[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gettext and plurals
A comment on the ngettext function (I just read the new glibc CVS
documentation on this): According to [1], there are languages with more
than singular and plural: Arabic, Lithuanian, Slovenian, and Ancient Egyptian
have singular, dual, plural. You cannot cover them with an 'ngettext'
function which takes two strings:
printf (ngettext ("%d file removed", "%d files removed", n), n);
because three strings would be needed for these languages. (Can anyone
fluent in one of these languages give more details?)
Therefore I'd propose to pass to ngettext just one string, but with a
special syntax for the alternatives:
%[ singular %; plural %]
or %[ singular %; dual %; plural %]
In other words, the first piece of string is for n=1, the second one for
n=2, and so on, and the last piece of string is the default. (*)
Your example would therefore look like this:
printf (ngettext ("%[%d file%;%d files%] removed", n), n);
Bruno
[1] http://www.lmp.ucla.edu/proflng.htm
(*) The syntax resembles the one used in Common Lisp format strings. Those
who don't know Lisp are doomed to reinvent it.
-
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/lists/