Skip to content
phinn edited this page Jul 12, 2026 · 2 revisions

🌐 Language: English | 中文

i18n (multiple languages)

Supports four UI languages, live-switchable (no restart).

Supported

Code Name
en English
zh-CN 简体中文 (Simplified Chinese, default)
zh-TW 繁體中文 (Traditional Chinese)
ja 日本語 (Japanese)

Switching

Main window ⚙ → Interface → Language dropdown. Change → saveSettings({ lang }) → entire app re-renders.

How it works

String table

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.

t(lang, key, params?)

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}

Rendering

UI strings bind in two ways:

  1. Explicit JS call: el.textContent = t(lang, 'sidebar.newSession')
  2. HTML declarative (more common): <button data-i18n="sidebar.newSession">New</button>, then applyI18nDOM sweeps [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.

What's NOT translated

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).

Why zh-CN is the default

GLM Zhipu (the default provider) is a Chinese-leaning model, and the primary user base is Chinese-speaking. baseSystemPrompt is also Chinese.

Adding a new language

  1. Add 'xx' to the Lang union in src/shared/i18n.ts
  2. Add 'xx' translations to each STRINGS entry
  3. Add <option value="xx"> to the language dropdown in src/renderer/index.html (or the relevant view)
  4. typecheck → ship

No other changes needed when only adding keys (not languages).

Adding a new key

  1. Add the new key + four-language translations to STRINGS
  2. Use it via data-i18n="new.key" or call t(lang, 'new.key') in JS
  3. Ship

Key source files

  • src/shared/i18n.ts — STRINGS + t()
  • src/shared/types.ts:46 — AppSettings.lang: Lang
  • src/renderer/app.ts — top-level applyI18nDOM() + re-sweep on language switch
  • src/renderer/files-pane.ts:53 — files window's applyI18nDOM (standalone window needs its own call)

Clone this wiki locally