Add lightweight i18n foundation; route new strings through catalogs

- Backend src/i18n.rs: embedded locales/<lang>.json, t(key,params) with {placeholder} interpolation, process-wide language from config.language (default it), English-then-key fallback. Applied to the identity reminder and name-lock/empty errors.

- Frontend: web/assets/locales/<lang>.json + t()/loadI18n()/applyI18n() (data-i18n attributes); language follows the browser; async bootstrap. Applied to the settings panel.

- Convention: new user-facing and model-facing strings use the catalog; wire/JSON/identifiers never translated. Existing strings migrate in a later round. it+en catalogs; 115 tests; verified live (catalog error messages) + node --check + HTTP. README documents the convention.
This commit is contained in:
adm committed 2026-11-25 16:05:29 +01:00
1 parent 73b665d1a7
commit 498e3dbc1b
12 files changed
+248 -27

No files matched your search

+16 -1
View File
@@ -193,9 +193,24 @@ optional `startup_timeout_secs` / `silence_timeout_secs`. Everything else (`arch
`mcp_servers`, `cors_origins`, …) is preserved untouched and reported as ignored —
unknown keys never break startup.
### Localization (i18n)
User-facing strings are externalized into embedded per-language catalogs and
looked up by key with `{placeholder}` interpolation:
- **Backend** (`src/i18n.rs`): `locales/<lang>.json`, `t(key, params)`, language
from the `language` config key (default `it`), English fallback then the key.
- **Frontend** (`web/assets/locales/<lang>.json`): `t(key, params)` for dynamic
strings and `data-i18n` attributes for static HTML; language follows the browser.
Convention: new code routes user-facing strings (and model-facing prompts such as
the identity reminder) through the catalog. Wire-protocol fields, JSON keys and
identifiers are **never** translated. Existing hardcoded strings are migrated in a
later adaptation round.
## Status
Working and tested (114 tests, plus 2 real-file tests run on demand). Text, images,
Working and tested (115 tests, plus 2 real-file tests run on demand). Text, images,
the full client-side tool loop, the Anthropic endpoint, the web GUI (session
context, streaming, stats) and **agent mode** (the model using `shell_exec` on the
host) have been validated live against the real Inkling engine.