Difference between revisions of "Internationalization/plural forms"

m (added page to our category)
(Rules: added arabic)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
[[Category:Projects]]
 
 
[[Category:Internationalization]]
 
[[Category:Internationalization]]
  
Line 17: 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 32: 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 52: 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 62: 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 71: 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]===
Line 83: 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 95: 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 107: 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 118: Line 119:
 
:Languages with this property include:  
 
:Languages with this property include:  
 
:*Slavic family  
 
:*Slavic family  
:*Slovenian
+
:**Slovenian

Latest revision as of 05: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