lingui-translate
v0.1.8
Published
CLI for translating missing Lingui PO entries with an LLM.
Maintainers
Readme
lingui-translate
lingui-translate is a small CLI that fills missing Lingui messages.po translations with an LLM.
Missing translations are easy to leave behind, especially when strings change often or several locales need to stay in sync. This package scans your Lingui locale folders, finds untranslated entries, and writes translations back into the existing messages.po files. The result is a faster localization workflow with less repetitive copy/paste and more consistent wording across a locale.
Quick start
Install it:
npm install --save-dev lingui-translateSet an API key:
export OPENAI_API_KEY=your_api_key_hereRun it on your locales:
npx lingui-translate --locales-dir src/locales --languages de esThat is enough to get started. If your project uses the default src/locales layout, you can also keep the command very small by moving options into a config file.
Usage
Translate specific languages:
lingui-translate --locales-dir src/locales --languages de esPreview changes without writing files:
lingui-translate --locales-dir src/locales --languages de es --dry-runUse a custom model and prompt:
lingui-translate \
--locales-dir src/locales \
--languages de es \
--model gpt-5.4 \
--system-prompt "You are a concise product localization translator."Use a different provider:
lingui-translate \
--provider anthropic \
--model claude-3-5-sonnet-latest \
--locales-dir src/locales \
--languages deConfig
The CLI can auto-load:
lingui-translate.config.jsonlingui-translate.config.jslingui-translate.config.mjslingui-translate.config.cjs
Example:
export default {
localesDir: "src/locales",
languages: ["de", "es"],
workers: 4,
provider: "openai",
model: "gpt-5.4",
systemPrompt:
"You are a professional translator specializing in software localization.",
};Then you can run:
npx lingui-translateCLI flags override config file values.
Defaults
If you do not provide config, flags, or environment variables, lingui-translate uses:
localesDir:src/localesdryRun:falseworkers:4provider:openaimodel: depends onprovideropenai:gpt-5.4anthropic:claude-sonnet-4-6google:gemini-2.5-flash
systemPrompt:You are a professional translator specializing in software localization. Pay careful attention to the provided examples to maintain consistency in style and terminology.
There is no default API key or base URL. The API key must be provided through a provider-specific env var, LINGUI_TRANSLATE_API_KEY, or --api-key.
Environment
LINGUI_TRANSLATE_PROVIDERLINGUI_TRANSLATE_API_KEYLINGUI_TRANSLATE_BASE_URLOPENAI_API_KEYOPENAI_BASE_URLANTHROPIC_API_KEYANTHROPIC_BASE_URLGOOGLE_GENERATIVE_AI_API_KEYGOOGLE_GENERATIVE_AI_BASE_URLLINGUI_TRANSLATE_LOCALES_DIRLINGUI_TRANSLATE_LANGUAGESas a comma-separated listLINGUI_TRANSLATE_WORKERSLINGUI_TRANSLATE_MODELLINGUI_TRANSLATE_SYSTEM_PROMPT
Exit codes
0: success, whether or not translations were written1: any CLI or translation error
