-
Notifications
You must be signed in to change notification settings - Fork 3
i18n
🌐 Language: English | 中文
Supports four UI languages, live-switchable (no restart).
| Code | Name |
|---|---|
en |
English |
zh-CN |
简体中文 (Simplified Chinese, default) |
zh-TW |
繁體中文 (Traditional Chinese) |
ja |
日本語 (Japanese) |
Main window ⚙ → Interface → Language dropdown. Change → saveSettings({ lang }) → entire app re-renders.
src/shared/i18n.ts — a flat key → string map across four languages:
const STRINGS = {
'sidebar.newSession': { en: 'New', 'zh-CN': '新建', 'zh-TW': '新建', ja: '新規' },
'head.cwdPh': { en: 'Working directory', 'zh-CN': '工作目录', ... },
// ...
};Each key maps to an object with four language fields.
export function t(lang: Lang, key: string, params?: Record<string, string | number>): string;- Looks up STRINGS[key][lang]; falls back to en, then to the key itself
- params replace placeholders:
t('en', 'al.httpErr', { code: 500, detail: 'timeout' })→HTTP 500 error — timeout - Placeholder syntax:
{code}{detail}
UI strings bind in two ways:
-
Explicit JS call:
el.textContent = t(lang, 'sidebar.newSession') -
HTML declarative (more common):
<button data-i18n="sidebar.newSession">New</button>, thenapplyI18nDOMsweeps[data-i18n]/[data-i18n-placeholder]/[data-i18n-title]and fills them
applyI18nDOM (src/renderer/files-pane.ts:53 is one example) re-sweeps on language switch.
Strings shown to the model stay in their original language:
- baseSystemPrompt (always Chinese, even if UI is English)
- engine error messages (Chinese, since they're part of the model prompt)
- AGENTS.md / CLAUDE.md / KINET.md / KINET-CONTEXT.md (user-authored)
- Long-term memory contents (model-extracted)
- Tool results (shell output, file contents, etc.)
Reasoning: these are prompt contents for the LLM. Translating them to English would degrade performance on Chinese tasks for models like GLM/Claude (when the user writes Chinese tasks, the system prompt should also be Chinese to match).
GLM Zhipu (the default provider) is a Chinese-leaning model, and the primary user base is Chinese-speaking. baseSystemPrompt is also Chinese.
- Add
'xx'to theLangunion insrc/shared/i18n.ts - Add
'xx'translations to each STRINGS entry - Add
<option value="xx">to the language dropdown insrc/renderer/index.html(or the relevant view) - typecheck → ship
No other changes needed when only adding keys (not languages).
- Add the new key + four-language translations to
STRINGS - Use it via
data-i18n="new.key"or callt(lang, 'new.key')in JS - Ship
-
src/shared/i18n.ts— STRINGS +t() -
src/shared/types.ts:46—AppSettings.lang: Lang -
src/renderer/app.ts— top-levelapplyI18nDOM()+ re-sweep on language switch -
src/renderer/files-pane.ts:53— files window'sapplyI18nDOM(standalone window needs its own call)