plural form (ngettext)

Bug #420368 reported by abdullahc
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Keryx
New
Undecided
Unassigned

Bug Description

Hi all,

Some entries of PO file need to be the plural form (I mean the use ngettext instead of gettext) :

_ Plugin(s) have failed to load. This may be due to not having python-wxversion installed.
_ file(s)
_ files? # I'm not sure about this one! check it please.

ex. "file(s)", for arabic need 6 forms instead of 2 for english.

Revision history for this message
Chris Oliver (excid3) wrote :

Ah, I am not familiar with internationalization or translation support whatsoever. Does this mean we should simply switch gettext to ngettext and that is all that is needed to be done?

Revision history for this message
abdullahc (sneetsher) wrote :

Yeah,

Here the definition from GNU manual:
============================
Function: char * ngettext (const char *msgid1, const char *msgid2, unsigned long int n)

    The ngettext function is similar to the gettext function as it finds the message catalogs in the same way. But it takes two extra arguments. The msgid1 parameter must contain the singular form of the string to be converted. It is also used as the key for the search in the catalog. The msgid2 parameter is the plural form. The parameter n is used to determine the plural form. If no message catalog is found msgid1 is returned if n == 1, otherwise msgid2.

    An example for the use of this function is:

              printf (ngettext ("%d file removed", "%d files removed", n), n);

    Please note that the numeric value n has to be passed to the printf function as well. It is not sufficient to pass it only to ngettext.

    In the English singular case, the number – always 1 – can be replaced with "one":

              printf (ngettext ("One file removed", "%d files removed", n), n);

    This works because the ‘printf’ function discards excess arguments that are not consumed by the format string.

    It is also possible to use this function when the strings don't contain a cardinal number:

              puts (ngettext ("Delete the selected file?",
                              "Delete the selected files?",
                              n));

    In this case the number n is only used to choose the plural form.
============================

As you see:

- n is the number of the things you are counting.

- English has 2 forms. You will write them directly in the source. as with gettext!
 (and for other languages form gettext lib will take care of them depending on your variable n and plural equation of that language. Don't worry about this, All what they needs is just n)

Alright?

Revision history for this message
abdullahc (sneetsher) wrote :

I forgot, another thing,

Try to write a full sentence using FORMAT. Because some languages need to swap (rearrange) the words.

Revision history for this message
Chris Oliver (excid3) wrote :

Okay awesome. We will definitely be adding support for this soon. Thanks for your explanation, from what I had read online it was really confusing and messy sounding. This shouldn't be too hard.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.