Skip to content

Locale Sync CLI

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

Synchronizes non-English locale files to en.json key shape. Parity / English-identical reporting is a separate read-only command: pnpm locales:validate:quality (see validate.md).

Commands

From apps/web:

  • pnpm locales:sync
  • tsx scripts/locales/sync/index.ts
  • pnpm locales:sync -- --yes — non-interactive (also when CI is set): skip confirm when dropping extra keys

Behavior

  • Rebuilds each non-en locale with the same key tree as en.json.
  • Keeps existing locale translations (value) where path/type still match.
  • Structured leaves: non-English files use objects per key (see locale-leaves.md). Sync merges missing meta fields (status, confidence, needsReview, source, updatedAt) when it finds plain strings or partial objects, without changing the translated text.
  • Fills missing/wrong-shape paths with English copy + default meta (copy-en / pending).
  • Drops stale extra keys that are no longer in en.
  • Writes a file only when merged content differs from the existing JSON (deep compare). The summary lists which files were updated, including paths that only received metadata patches.

Preserve comparison exclusions

English-identical detection (for locales:validate:quality / fill) uses exclusions from:

  • scripts/locales/shared/preserve.ts