Difference between revisions of "Internationalization/plural forms"
(list of known forms) |
m (→=Three forms, special case for numbers ending in 1[2-9]) |
||
Line 70: | Line 70: | ||
:*Gaeilge (Irish) | :*Gaeilge (Irish) | ||
− | ===Three forms, special case for numbers ending in 1[2-9]== | + | ===Three forms, special case for numbers ending in 1[2-9]=== |
The header entry would look like this: | The header entry would look like this: | ||
Line 80: | Line 80: | ||
:Languages with this property include: | :Languages with this property include: | ||
:*Baltic family | :*Baltic family | ||
− | :*Lithuanian | + | :*Lithuanian |
===Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]=== | ===Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]=== |
Revision as of 06:56, 31 May 2006
The information about the plural form selection has to be stored in the header entry of the PO file (the one with the empty msgid string). The plural form information looks like this:
- Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;
The nplurals value must be a decimal number which specifies how many different plural forms exist for this language. The string following plural is an expression which is using the C language syntax. Exceptions are that no negative numbers are allowed, numbers must be decimal, and the only variable allowed is n. This expression will be evaluated whenever one of the translation function for a "plural form" is called. The numeric value passed to these functions is then substituted for all uses of the variable n in the expression. The resulting value then must be greater or equal to zero and smaller than the value given as the value of nplurals.
Contents
- 1 Rules
- 1.1 Only one form
- 1.2 Two forms, singular used for one only
- 1.3 Two forms, singular used for zero and one
- 1.4 Three forms, special case for zero
- 1.5 Three forms, special cases for one and two
- 1.6 Three forms, special case for numbers ending in 1[2-9]
- 1.7 Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
- 1.8 Three forms, special case for one and some numbers ending in 2, 3, or 4
- 1.9 Four forms, special case for one and all numbers ending in 02, 03, or 04
Rules
The (at this point) known rules are:
Only one form
Some languages only require one single form. There is no distinction between the singular and plural form. An appropriate header entry would look like this:
- Plural-Forms: nplurals=1; plural=0;
- Languages with this property include:
- Finno-Ugric family
- Hungarian
- Asian family
- Japanese, Korean
- Turkic/Altaic family
- Turkish
Two forms, singular used for one only
This is the form used in most existing programs since it is what English is using. A header entry would look like this:
- Plural-Forms: nplurals=2; plural=n != 1;
- (Note: this uses the feature of C expressions that boolean expressions have to value zero or one.)
- Languages with this property include:
- Germanic family
- Danish, Dutch, English, German, Norwegian, Swedish
- Finno-Ugric family
- Estonian, Finnish
- Latin/Greek family
- Greek
- Semitic family
- Hebrew
- Romanic family
- Italian, Portuguese, Spanish
- Artificial
- Esperanto
Two forms, singular used for zero and one
Exceptional case in the language family. The header entry would be:
- Plural-Forms: nplurals=2; plural=n>1;
- Languages with this property include:
- Romanic family
- French, Brazilian Portuguese
Three forms, special case for zero
The header entry would be:
- Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;
- Languages with this property include:
- Baltic family
- Latvian
Three forms, special cases for one and two
The header entry would be:
- Plural-Forms: nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;
- Languages with this property include:
- Celtic
- Gaeilge (Irish)
Three forms, special case for numbers ending in 1[2-9]
The header entry would look like this:
- Plural-Forms: nplurals=3; \
- plural=n%10==1 && n%100!=11 ? 0 : \
- n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2;
- plural=n%10==1 && n%100!=11 ? 0 : \
- Languages with this property include:
- Baltic family
- Lithuanian
Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
The header entry would look like this:
- Plural-Forms: nplurals=3; \
- plural=n%10==1 && n%100!=11 ? 0 : \
- n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
- plural=n%10==1 && n%100!=11 ? 0 : \
- Languages with this property include:
- Slavic family
- Croatian, Czech, Russian, Slovak, Ukrainian
Three forms, special case for one and some numbers ending in 2, 3, or 4
The header entry would look like this:
- Plural-Forms: nplurals=3; \
- plural=n==1 ? 0 : \
- n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
- plural=n==1 ? 0 : \
- Languages with this property include:
- Slavic family
- Polish
Four forms, special case for one and all numbers ending in 02, 03, or 04
The header entry would look like this:
- Plural-Forms: nplurals=4; \
- plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3;
- Languages with this property include:
- Slavic family
- Slovenian