Skip to content

Locale Generate CLI

apps/web/scripts/locales/generate/index.ts

Use this tool to translate en.json into locale files and keep i18n wiring in sync.

English-identical “fill” re-translation is a separate command: see fill.md (pnpm locales:fill).

Commands

Run from apps/web:

  • pnpm locales:generate
  • pnpm locales:generate -- --review
  • pnpm locales:generate -- --dry-run

Modes

  • full — re-translate all translatable string leaves from English.
  • incremental — translate only missing translatable paths and merge into existing locale file.

Flags

  • --dry-run — no API calls, no file writes.
  • --review — show summary, require confirmation before translation starts.
  • --fill — run fill mode (see fill.md).
  • --lang <code> / --lang=<code> — target locale slug (especially useful with --fill via locales:fill).
  • --all — with fill, run for every non-en locale (see fill.md).

What the CLI updates

  • locales/<code>.json — each translated leaf is written as a structured object (value, status, confidence, needsReview, source, updatedAt) on non-English files. See locale-leaves.md.
  • src/i18n/config.ts (SUPPORTED_LANGUAGES row)
  • src/i18n/index.ts (localeLoaders entry for lazy-loaded locale JSON)

Fill-only updates are documented in fill.md.

Preserve behavior

Two preserve policies exist and are intentionally separate:

  • scripts/locales/shared/preserve.ts:
    • COPY_EN_VERBATIM_KEYS — copy-as-is from en while generating
    • EXCLUDE_EN_COMPARE_* — exclusions for EN-value parity checks (sync/fill)

Notes

  • SUPPORTED_LANGUAGES[].code must match localeLoaders keys (camelCase identifier), while locale filename and Google tl stay slug-style.
  • If translations repeatedly equal English (10 in a row), CLI pauses and asks to continue/abort.