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 123847 - Please use ngettext in Gtk+
Please use ngettext in Gtk+
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other other
: Urgent normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 116236
 
 
Reported: 2003-10-04 20:37 UTC by Danilo Segan
Modified: 2011-02-04 16:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to use ngettext in gdk-pixdata.c (638 bytes, patch)
2003-10-04 20:40 UTC, Danilo Segan
none Details | Review
Proposed patch containing both fixes. (1.39 KB, patch)
2003-12-30 20:06 UTC, Christian Neumair
none Details | Review

Description Danilo Segan 2003-10-04 20:37:49 UTC
(Following paragraph copied from bug 116236 verbatim :-)
As mentioned in
http://developer.gnome.org/doc/tutorials/gnome-i18n/developer.html#plurals,
the common way of handling plurals is broken for many locales. A way to solve
this is by using ngettext instead, as mentioned in that document.


This is the relevant message in Gtk+ HEAD.

#: gdk-pixbuf/gdk-pixdata.c:402
#, c-format
msgid "failed to allocate image buffer of %u bytes"
msgstr ""

I'll attach a patch.
Comment 1 Danilo Segan 2003-10-04 20:40:21 UTC
Created attachment 20465 [details] [review]
Patch to use ngettext in gdk-pixdata.c
Comment 2 Matthias Clasen 2003-10-05 20:03:32 UTC
I doubt that we want to introduce a ngettext dependency for that
specific message... single-byte images are not very common, and a
failure to allocate a single-byte buffer is even more rare...
Comment 3 Danilo Segan 2003-10-05 22:48:16 UTC
Ah, I've heard those "arguments" before ;-)

Actually, this has nothing to do with (only) single vs. plural, unless
you're thinking of *only* Western-like (whatever that might be ;-)
languages. Many languages differentiate only between singularity and
plurality, and use the appropriate form in any case (two cases total).

For many Slavic languages, words that follow numbers take different
forms in different cases, depending on the number, not only on whether
it's plural or singular.

For instance, in Serbian, we've got:
"Image of 1 byte"
"Image of 2 bytes" (the same for all numbers ending in 2, 3, 4, except
those ending with 12, 13, 14)
"Image of 7 byteos" (just to illustrate the difference)
"Image of 41 byte" (like for "1", if it ends with one, and not with
11, than it's treated like "singular")

So, as you might see here, Serbian has 3 forms of "plural", and
Slovenian should have 4 (please see the referenced page for details).

Similar things also apply to Russian, Polish, Slovenian, and other
languages -- ngettext is designed precisely to solve this issue.

I hope this clarifies a bit, and thanks for prompt response.
Comment 4 Matthias Clasen 2003-10-07 09:15:20 UTC
Thanks, its easy to forget this. 


Java's MessageFormat handles this much better, IMO.
Comment 5 Danilo Segan 2003-11-04 16:32:00 UTC
Recent changes to Gtk+ have added one more message:

#: gtk/gtkfilechooserdefault.c:2457
#, c-format
msgid "%d bytes"
Comment 6 Christian Neumair 2003-12-30 20:06:54 UTC
Created attachment 22781 [details] [review]
Proposed patch containing both fixes.
Comment 7 Christian Neumair 2003-12-31 16:02:52 UTC
Approved by Tim Janik. Committed. Closing.

regs,
 Chris
Comment 8 Owen Taylor 2004-01-05 14:32:09 UTC
Committing this was *not* OK, since we do not currently require
ngettext for the GTK+ stack. If we made this change, we would
require ngettext at glib, so someone wouldn't have to rebuild
everything when GTK+ failed.
Comment 9 Christian Neumair 2004-01-06 07:35:07 UTC
So what? Can't we simply add ngettext dependency to glib? Writing a
check wouldn't be hard at all.

regs,
 Chris
Comment 10 Danilo Segan 2004-01-08 19:48:08 UTC
Owen, I think it is possible to use ngettext if it is available,
otherwise offer those messages untranslated.

Though, this would require a bit more changes to the build system: if
ngettext was not found, msgfmt should receive preprocessed files which
don't contain msgstr[[0-9]+] and msgid_plural lines (otherwise, it
would break).

Of course, ngettext(a,b,c) should be redefined to simple gettext(b),
using #ifdef. I know you have discussed adding GNU gettext to the
glib's dependencies, and that you planned to do it in the 2.6 (Gtk+'s,
not GNOME's) timeframe, but this has the advantage of not depending on
any particular gettext version, and yet providing the best for those
that can take it.

I'm willing to work on that if you agree it's acceptable for 2.4 (bug
116236 already has simple Perl code which comments out such messages
in PO files, it just needs to be integrated into build system ).

So, what do you think about this way of supporting it? That would also
remove ngettext as a potential reason for depending on newer (or
"GNUer" ;) gettextes.
Comment 11 Danilo Segan 2004-01-30 12:38:21 UTC
There's already one message which makes use of plural forms in Gtk+,
perhaps this needs to be removed (and that needs to happen before
string freeze on February 9th), if it's not planned to be supported in
2.4 (which is a big shame, and if we take into account that this
message has been in Gtk+ for over a month, and nobody complained, I
guess ngettext really *is* very widely supported).

#: gdk-pixbuf/gdk-pixdata.c:402
#, c-format
msgid "failed to allocate image buffer of %u byte"
msgid_plural "failed to allocate image buffer of %u bytes"

(I also raised the priority to "Urgent", so this would get fixed in
this timeframe, feel free to lower it once this is removed)
Comment 12 Matthias Clasen 2004-08-06 01:21:39 UTC
I think we should decide whether we want to require ngettext for glib 2.6.
As things stand, gdk-pixbuf contains a single message using ngettext() since
last December, since Christians commit didn't get reverted for gdk-pixdata.c.
Comment 13 Danilo Segan 2004-08-06 05:43:35 UTC
Half a year has passed (entire Gnome release cycle :), while Gtk+ is
compileable/usable only with ngettext()-supporting gettext (including stuff such
as xgettext, msgfmt), so I guess we can already assume Gtk+ requires it.  Going
down in the library stack will affect only minor number of glib-only projects
(though, if some of those projects are for embedded platforms, this might be
undesired dependency).
Comment 14 Matthias Clasen 2004-08-06 17:35:07 UTC
I have made configure require ngettext now in glib HEAD.