Translate GNU Gettext (.po) Files for C, PHP, Python & More
Simplify localization for applications using gettext-based internationalization with Lingo.dev's native support for .po files - perfect for C, C++, PHP, Python, Java and other languages that use the GNU Gettext standard.
Quick Setup
Create an i18n.json
configuration file in your project root:
{
"version": 1,
"locale": {
"source": "en",
"targets": ["es", "fr", "de"]
},
"buckets": {
"po": {
"include": ["locales/[locale]/LC_MESSAGES/messages.po"]
}
}
}
This configuration:
- Sets English as your source language
- Targets Spanish, French, and German translations
- Works with the standard gettext directory structure
Find Supported Languages
Discover all available language options:
# View source language options
npx lingo.dev@latest show locale sources
# View target language options
npx lingo.dev@latest show locale targets
One Command Translation
Translate all your .po files with a single command:
npx lingo.dev@latest i18n
This automatically:
- Reads your source .po files
- Identifies new or modified strings
- Translates only what's changed
- Creates or updates target language files in their respective directories
Smart Gettext Features
Context Preservation
Lingo.dev maintains message contexts for accurate translations:
# Original English with context
msgctxt "Menu"
msgid "Open"
msgstr ""
msgctxt "File"
msgid "Open"
msgstr ""
# After translation to Spanish
msgctxt "Menu"
msgid "Open"
msgstr "Abrir"
msgctxt "File"
msgid "Open"
msgstr "Abrir archivo"
Pluralization Support
Handles all plural forms correctly across languages:
# English source with plural forms
msgid "Found %d item"
msgid_plural "Found %d items"
msgstr[0] ""
msgstr[1] ""
# After translation to Spanish
msgid "Found %d item"
msgid_plural "Found %d items"
msgstr[0] "Encontrado %d elemento"
msgstr[1] "Encontrados %d elementos"
Format String Protection
Preserves format specifiers like %d
, %s
, and named parameters across translations.
Advanced Configuration Options
Exclude Specific Files
Keep certain files untranslated:
"po": {
"include": ["locales/*/LC_MESSAGES/*.po"],
"exclude": ["locales/*/LC_MESSAGES/admin.po"]
}
Multi-Format Projects
Combine .po files with other localization formats:
"buckets": {
"po": {
"include": ["locales/*/LC_MESSAGES/*.po"]
},
"markdown": {
"include": ["docs/[locale]/*.md"]
}
}
Why Developers Choose Gettext Translation
- Standard Compatibility: Works with the established GNU Gettext ecosystem
- Context Awareness: Preserves message contexts for disambiguation
- Plural Support: Handles complex pluralization rules across languages
- Incremental Updates: Only translates what's changed, saving time and resources
- Toolchain Integration: Fits seamlessly with existing gettext workflows
Seamless Workflow Integration
Lingo.dev integrates perfectly with standard gettext tools:
- Extract strings with
xgettext
or your framework's extraction tools - Translate with Lingo.dev
- Compile .po files to .mo files with
msgfmt
as usual
By integrating Lingo.dev into your development workflow, you get powerful AI-driven translations while maintaining compatibility with the GNU Gettext standard that powers thousands of applications worldwide.