GNOME Bugzilla – Bug 123847
Please use ngettext in Gtk+
Last modified: 2011-02-04 16:17:18 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.
Created attachment 20465 [details] [review] Patch to use ngettext in gdk-pixdata.c
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...
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.
Thanks, its easy to forget this. Java's MessageFormat handles this much better, IMO.
Recent changes to Gtk+ have added one more message: #: gtk/gtkfilechooserdefault.c:2457 #, c-format msgid "%d bytes"
Created attachment 22781 [details] [review] Proposed patch containing both fixes.
Approved by Tim Janik. Committed. Closing. regs, Chris
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.
So what? Can't we simply add ngettext dependency to glib? Writing a check wouldn't be hard at all. regs, Chris
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.
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)
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.
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).
I have made configure require ngettext now in glib HEAD.