Skip to content

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:

json
{
  "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:

bash
# 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:

bash
npx lingo.dev@latest i18n

This automatically:

  1. Reads your source .po files
  2. Identifies new or modified strings
  3. Translates only what's changed
  4. Creates or updates target language files in their respective directories

Smart Gettext Features

Context Preservation

Lingo.dev maintains message contexts for accurate translations:

po
# 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:

po
# 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:

json
"po": {
  "include": ["locales/*/LC_MESSAGES/*.po"],
  "exclude": ["locales/*/LC_MESSAGES/admin.po"]
}

Multi-Format Projects

Combine .po files with other localization formats:

json
"buckets": {
  "po": {
    "include": ["locales/*/LC_MESSAGES/*.po"]
  },
  "markdown": {
    "include": ["docs/[locale]/*.md"]
  }
}

Why Developers Choose Gettext Translation

  1. Standard Compatibility: Works with the established GNU Gettext ecosystem
  2. Context Awareness: Preserves message contexts for disambiguation
  3. Plural Support: Handles complex pluralization rules across languages
  4. Incremental Updates: Only translates what's changed, saving time and resources
  5. Toolchain Integration: Fits seamlessly with existing gettext workflows

Seamless Workflow Integration

Lingo.dev integrates perfectly with standard gettext tools:

  1. Extract strings with xgettext or your framework's extraction tools
  2. Translate with Lingo.dev
  3. 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.