GNOME Bugzilla – Bug 106700
Please use ngettext for handling plurals in gnome-utils
Last modified: 2004-12-22 21:47:04 UTC
#: logview/info.c:186 #, c-format msgid "%ld bytes" #: gfloppy/src/progress.c:123 #, c-format msgid "" "The floppy has been formatted, but <b>%d bad blocks</b> (out of %d) have " "been found and marked." #: gsearchtool/gsearchtool.c:831 #, c-format msgid "%d files found" #: gsearchtool/gsearchtool-callbacks.c:299 #, c-format msgid "This will open %d separate files. Are you sure you want to do this?" #: gsearchtool/gsearchtool-callbacks.c:302 #, c-format msgid "Open %d Files?" #: gsearchtool/gsearchtool-callbacks.c:404 #, c-format msgid "This will open %d separate folders. Are you sure you want to do this?" #: gsearchtool/gsearchtool-callbacks.c:407 #, c-format msgid "Open %d Folders?" As mentioned in http://developer.gnome.org/doc/tutorials/gnome-i18n/developer.html#plurals, this way of handling plurals is broken for many locales. A way to solve this is by using ngettext instead as mentioned in that document. A simple code example of code using ngettext: g_printf (ngettext ("Found %d file.", "Found %d files.", nbr_of_files), nbr_of_files);
was this decided that this should be standard?
Created attachment 20150 [details] [review] Proposed patch.
Gman: It makes translators' lifes easier since it bundles strings that belong to each other at one location inside the po files: #: gsearchtool/gsearchtool.c:1237 #, c-format msgid "%d file found" msgid_plural "%d files found" msgstr[0] "%d Dateien gefunden" msgstr[1] "%d Dateien gefunden" menthos: You can safely ignore the last 4 strings since these messages only show up if a file limit (5) is exceeded. regs, Chris
Can we have this issue revisited now?
None of these can be ignored for correct plural forms support. For instance, in Serbian language, plural is not used if the number ends in 1 (eg. 21, 31, 7271 are all written with *singular*). Also, in Serbian and some other languages (see the GNU gettext.info manual for more examples), the word used depends in more subtle ways than just plural and not-plural (for instance, numbers ending in 2, 3 or 4 use another form for nouns and adjectives that follow them, so we've got "Otvori 24 knjige" and "Otvori 27 knjiga" for "Open %d books").
Danilo: Your problem seems to be very weird and very fundamental - and doesn't have anything to do with this bug report. Are there any other approaches? Have there been any efforts for resolving this? Any concrete proposal? regs, Chris
Manny, "my problem" is exactly what plural forms and ngettext solve. Please see the plural forms section in gettext.info manual (eg. "info gettext" and then "m plural<RET>" if you're using standalone info viewer; yelp can view info files too). As a matter of fact, similar example (for Polish) is given on that page: In Polish we use e.g. plik (file) this way: 1 plik 2,3,4 pliki 5-21 pliko'w 22-24 pliki 25-31 pliko'w What probably bothers you is how is it defined that there are more than two plural forms. That is defined in PO file header (translation of msgid "") in field Plural-Forms. For a concrete, working example, see gnome-games/po/sr.po. So, the idea behind ngettext was not to make "translators' job easier by bundling strings together", but rather, to make it possible for Russian, Polish, Serbian, Croatian, Slovenian, and *many* other languages have it translated *correctly*.
Created attachment 20409 [details] [review] Proposed patch #2
any traction here? seems like this should be a gnome wide decision.
It is a gnome wide decision (see bug 116236 which is linked to this one), and AFAIK the decision has already been made (see the last comment in that report). gnome-games (bug 106697), gnopernicus (bug 116235), gnome-applets (bug 116986), gnome-terminal (bug 106699), and nautilus-cd-burner (bug 123857) all use ngettext already, so prolly gnome-utils could and should too.
The following all seem very related, and should probably belong into one ngettext call (except maybe the zero-case): #: gsearchtool/gsearchtool.c:565 msgid "No Files Found" #: gsearchtool/gsearchtool.c:570 msgid "One File Found" #: gsearchtool/gsearchtool.c:571 msgid "One file found" #: gsearchtool/gsearchtool.c:574 #, c-format msgid "%d Files Found"
Created attachment 22366 [details] [review] New patch against HEAD.
Looks good to me. You can commit when Dennis gives you permission on the gsearchtool parts of the patch.
In gsearchtool.c, + message_string = ngettext ("%d file Found", + "%d files Found", + total_files); This string should read "found" not "Found". Assuming the patch has been tested, please commit it with the above fix.
Done. Closing. regs, Chris