bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU Coding Standards, internatialisation and plurals


From: Michael Thayer
Subject: Re: GNU Coding Standards, internatialisation and plurals
Date: Sat, 20 May 2006 10:21:57 +0200

Hello Karl,

The solution to the problem of multiple plurals is GNU gettext's
ngettext() function.  The format is

 char * ngettext (const char *msgid1, const char *msgid2, unsigned long int n)

The first two arguments are the English singular and plural, which are
necessary because gettext defaults to English if no translations are
found.  The argument n is used to select the correct translation, and
the translator supplies the number of translations needed for their
language.  Treating zero as a separate case in English ("No files
found") is not required, but does no harm either, since that is a
fixed string with a fixed translation, and is certainly more elegant
(than "Found 0 files").

The second case could be dealt with as "Searched %d directories.  ",
"Found %d files" (in two separate strings) or "Searched %d directories
", "and found %d files", which should work in most languages since the
"and" conjunction effectively makes it two separate sentences (please
get confirmation from as many translators as possible about this,
because I am generalising from languages I speak, which is not always
a safe thing to do!)  As you said, it is probably not very common in
practice anyway, but it would perhaps not hurt for people to be aware
of the problem when they write their messages to save time later.

Thanks and kind regards,

Michael

Am 2006/5/20 schrieb Karl Berry <address@hidden>:
Hi Michael,

Thanks for writing.

    This has the problem that not all languages treat singular and plural
    the same way as English.

I see the problem, but what is the solution?  Repeating every message
containing a number to have separate cases for so many integers seems
quite impractical.  Cc-ing gnulib friends for their input ...

    Another thing worth mentioning is that it is better to limit strings
    to be translated to one number argument per sentence unit

A good point, thanks.  I can see the advice being hard to follow in
practice, though, since "found %d files in %d directories" is such a
natural expression in English.  Fortunately I don't think it comes up
*too* often.

Best regards,
Karl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]