Skip to content

Shared Locale CLI Utilities

Shared utilities live in apps/web/scripts/locales/shared/.

Files

  • ansi.ts — common CLI colors/styles
  • banner.ts — reusable boxed locale banner printer
  • code.ts — locale code normalize/validate/list helpers
  • localeLeaf.ts — structured non-English leaf types (value, status, confidence, needsReview, source, updatedAt), sync merge helpers, and locale tree walking for parity/review/cleanup
  • reference.ts — central English source locale guard (en) for all locale CLIs
  • prompts.ts — shared prompt helpers (isExitPromptError, hint printer)
  • preserve.ts — EN-value comparison exclusions for sync parity + fill mode + generate copy-as-is preserve rules

Why split preserve policy

Two preserve concerns are different but are implemented in one file:

  • Copy preserve (COPY_EN_VERBATIM_KEYS): what generation keeps exactly from English.
  • Compare preserve (EXCLUDE_EN_COMPARE_*): what parity/fill ignores during EN-identical comparison.

This avoids coupling translation behavior with parity diagnostics.

English safety guard

shared/reference.ts centralizes the English source locale guard:

  • the reference locale slug/file (en, en.json)
  • guard helpers to prevent accidental deletion/cleanup of English

Delete/Cleanup CLIs use this guard so en.json is always protected.