bugGNU gettext - Bugs: bug #23183, msgfmt -c should accept...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #23183: msgfmt -c should accept translations that omit any or all arguments

Submitted by:  Benjamin Geer <bgeer>
Submitted on:  Tue 06 May 2008 04:12:48 PM UTC  
 
Category: Plural formsSeverity: 3 - Normal
Item Group: NoneStatus: Not a Bug
Privacy: PublicAssigned to: Bruno Haible <haible>
Open/Closed: Closed

Tue 06 May 2008 11:20:27 PM UTC, comment #2:

I have this piece of documentation to the manual, regarding
ngettext:

If this function is meant to yield a format string that takes two
or more arguments, you cannot use it like this:

printf (ngettext ("%d file removed from directory %s",
"%d files removed from directory %s",
n, dir),
n);

because in many languages the translators want to replace the `%d'
with an explicit word in the singular case, just like "one" in
English, and C format strings cannot consume the second argument
but skip the first argument. Instead, you have to reorder the
arguments so that `n' comes last:

printf (ngettext ("%$2d file removed from directory %$1s",
"%$2d files removed from directory %$1s",
dir, n),
n);

See *note c-format:: for details about this argument reordering
syntax.

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Tue 06 May 2008 11:00:20 PM UTC, comment #1:

> If the translation of a plural form includes argument 2 but omits
> argument 1, msgfmt -c rejects it with the following error
> message:
>
> "msgstr[0]' is not a valid C format string, unlike 'msgid'.
> Reason: The string refers to argument number 2 but ignores
> argument number 1."
>
> This is incorrect


The error message is correct. A string like "une piece %$2s"
simply is not a valid C format string. When you pass it to
printf, printf produces an error code.

In C, a format string can choose to ignore the last argument,
however.

> in Arabic, omitting an argument in the translation is often
> the right thing to do. If the value of the argument is 0, 1
> or 2 (as determined by the gettext plural expression), the
> translation should reflect this value by using the appropriate
> the form of the Arabic word for "piece", rather than by
> including the number itself in the translation; therefore the
> translation will not refer to the argument.


Thank you for explaining. What you can do, is to ask the
programmer to swap the assignment of the argument numbers:

English singular:
%2$'d Piece @ %1$s
English plural:
%2$'d Pieces @ %1$s

Then you will be able to omit the reference to argument number
2, and "msgfmt -c" will accept it. (By "the programmer" I mean
the address listed in the Report-Msgid-Bugs-To field of the
PO file header.)

I will add a note about it to the gettext manual. Thank you
very much for bringing up this issue!

Bruno Haible <haible>
Project AdministratorIn charge of this item.
Tue 06 May 2008 04:12:48 PM UTC, original submission:

Given the following message to be translated:

English singular:
%1$'d Piece @ %2$s
English plural:
%1$'d Pieces @ %2$s

If the translation of a plural form includes argument 2 but omits argument 1, msgfmt -c rejects it with the following error message:

"msgstr[0]' is not a valid C format string, unlike 'msgid'. Reason: The string refers to argument number 2 but ignores argument number 1."

This is incorrect, because in Arabic, omitting an argument in the translation is often the right thing to do. If the value of the argument is 0, 1 or 2 (as determined by the gettext plural expression), the translation should reflect this value by using the appropriate the form of the Arabic word for "piece", rather than by including the number itself in the translation; therefore the translation will not refer to the argument. There's an example here on the Arabeyes project Wiki: http://tinyurl.com/4dweuj .

Therefore msgfmt -c should allow the translation to omit any or all arguments, since only the translator can know which ones are needed in a particular language.

Benjamin Geer <bgeer>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by haible (Posted a comment)
  • -unavailable- added by bgeer (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 26 Nov 2016 11:57:28 PM UTChaibleCategoryNone=>Plural forms
    Tue 06 May 2008 11:00:20 PM UTChaibleStatusNone=>Not a Bug
      Assigned toNone=>haible
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1