4.9 KiB
Localization maintenance
The web client loads one of 17 catalogs on demand. English source text is the message key; the presentation translator never changes game state, player input, or protected player names.
Run from web-client:
npm run localization:check # read-only current-source inventory / English drift
npm run test:locales # language/key/placeholder parity + extractor tests + drift
node --experimental-strip-types --test src/localization.test.ts
npm run build && node scripts/localization-smoke.mjs # production French + retry/mobile regression
localization:check exits nonzero and prints source locations for new messages
missing from src/localization/en.json. It does not rewrite any catalog (even if
output flags are supplied). Unlike comparing catalog sizes, it scans the current
Svelte/TypeScript UI, protocol tutorial DOM, and Rust engine sources. Technical
attributes/identifiers, comments, diagnostics and test files are filtered out.
Historical keys remain compatible; their presence is not evidence that a current
rule is covered.
For review, extraction can write candidates and locations outside the catalogs:
npm run localization:extract -- --source-output=/tmp/clash-en.json --locations=/tmp/clash-locations.json
Rust escaped line continuations are decoded according to Rust whitespace rules;
raw strings, Unicode/hex escapes, comments and character literals are handled too.
Format arguments become {p0}, {p1}, etc. Translators must preserve the complete
placeholder multiset, but may reorder arguments to suit their language.
Dynamic captions
Do not concatenate optional English suffixes immediately after a parameter, such
as Build {p0}{p1}. The rendered text cannot reveal where one argument ends and the
next begins. Such ambiguous patterns are deliberately not matched by the runtime
or required by the source inventory. Use complete alternatives, for example
Build {p0} and Build {p0} at {p1}, and translate both. The same applies to free
research, fortress city size, army passengers and recruitment variants.
Exact complete messages take precedence over patterns. Multi-part · tooltips
are translated segment by segment when no complete specific caption matches,
rather than letting a broad capture swallow the entire tooltip. Nested captures
are bounded, and only top-level results are cached to avoid caching a translation
that stopped at the recursion limit. Generic connector templates reject long or
sentence-like unknown captures instead of disguising missing prose with isolated
translated words. This is a conservative guard, not semantic language detection.
For authored keys, translator.getMissingKeys(keys) provides an opt-in exact-key
check without collecting or logging player names or runtime game text.
Panel close controls use data-panel-close; never use translated accessible labels
as behavioral or layout selectors. Failed catalog downloads display an English
fallback notice and a retry button bearing the requested language's native name.
Scope and review
The source inventory is a practical drift guard, not proof that every runtime branch or every sentence is translated. It cannot infer arbitrary string concatenation, pluralization or all text generated by third-party code. New rules, logs, tooltips and dynamic UI variants still need review in rendered context. Untranslatable identifiers and diagnostic strings should not be added merely to make totals agree. Existing technical/historical catalog entries are retained for compatibility, not advertised as user-facing coverage.
Regression tests use shipped catalogs in all supported languages, current continued engine rules (Spy, Mercenaries, wonder leader abilities), complete optional captions and composed strategy tooltips. They supplement, rather than replace, native-language review of wording and gameplay terminology.
Printed action terminology
Action controls use Advance and Construct, while the browsing tree is
Advances. The purchase template is Advance · {p0} so it reads as an action
label followed by an advance name, not an awkward verb phrase. Existing Use,
Choose, and Queue choice controls keep their distinct meanings. The
catalogs reuse their existing action/browsing translations and preserve old keys
for recorded text; ordinary rules prose (such as research costs) is unchanged.
New public board-history titles use Advance / Construct / Construct wonder.
Playback still recognizes Research / Build / Build wonder in old recordings and
normalizes their displayed captions without rewriting saved frames or engine
action identifiers. Journal Advance and legacy Research origins group the same
advance rewards. Focused coverage lives in journal.test.ts, playback.test.ts,
platform_log_tests.rs, and the board-history terminology unit test. The
research-card smoke checks desktop/mobile action labels, tooltips and overflow.