Hi!

On Sun, 2013-03-24 at 20:51:39 +0100, Jakub Wilk wrote:
> I initially imported all plural forms that were known to gettext,
> but then did some reality checking and commented out those that
> weren't used in practice or were otherwise problematic. If an entry
> is commented out, it means that I haven't wrapped my head around it
> yet. :)

Sure, makes sense. :)

> Bosnian (together with Belarusian, Croatian, Russian, Serbian and
> Ukrainian) is actually an interesting case. According to gettext
> documentation and Translate Toolkit wiki, the correct Plural-Forms
> for them is:
> 
> nplurals=3; plural= \
>       n%10==1 && n%100!=11 ? 0 : \
>       n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
> 
> This expression has an unpleasant property that plural(1) ==
> plural(21). Why is that a problem? Well, usually it isn't. But
> sometimes software authors use plural forms in messages like this:

Aha, thanks for pointing this out, had missed that when skimming over
those sites/docs.

> msgid "an apple"
> msgid_plural "apples"
> 
> or like this:
> 
> msgid "an apple"
> msgid_plural "%d apples"
> 
> Then in translation you would get singular form, even though the
> numeral is greater than 1. Ooops!

Actually, it does not really matter how the original string was
written, as long as the translated string matches the plural-form
formula. The argument to the printf-like function will be passed
anyway (if it is passed at all), so it can still be translated
like this:

msgid "an apple"
msgid_plural "%d apples"
msgstr[0] "%d poma"
msgstr[1] "%d pomes"

So to me this seems to end up being a matter of style and how the
translators want to translate the strings.

> Of course, I'm not the first one who noticed this is a problem. In
> fact, majority of Russian, Serbian and Ukrainian MO files in Debian
> use this Plural-Forms instead:
> 
> nplurals=4; plural= \
>       n==1 ? 3 : \
>       n%10==1 && n%100!=11 ? 0 : \
>       n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
> 
> This is the same as above, but with special case for 1.

Given the above, then I think a solution could be to accept both
plural-forms as valid (because they are a matter of translation-style).
And ideally, i18nslator would check that if the condensed form is used
(nplurals=3), the msgstr matching n==1 contains the same amount of
format directives as the msgstr matching f.ex. n==2, to detect the
problematic case you brought up before, and to not trip on strings
with more than one format directive, for example:

msgstr[0] "numeral-or-article text-0 %d"
msgstr[1] "%d text-1 %d"
msgstr[2] "%d text-2 %d"

This would then trigger a warning.

Thanks,
Guillem


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to