feat(tui): internationalize welcome, status/usage panels, dialogs and slash commands#869
feat(tui): internationalize welcome, status/usage panels, dialogs and slash commands#869meymchen wants to merge 10 commits into
Conversation
Introduce a zero-dependency I18n singleton (lookup, en fallback, param interpolation, runtime setLocale) modeled on the theme singleton, with per-module language packs under locales/en and locales/zh-CN. Add a language setting to tui.toml (auto | en | zh-CN), resolve auto from the system locale at startup, and migrate the footer status labels to translated strings.
Build the interactive language-switching path on top of the i18n skeleton (#1). A LanguageSelectorComponent (ChoicePicker subclass) offers Auto / English / 简体中文; /settings routes a new "Language" entry to it. Selecting a language persists to tui.toml, updates app state, flips the live i18n locale, and repaints so the UI switches language immediately without a restart. /reload re-reads the language and re-applies it via setAppState + i18n.setLocale alongside theme. Closes #2 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrate the user-visible English strings in the reverse-RPC approval and
question panels to the i18n layer, with en + zh-CN translations under a new
`reverseRpc` namespace.
- Approval panel headers, choice buttons, danger labels, cwd/scope/more-lines
metadata, and key hints now resolve via `i18n.t('reverseRpc.approval.*')`.
- Choice/danger labels are localized in the approval adapter at adapt time;
`selected_label` stays a stable English identifier for the upstream contract.
- Question dialog heading, review/submit prompts, Other/Not-answered labels,
submit actions, and hints resolve via `i18n.t('reverseRpc.question.*')`.
- Approval preview title and footer hints resolve via
`i18n.t('reverseRpc.preview.*')`.
- Strings stay colored via `currentTheme`; no chalk named colors, and no
coloring / printableChar() / keyboard behavior changes.
Locale-render tests assert the panels render in Simplified Chinese under
`zh-CN` and English under `en`.
Resolves #3.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrate builtin slash-command descriptions, the /help panel chrome (title, dismiss hint, greeting, section headers, keyboard-shortcut descriptions, scroll tail), and goal/swarm argument-completion descriptions to the i18n layer, with en + zh-CN translations under a new `commands` namespace. Command names, aliases, and subcommand values stay untranslated — only human-readable descriptions follow the active locale. Skill command descriptions remain owned by the skill; only framework builtins are localized via `localizedBuiltinSlashCommands()`. Closes #4 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…keleton # Conflicts: # apps/kimi-code/package.json
Migrate the `/usage` and `/status` panel labels to the i18n layer with
`en` + `zh-CN` translations, extending the `components` namespace with
`usage` and `status`.
- usage-panel: session/context/plan section labels, input/output/total
words, "% used", and empty-state strings now come from
`i18n.t('components.usage.*')`.
- status-panel: field labels (Model, Directory, Permissions, Plan mode,
Session, Title, Warning) and rendered values (on/off, not set, none,
thinking) come from `i18n.t('components.status.*')`.
- Panel chrome titles (' Usage ' / ' Status ') are localized; model names
and permission-mode identifiers stay untranslated.
- Add a `padEndToWidth` helper so the aligned label columns pad by display
width, keeping the panels aligned under double-width Chinese characters.
Locale-render assertions verify both panels render Chinese under `zh-CN`
and English under `en`, plus alignment/width under `zh-CN`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Migrate the welcome panel to the i18n layer (title, login/help hints, unset-model notice, and the Directory/Session/Model/Version/MCP info labels), padding the label column by display width so it stays aligned under double-width Chinese. Introduce a `common` namespace for short phrases shared across components: the generic Submit/Cancel/Back controls plus the navigate/select/cancel/clear-search key hints. Migrate the list-style dialogs (model, choice, session, undo, experiments selectors) and the plugin-remove Cancel button to `common.*` so each shared phrase is translated once, with en + zh-CN translations. Resolve #6 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Render the `tui.toml` parse-failure notice (INVALID_TUI_CONFIG_MESSAGE) in the active locale. Config load runs before the language is known, so run-shell now records only that parsing failed and translates the notice after `i18n.setLocale(...)` resolves the locale — deferred init that falls back to the default `en` pack before config load. The `TuiConfigParseError.message` stays English so logs and issue triage remain English; only the user-facing startup notice is localized. Adds a `cli` i18n namespace (`cli.config.invalidTuiConfig`) for en and zh-CN. Closes #7. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…date thinking label
🦋 Changeset detectedLatest commit: fc281a7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc281a7042
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| private readonly title: string = i18n.t('components.usage.panelTitle'), | ||
| ) { | ||
| this.lines = buildLines(); |
There was a problem hiding this comment.
Rebuild cached usage panels on locale changes
When a user has an existing /usage or /status panel in the transcript and then switches language via /settings (or reloads tui.toml), this component keeps both the localized title and the prebuilt lines from construction time. The language-switch paths only request a render, so these visible panels continue showing the old locale; even a later invalidate can rebuild the body but not this stored title. Consider deriving the title/body from builders on render/invalidate or invalidating and recreating these panels when the locale changes.
Useful? React with 👍 / 👎.
Related Issue
Resolve #868
Problem
Kimi Code TUI already supports language switching via
/language, but a large portion of user-facing text (welcome screen, status/usage panels, shared dialogs, slash command descriptions, and the/helppanel) is still hard-coded in English. This breaks the experience for zh-CN users and leaves no clear pattern for adding more languages later.What changed
This PR lands a walking skeleton for TUI internationalization:
cli: CLI-facing notices rendered before the TUI mounts.common: shared dialog vocabulary and keyboard hints.components: expanded keys forwelcome,usage,status, and shared dialog labels.choice-picker,model-selector,session-picker,undo-selector, etc.)/helppaneltui.tomlconfig-parse notice through i18n.The approach keeps each locale file a flat
MessageTreeand groups keys by UI area, which matches the existingcommandsandreverse-rpcnamespaces. This should make it straightforward to add more languages or migrate additional components incrementally.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.