After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 106698 - mailcheck applet should use ngettext
mailcheck applet should use ngettext
Status: RESOLVED FIXED
Product: gnome-applets
Classification: Other
Component: general
unspecified
Other All
: High normal
: ---
Assigned To: gnome-applets Maintainers
gnome-applets Maintainers
: 116986 (view as bug list)
Depends on:
Blocks: 116236
 
 
Reported: 2003-02-21 10:03 UTC by Christian Rose
Modified: 2005-08-15 01:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch. Untested, compiles fine. (876 bytes, patch)
2003-09-19 19:32 UTC, Christian Neumair
none Details | Review
Proposed patch, removed inner gettext calls. (864 bytes, patch)
2003-09-21 07:06 UTC, Christian Neumair
none 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 :) (1.59 KB, patch)
2004-01-02 18:41 UTC, Christian Neumair
none Details | Review
Split string into two ngettext-able parts (1.25 KB, patch)
2004-01-02 22:05 UTC, Danilo Segan
none Details | Review
Attempt #2: Split string into two ngettext-able parts (mark "%s/%s" for translation) (1.25 KB, patch)
2004-01-02 22:16 UTC, Danilo Segan
none Details | Review
#3: Hopefully completely correct patch (add g_strdup calls instead of removing g_free's) (1.27 KB, patch)
2004-02-01 13:13 UTC, Danilo Segan
none Details | Review

Description Christian Rose 2003-02-21 10:03:41 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);
Comment 1 Christian Neumair 2003-09-19 19:32:13 UTC
Created attachment 20112 [details] [review]
Proposed patch. Untested, compiles fine.
Comment 2 Christian Neumair 2003-09-19 19:34:52 UTC
mailcheck applet is now part of gnome-applets.

regs,
 Chris
Comment 3 Christian Neumair 2003-09-21 07:02:52 UTC
*** Bug 116986 has been marked as a duplicate of this bug. ***
Comment 4 Christian Neumair 2003-09-21 07:06:17 UTC
Created attachment 20152 [details] [review]
Proposed patch, removed inner gettext calls.
Comment 5 Christian Rose 2003-09-30 08:18:22 UTC
Can we revisit this issue now?
Comment 6 Kevin Vandersloot 2003-11-30 19:53:35 UTC
I think we can do this now for 2.5. Is this patch correct Christian?
Comment 7 Christian Rose 2003-11-30 22:23:18 UTC
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.
Comment 8 Danilo Segan 2003-11-30 23:06:10 UTC
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).
Comment 9 Christian Rose 2003-12-01 07:51:40 UTC
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.
Comment 10 Danilo Segan 2003-12-01 20:07:29 UTC
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.
Comment 11 Christian Neumair 2004-01-02 18:41:42 UTC
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 :)
Comment 12 Danilo Segan 2004-01-02 22:03:51 UTC
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.
Comment 13 Danilo Segan 2004-01-02 22:05:58 UTC
Created attachment 22845 [details] [review]
Split string into two ngettext-able parts
Comment 14 Danilo Segan 2004-01-02 22:16:06 UTC
Created attachment 22846 [details] [review]
Attempt #2: Split string into two ngettext-able parts (mark "%s/%s" for translation)
Comment 15 Danilo Segan 2004-01-02 22:26:18 UTC
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 ;).
Comment 16 Dennis Smit 2004-02-01 11:38:02 UTC
I am not good with i18n, Kevin could you approve this patch ?
Comment 17 Danilo Segan 2004-02-01 13:13:54 UTC
Created attachment 23941 [details] [review]
#3: Hopefully completely correct patch (add g_strdup calls instead of removing g_free's)
Comment 18 Kevin Vandersloot 2004-02-01 17:03:56 UTC
Applied. Thanks Danilo :)