gettext plural‑forms table for 209 languages and a browser‑based validator released

Illustrative photo: A new tool offers gettext plural rules for 209 languages.

A developer‑focused tool that combines a complete gettext Plural‑Forms table for 209 languages with a client‑side checker has been published, letting teams verify that each language’s plural rule matches the Unicode CLDR data before any translation is shipped.

CLDR‑based headers for every language

The table was generated from CLDR 47 using Babel 2.18.0. For each language that defines its own plural rules, a Plural‑Forms header was crafted so that every whole number maps to the correct CLDR category. The authors evaluated each header against 22,017 distinct counts – every integer up to 20,000, every thousand up to two million and round numbers up to a billion – and kept only those expressions that placed each count in the right slot. This work covers languages such as Russian, French, Portuguese (European), Welsh and Latvian, highlighting where historic headers diverge from the current CLDR definitions.

A notable edge case is European Portuguese, where the CLDR rule treats the numeral 0 as a separate form; the generated header reflects this nuance, unlike the generic two‑form header used elsewhere for Portuguese.

Browser‑based checker for existing .po files

The accompanying web tool lets developers paste a Plural‑Forms line (or the full .po header) and instantly see which numbers each msgstr index would receive. The parser analyses the C‑style expression without invoking eval, ensuring that no code leaves the browser. It flags headers that mix CLDR categories in a single slot, leave a slot unused, or assign a slot to numbers that require the count to be displayed (e.g., Russian 21, French 0).

Because the checker runs entirely client‑side, it can be used on any machine without installing additional software, making it suitable for quick sanity checks during localisation reviews or as part of a continuous‑integration pipeline.

Integration into translation workflows

Beyond individual header validation, the project ships an MIT‑licensed Python script named translation‑checks. The script scans an entire .po catalogue, applies the CLDR‑derived header to each plural entry, and verifies placeholder consistency, number tags and that each msgstr is used for the intended set of numbers. It can also be installed as a pre‑commit hook, automatically rejecting commits that contain mismatched plural rules. The authors note that their own localisation pipeline for 42 languages already runs this check before any catalogue is merged.

Why accurate plural rules matter for developers

Incorrect Plural‑Forms headers silently produce wrong word forms, a problem that often goes unnoticed because gettext does not raise an error when the expression yields an unexpected index. For languages with three or more forms, such as Russian or Polish, a single misplaced header can make dozens of strings display the wrong grammatical number, leading to poor user experience and potentially breaking legal or audit‑related copy. By aligning gettext headers with CLDR – the industry‑standard repository of language pluralisation data – the new table eliminates this class of bugs at the source. The browser checker adds a low‑friction safety net, enabling developers to spot mismatches during code review rather than after a release. Moreover, the integration hooks let teams embed the validation step into CI pipelines, turning a previously manual quality‑control task into an automated gate. For open‑source projects that rely on community‑generated .po files, the resource provides a single authoritative reference, reducing the churn caused by divergent custom headers and making it easier for contributors to generate correct translations without deep linguistic expertise.

Cover: Christina Morillo · CC0 · StockSnap. Layout and headline text by Signal Titans.

Source: gettext Plural-Forms for 209 languages, checked against CLDR 47, and a checker for yours · Plural-Forms for every language: gettext headers checked against CLDR 47

Share this article
FacebookThreadsLinkedInX

Leave a Reply

Your email address will not be published. Required fields are marked *