By lisa on
Having trouble understanding how to write Plural Form line in po files.
Where can I find an explanation of INTERGER and EXPRESSION - I don't understand the syntax of:
"Plural-Forms: nplurals=INTERGER; plural=EXPRESSION;"
Working on po file for Latvian. In other language po files I've seen:
"Plural-Forms: nplurals=2; plural=($n!=1);"
"Plural-Forms: nplurals=2; plural=(n > 1);"
for French
"Plural-Forms: nplurals=2; plural=(n != 1);"
Comments
The first thing is the
The first thing is the number of plural forms. Many languages have only two (singular and plural), a few have only one (Japanese I think), and some have more than two (Polish and I think Latvian).
The second part is a formula that states for which numbers which plural form is to be used. plural=(n != 1) means that for every number which is not 1 the plural form is to be used.
A better explanation is here:
http://www.gnu.org/software/gettext/manual/html_node/gettext_150.html
It comes even with an example for Latvian.
--
Drupal services
My Drupal services
--
Drupal services
My Drupal services
about msgstr[2]
Thanks so much for your explanations and the link - both were very helpful. According to that link, Latvian has 3 forms including a special case for zero. The Plural-Form line for Latvian should look like this:
Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;Breaking it down, I think this means:
n%10==1 && n%100!=11 ? 0This relates to msgstr[0] and means the number equals 1 but not 11
n != 0 ? 1This relates to msgstr[1] and means the number is NOT 0
2This relates to msgstr[2] and means all other numbers (special case for 0)
1. Is that the correct meaning of the expression?
I think this means I need to add msgstr[2] in all necessary places in the po files. For example, common-inc.po has:
I should modify it like this:
2. Is this correct?
Thanks again for your help.
Yes, this appears to be
Yes, this appears to be correct.
--
Drupal services
My Drupal services
--
Drupal services
My Drupal services
seems to work
thanks - seems to work
List of plural forms
This list of Gettext plural forms will help you find the correct settings for your language.