[libreoffice-l10n] plural forms translation, ngettext

2018-10-05 Thread Caolán McNamara
I was asked in 
https://bugs.documentfoundation.org/show_bug.cgi?id=83128 about
supporting ngettext-alike plural forms.

https://gerrit.libreoffice.org/#/c/61426/ is my proposal on that.

To current Translate::get(id) we add Translate::nget(id, cardinality)
when requesting the translation.

To current NC_(context, string) we add NNC_(context, singular, plural)
when declaring the strings for translation

We add --keyword=NNC_:1c,2,3 to our xgettext invocation resulting in a
change in the output .po for my calc SCSTR_TOTAL example from

msgctxt "SCSTR_TOTAL"
msgid "%1 results found"
msgstr ""

to

msgctxt "SCSTR_TOTAL"
msgid "1 result found"
msgid_plural "%1 results found"
msgstr[0] ""
msgstr[1] ""

Locally at least this works to give the desired expected results of "1
result found" vs "2 results found" for the simple example.

caolanm->cloph: would this work smoothly with our current pootle stuff?


-- 
To unsubscribe e-mail to: l10n+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/l10n/
Privacy Policy: https://www.documentfoundation.org/privacy


[libreoffice-l10n] Re: plural forms translation, ngettext

2018-10-05 Thread sophi
Hi Mike,
Le 05/10/2018 à 17:57, Kaganski Mike a écrit :
> On 10/5/2018 6:09 PM, Caolán McNamara wrote:
>> To current NC_(context, string) we add NNC_(context, singular, plural)
>> when declaring the strings for translation
> 
> How does it play with other languages, where we might have more complex 
> rules? E.g., in Russian, a "singular" form might be used for any decimal 
> integer ending with 1 except 11 (e.g., 21, 31, 101...); also endings for 
> numbers with 2, 3, 4 differ from 5 and greater (22 from 25 likewise)...

I guess the number of msgstr[N] "" needed is based on your plural
equation added in Pootle or your translation tool:
(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 ||
n%100>=20) ? 1

it's explained here:
https://www.gnu.org/software/gettext/manual/html_node/Translating-plural-forms.html
and here:
https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html#Plural-forms

Cheers
Sophie

-- 
Sophie Gautier sophie.gaut...@documentfoundation.org
GSM: +33683901545
IRC: sophi
Release coordinator
The Document Foundation

-- 
To unsubscribe e-mail to: l10n+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/l10n/
Privacy Policy: https://www.documentfoundation.org/privacy