Difference between revisions of "Internationalization/plural forms"

(list of known forms)
 
(Rules: added arabic)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
[[Category:Internationalization]]
 +
 
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:  
 
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;
 
::Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;
Line 14: Line 16:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Finno-Ugric family  
 
:*Finno-Ugric family  
:*Hungarian  
+
:**Hungarian  
 
:*Asian family  
 
:*Asian family  
:*Japanese, Korean  
+
:**Japanese, Korean  
 
:*Turkic/Altaic family  
 
:*Turkic/Altaic family  
:*Turkish  
+
:**Turkish  
  
 
===Two forms, singular used for one only===
 
===Two forms, singular used for one only===
Line 29: Line 31:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Germanic family  
 
:*Germanic family  
:*Danish, Dutch, English, German, Norwegian, Swedish  
+
:**Danish, Dutch, English, German, Norwegian, Swedish  
 
:*Finno-Ugric family  
 
:*Finno-Ugric family  
:*Estonian, Finnish  
+
:**Estonian, Finnish  
 
:*Latin/Greek family  
 
:*Latin/Greek family  
:*Greek  
+
:**Greek  
 
:*Semitic family  
 
:*Semitic family  
:*Hebrew  
+
:**Hebrew  
 
:*Romanic family  
 
:*Romanic family  
:*Italian, Portuguese, Spanish  
+
:**Italian, Portuguese, Spanish  
 
:*Artificial  
 
:*Artificial  
:*Esperanto  
+
:**Esperanto  
  
 
===Two forms, singular used for zero and one===
 
===Two forms, singular used for zero and one===
Line 49: Line 51:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Romanic family  
 
:*Romanic family  
:*French, Brazilian Portuguese  
+
:**French, Brazilian Portuguese  
  
 
===Three forms, special case for zero===
 
===Three forms, special case for zero===
Line 59: Line 61:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Baltic family  
 
:*Baltic family  
:*Latvian  
+
:**Latvian  
  
 
===Three forms, special cases for one and two===
 
===Three forms, special cases for one and two===
Line 68: Line 70:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Celtic  
 
:*Celtic  
:*Gaeilge (Irish)  
+
:**Gaeilge (Irish)  
 +
:*Semitic family
 +
:**Arabic
  
===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 84:
 
: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]===
Line 92: Line 96:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Slavic family  
 
:*Slavic family  
:*Croatian, Czech, Russian, Slovak, Ukrainian  
+
:**Croatian, Czech, Russian, Slovak, Ukrainian  
  
 
===Three forms, special case for one and some numbers ending in 2, 3, or 4===
 
===Three forms, special case for one and some numbers ending in 2, 3, or 4===
Line 104: Line 108:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Slavic family  
 
:*Slavic family  
:*Polish  
+
:**Polish  
  
 
===Four forms, special case for one and all numbers ending in 02, 03, or 04===
 
===Four forms, special case for one and all numbers ending in 02, 03, or 04===
Line 115: Line 119:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Slavic family  
 
:*Slavic family  
:*Slovenian
+
:**Slovenian

Latest revision as of 04:34, 28 June 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.

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)
  • Semitic family
    • Arabic

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;
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;
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;
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