gettext
A widely-used GNU internationalization system using PO/POT file format.
Definition
gettext is the GNU internationalization and localization system, originally developed for Unix/Linux. It uses PO (Portable Object) files for translations and POT (PO Template) files for source strings. gettext is widely used in open-source projects, PHP (WordPress), Python (Django), Ruby, and many other ecosystems. The format supports pluralization, context, and translator comments.
Examples
- →POT file: msgid "Hello" with empty msgstr
- →PO file: msgid "Hello" msgstr "Hola"
- →Plural: msgid_plural for plural forms
- →Context: msgctxt for disambiguation
Frequently Asked Questions
When should I use gettext vs JSON?
Use gettext for: PHP/WordPress, Python/Django, open-source projects, when translators prefer PO editors. Use JSON for: JavaScript frameworks (React, Vue, Next.js), modern web apps, API-driven projects. Most TMS support converting between formats.
How does gettext handle plurals?
gettext uses nplurals header to define plural count and plural expression. Example: nplurals=2; plural=(n!=1); for English. Each PO entry can have msgid_plural and multiple msgstr[N] for each form. Supports all CLDR plural rules.