gettext Plural-Forms for 42 languages, checked number by number against CLDR

Languages

A gettext plural entry keeps its forms in numbered slots, msgstr[0], msgstr[1] and on, and the Plural-Forms line in the file's header is a small C formula that picks the slot for a number. For Polyglot 1.4.0 we needed that formula for all 42 languages it translates into, and each slot had to hold the form that CLDR, the plural data behind Android, ICU and our own checks, gives the same numbers. Here is the table, and how we checked it.

The header for every language CLDR has plural rules for, and a checker for your own, are on Plural-Forms for every language.

How we checked it

Where older data disagreed

We first checked against Babel 2.10, which carries CLDR 41 from 2022. Three languages came out differently, and in each the newer data and the language itself agree with the table:

What the slots hold

The table

LanguagegettextPlural-Formsmsgstr[0], [1]…
Amharicamnplurals=2; plural=(n > 1);one, other
Arabicarnplurals=6; plural=(n == 0) ? 0 : ((n == 1) ? 1 : ((n == 2) ? 2 : ((n % 100 >= 3 && n % 100 <= 10) ? 3 : ((n % 100 >= 11) ? 4 : 5))));zero, one, two, few, many, other
Armenianhynplurals=2; plural=(n > 1);one, other
Bulgarianbgnplurals=2; plural=(n != 1);one, other
Chinese (Simplified)zh_CNnplurals=1; plural=0;other
Chinese (Traditional)zh_TWnplurals=1; plural=0;other
Czechcsnplurals=3; plural=(n == 1) ? 0 : ((n >= 2 && n <= 4) ? 1 : 2);one, few, other
Dutchnlnplurals=2; plural=(n != 1);one, other
Filipinofilnplurals=2; plural=(n != 1 && n != 2 && n != 3 && (n % 10 == 4 || n % 10 == 6 || n % 10 == 9));one, other
Finnishfinplurals=2; plural=(n != 1);one, other
Frenchfrnplurals=2; plural=(n > 1);one, other
Germandenplurals=2; plural=(n != 1);one, other
Greekelnplurals=2; plural=(n != 1);one, other
Haitian Creolehtnplurals=1; plural=0;other
Hebrewhenplurals=3; plural=(n == 1) ? 0 : ((n == 2) ? 1 : 2);one, two, other
Hungarianhunplurals=2; plural=(n != 1);one, other
Indonesianidnplurals=1; plural=0;other
Italianitnplurals=2; plural=(n != 1);one, other
Japanesejanplurals=1; plural=0;other
Kannadaknnplurals=2; plural=(n > 1);one, other
Khmerkmnplurals=1; plural=0;other
Koreankonplurals=1; plural=0;other
Macedonianmknplurals=2; plural=(n % 10 == 1 && n % 100 != 11) ? 0 : 1;one, other
Malaymsnplurals=1; plural=0;other
Norwegian Bokmålnbnplurals=2; plural=(n != 1);one, other
Oromoomnplurals=2; plural=(n != 1);one, other
Persianfanplurals=2; plural=(n > 1);one, other
Polishplnplurals=3; plural=(n == 1) ? 0 : ((n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14)) ? 1 : 2);one, few, many
Portuguese (Brazil)pt_BRnplurals=2; plural=(n > 1);one, other
Punjabipanplurals=2; plural=(n > 1);one, other
Romanianronplurals=3; plural=(n == 1) ? 0 : ((n == 0 || n % 100 >= 1 && n % 100 <= 19) ? 1 : 2);one, few, other
Russianrunplurals=3; plural=(n % 10 == 1 && n % 100 != 11) ? 0 : ((n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14)) ? 1 : 2);one, few, many
Scottish Gaelicgdnplurals=4; plural=(n == 1 || n == 11) ? 0 : ((n == 2 || n == 12) ? 1 : ((n > 2 && n < 20) ? 2 : 3));one, two, few, other
Serbian (Cyrillic)srnplurals=3; plural=(n % 10 == 1 && n % 100 != 11) ? 0 : ((n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14)) ? 1 : 2);one, few, other
Slovaksknplurals=3; plural=(n == 1) ? 0 : ((n >= 2 && n <= 4) ? 1 : 2);one, few, other
Slovenianslnplurals=4; plural=(n % 100 == 1) ? 0 : ((n % 100 == 2) ? 1 : ((n % 100 == 3 || n % 100 == 4) ? 2 : 3));one, two, few, other
Spanishesnplurals=2; plural=(n != 1);one, other
Swedishsvnplurals=2; plural=(n != 1);one, other
Thaithnplurals=1; plural=0;other
Turkishtrnplurals=2; plural=(n != 1);one, other
Ukrainianuknplurals=3; plural=(n % 10 == 1 && n % 100 != 11) ? 0 : ((n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 12 || n % 100 > 14)) ? 1 : 2);one, few, many
Vietnamesevinplurals=1; plural=0;other

What the real run found

Arabic's zero and two forms were refused at first for leaving out %(n)s. A form for a single number may do that, and the Arabic dual says "two" by itself, but our check only knew %d and {count} as the count. It now knows Python's %(n)s and %(count)d as well, which also means a Russian "one" without the number is refused, since Russian "one" is also 21 and 31. The same run had our model read its translations for meaning, and it caught Czech "Unsubscribe" written as "log out".

Where it lives

Polyglot 1.4.0 writes these headers into every .po file it produces and puts each form in its slot. Why a form used for several numbers must show the number is in an earlier note, and the checks themselves are free in translation-checks, which since 1.3.0 also reads a .po file you already have and says when its Plural-Forms puts numbers in one slot that CLDR gives different forms.

Updated: