LangSync

langsync translate

Fill empty values in non-reference locales using an AI provider.

langsync translate fills empty (or missing) values in every non-reference locale by translating the reference value with an AI provider. Existing translations are never overwritten; the target always wins.

With namespaces configured, translation runs independently per namespace file.

Usage

langsync translate [--provider <provider>] [--model <model>] [--max-keys <n>] [--dry-run]

Flags

FlagDefaultDescription
--provider <name>config / openaiOverride the configured AI provider.
--model <model>config / defaultOverride the configured provider model.
--max-keys <n>unlimitedCap how many empty values a run translates.
--dry-runfalseReport what would be translated, no writes.

Providers

ProviderStatusAPI key env var
openaiReleasedOPENAI_API_KEY
deeplReleasedDEEPL_API_KEY
anthropicExperimental (flag)ANTHROPIC_API_KEY
geminiExperimental (flag)GEMINI_API_KEY

Experimental providers are implemented and tested but gated behind LANGSYNC_AI_EXPERIMENTAL=1 until each graduates to released.

Configuration

export default defineConfig({
  // ...
  ai: {
    provider: 'openai',
    model: 'gpt-5-mini',
    // apiKey: process.env.OPENAI_API_KEY (read automatically when omitted)
  },
});

Behavior

  • Only keys empty or missing in a target and non-empty in the reference are sent to the provider.
  • Each translation request preserves placeholders and ICU syntax.
  • On any provider or transport error the command exits with code 1.
  • The reference locale file is never modified.
  • Missing namespace files in target locales are synthesized as empty trees and created only when translations are written.
  • Extra target-only namespace files are left untouched.
  • If no namespace files are discovered while namespaces is configured, the command fails with an actionable error.
  • Namespaced files are translated independently, so written output paths reflect your namespace layout (for example src/i18n/de/common.json).

On this page