MusePi

MusePi i18n Architecture

English 中文

Living document (established 2026-08-16) — covers the two independent i18n systems in this repo: the renderer side (desktop-web, GUI/tray/collab Web) and the TUI (coding-agent). The vocabulary was split into per-domain modules on 2026-08-16, with compile-level parity on the en side and a plugin registration seam. The implementation is authoritative.

The Two Systems

  desktop-web (packages/desktop-web/src/i18n) coding-agent (packages/coding-agent/src/i18n)
Consumers GUI main window/tray/bubble, collab Web UI TUI, daemon (reuses the same module)
Placeholders Named parameters {count} (validated via template literal type extraction) Positional parameters {0} (legacy convention, not migrated)
Key typing Strict TranslationKey = keyof typeof zhCN (typos/missing params are compile errors) Loose (key: string, English source text is the key)
en mapping Yes (en-US/ domain files, compile-level parity) None (English passthrough)
Vocabulary 12 domains (zh-CN/ + en-US/) 13 domains (zh-CN/)
Plugin seam registerTranslations(locale, map) + tLoose(key, params) registerTranslations(locale, map)

Shared conventions: the key is the English source text, and t() falls back to the key itself on a miss; t() runs only at render/call time, never at module load.

Vocabulary Split (desktop-web)

Plugin Seam

Maintenance Guide

  1. Editing copy: find the domain file matching the feature area (settings is largest at 2137 keys, then tools/pet); do not merge back into a single file.
  2. Adding a key: after adding it to a zh domain, the en domain must be updated in sync (otherwise a compile error); keep keys in English source-text style; use named parameters like {name}, not {0}.
  3. No duplicate keys across domains: duplicates throw when the barrel loads (the error names both domains).
  4. GUI dynamic keys (schema-driven labels, runtime error strings, tag.${…} concatenation): use explicit as TranslationKey; plugin/extension copy goes through registerTranslations + tLoose.
  5. TUI: leave {0} positional parameters untouched; when adding a new domain module, update the import/spread/guard parts of zh-CN/index.ts accordingly.