PO (Gettext)

Use-case guide: See Automate Lingui translations → for PO catalog workflows with Lingui.

Babely supports PO files, the widely-used Gettext localization format. This format is popular in many programming environments, particularly in Linux applications and PHP frameworks, offering support for context, plurals, and translator comments.


Setting Up

First, make sure you've got a babely.json config file in your project root. Here's an example:

typescript
{
  "locale": {
    "source": "en",
    "targets": ["sv", "de", "fr"]
  },
  "files": {
    "po": {
      "include": ["locales/[locale]/LC_MESSAGES/messages.po"]
    }
  }
}

Translating

With your config set, run:

typescript
npx @babely/cli@latest translate

When you run this command, Babely will:

  • Load your source PO file (e.g., locales/en/LC_MESSAGES/messages.po)
  • Detect any new or modified translation strings
  • Generate translations for your target languages
  • Create or update the target language PO files (e.g., locales/sv/LC_MESSAGES/messages.po)
  • Preserve metadata, contexts, and plural forms
  • Maintain translator comments and reference information