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:generatepnpm locales:generate -- --reviewpnpm 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--fillvialocales:fill).--all— with fill, run for every non-enlocale (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_LANGUAGESrow)src/i18n/index.ts(localeLoadersentry 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 fromenwhile generatingEXCLUDE_EN_COMPARE_*— exclusions for EN-value parity checks (sync/fill)
Notes
SUPPORTED_LANGUAGES[].codemust matchlocaleLoaderskeys (camelCase identifier), while locale filename and Googletlstay slug-style.- If translations repeatedly equal English (10 in a row), CLI pauses and asks to continue/abort.
Related
- fill.md — fill / English-identical re-translation
- i18n overview
- sync.md
- validate.md
- shared.md