Skip to content

feat(i18n): add multi-language internationalization support (zh/en)#1561

Open
7723qqq wants to merge 4 commits into
MoonshotAI:mainfrom
7723qqq:i18n-pr
Open

feat(i18n): add multi-language internationalization support (zh/en)#1561
7723qqq wants to merge 4 commits into
MoonshotAI:mainfrom
7723qqq:i18n-pr

Conversation

@7723qqq

@7723qqq 7723qqq commented Jul 12, 2026

Copy link
Copy Markdown

Summary

This PR adds comprehensive multi-language internationalization (i18n) support across the CLI, TUI, and Web UI.

Changes

  • i18n Engine (apps/kimi-code/src/i18n/) — lightweight i18n core with Chinese (zh) and English (en) locales
  • Locale Selector (apps/kimi-code/src/tui/components/dialogs/locale-selector.ts) — runtime language switching dialog via /locale command
  • 130+ files updated — all hardcoded English UI strings replaced with t() calls across:
    • CLI commands and options
    • TUI components (dialogs, messages, panes, controllers)
    • Web UI components (ServerAuthDialog, GoalStrip, CommandBar, Sheet, Dialog)
  • Test coverage (apps/kimi-code/test/i18n/index.test.ts) — i18n engine unit tests
  • Web UI locale updates — synced apps/kimi-web/src/i18n/locales/ for both en and zh

How it works

import { t, setLocale, getLocale } from '#/i18n';

setLocale('zh');
console.log(t('common.ok')); // "确定"
setLocale('en');  
console.log(t('common.ok')); // "OK"

Locale detection: locale config option → KIMI_LOCALE env var → zh (default).

Screenshots

(TBD — locale selector dialog, Chinese TUI, Chinese Web UI)

Checklist

  • Tests pass locally
  • No breaking changes to existing APIs
  • English locale keys match original hardcoded strings exactly
  • All existing tests pass with default locale set to zh

- Add i18n engine with Chinese (zh) and English (en) locales
- Add locale selector dialog for runtime language switching (/locale command)
- Replace all hardcoded English strings with t() calls across CLI, TUI, and Web UI
- Add comprehensive i18n test coverage
- Add changeset for i18n-coverage
@changeset-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5a83265

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a69993056

ℹ️ 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".

Comment thread apps/kimi-code/src/cli/run-prompt.ts Outdated
Comment on lines +505 to +507
outputWriter.writeStatus(
`Retrying (${event.nextAttempt}/${event.maxAttempts}) in ${Math.ceil(event.delayMs / 1000)}s — ${event.errorName}`,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve retry metadata for stream-json

When a retry occurs under kimi -p --output-format=stream-json, this now calls the generic status writer, so the JSONL output becomes {"role":"meta","type":"status","content":"Retrying ..."} and drops failed_attempt, delay_ms, error_message, and status_code. The stream-json contract/tests already expose retries as type: "turn.step.retrying" with structured fields, so consumers can no longer distinguish or handle provider retries; keep the structured JSON path and only localize the text writer.

Useful? React with 👍 / 👎.

return new Promise((resolve) => {
const picker = new ChoicePickerComponent({
title: 'Select a provider to log out',
title: t('tui.statusMessages.selectProviderToLogout'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add missing translations for prompt/provider keys

This and the other new tui.statusMessages.* keys in prompts.ts/provider.ts (for feedback attachment choices, API-key subtitle, catalog/provider add/remove statuses, etc.) are not present in either apps/kimi-code/src/i18n/locales/en.ts or zh.ts; because t() falls back to the key, opening these flows shows strings like tui.statusMessages.selectProviderToLogout instead of user text. Add the missing locale entries or point these calls at existing keys.

Useful? React with 👍 / 👎.

Comment on lines +76 to +80
v-if="goal.status !== 'paused'"
size="sm"
variant="secondary"
class="goal-action"
@click.stop="emit('controlGoal', 'pause')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resume blocked goals from the strip

In the blocked-goal state, this condition renders the Pause action and hides Resume, but the rest of the web UI treats blocked goals as resumable (goalCanResume is true for paused || blocked in Composer). Users who expand the goal strip after a goal blocks can only send goalControl: 'pause', which does not unblock or resume it; render Resume for blocked and Pause only for active.

Useful? React with 👍 / 👎.

Comment on lines +17 to +19
goalTurns: '{{count}} turns',
goalTokens: '{{count}} tokens',
goalTokenBudget: '{{pct}}% token budget',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use vue-i18n placeholder syntax

Vue-i18n in the web app uses single-brace named interpolation ({count}), and GoalStrip passes { count }/{ pct } to these keys. With {{count}}/{{pct}}, the message compiler will not substitute the values, so expanded goal stats render literal placeholders instead of numbers; change these new web locale strings (and the zh mirrors) to {count} and {pct}.

Useful? React with 👍 / 👎.

kimi and others added 3 commits July 12, 2026 08:17
…issing locale keys, fix GoalStrip blocked state, fix vue-i18n placeholder syntax

- Restore writeRetrying with structured JSON meta for stream-json consumers; t() only for text output
- Add missing i18n keys for prompts.ts and provider.ts (selectProviderToLogout, feedback*, catalog*, addProvider*, etc.)
- Fix GoalStrip.vue: blocked goals now show Resume instead of Pause (paused || blocked → resume, active → pause)
- Fix vue-i18n placeholder syntax: {{count}} → {count}, {{pct}} → {pct}
Signed-off-by: 7723qqq <65469696+7723qqq@users.noreply.github.com>
Signed-off-by: 7723qqq <65469696+7723qqq@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant