GNOME Bugzilla – Bug 106698
mailcheck applet should use ngettext
Last modified: 2005-08-15 01:45:29 UTC
#: applets/gen_util/mailcheck.c:579 #, c-format msgid "%d/%d messages" #: applets/gen_util/mailcheck.c:581 #, c-format msgid "%d messages" 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);
Created attachment 20112 [details] [review] Proposed patch. Untested, compiles fine.
mailcheck applet is now part of gnome-applets. regs, Chris
*** Bug 116986 has been marked as a duplicate of this bug. ***
Created attachment 20152 [details] [review] Proposed patch, removed inner gettext calls.
Can we revisit this issue now?
I think we can do this now for 2.5. Is this patch correct Christian?
Nah, I think the first part should take into account that both the %d can be either singular or plural, so I think there is some string composition necessary, even though it should in general be avoided. The second part is ok though.
Just my 2c. Patch is completely correct for eg. Serbian. I don't know about other languages, but I suspect it's the same with them too. Here we've got '%d of %d messages', and not '%d messages of %d messages' (in which case menthos would be right). As for "freshness", this patch still applies cleanly against HEAD. Be sure to add check for ngettext in configure.in too (and check bug 116236 for further discussion).
The adjective "unread" is different in singular (n=1) and plural (n!=1) at least for Swedish: n1=1, n2=1: "%d unread/ %d message": "%d oläst/ %d meddelande" n1=1, n2=2: "%d unread/ %d messages": "%d oläst/ %d meddelanden" n1=2, n2=2: "%d unread/ %d messages": "%d olästa/ %d meddelanden" So ngettext is needed both for the first and second %d of this message.
Uhm, yes, you're correct -- I looked only at the original report, and missed that it's not "%d/%d messages" anymore, but rather "%d unread/%d messages" (which belongs in the case above I already marked as "menthos would be right" :). Sorry for the confusion.
Created attachment 22843 [details] [review] Proposed patch #3. Believe me, it was a PITA for a German and I don't know whether it works. Please test it dear Slavonians :)
Manny, I didn't actually test this patch, but I think it will cause problems while generating the POT files: ngettext must be provided with real strings, because that's what's used for msgid and msgid_plural while doing xgettext. Since third ngettext calls requires first evaluating plural1 and plural2 (which may have any number of different forms, depending on the language), it's impossible for xgettext to extract them, and ngettext call would use *translated* versions of plural1 and plural2 while doing a lookup in the MO file. I'll attach a patch which I would prefer.
Created attachment 22845 [details] [review] Split string into two ngettext-able parts
Created attachment 22846 [details] [review] Attempt #2: Split string into two ngettext-able parts (mark "%s/%s" for translation)
Damn, another ommision which I remembered to check just about... too late :( Sorry everyone for the spam. man 3 ngettext says: The resulting string is statically allocated and must not be modified or freed. This means that two g_free(plural1) and g_free(plural2) calls should be removed prior to commit in either Manny's or mine patch (hey Manny, don't try to trick me this way again ;).
I am not good with i18n, Kevin could you approve this patch ?
Created attachment 23941 [details] [review] #3: Hopefully completely correct patch (add g_strdup calls instead of removing g_free's)
Applied. Thanks Danilo :)