Skip to content

feat(i18n): 添加 i18n 基础设施 + 英文/中文翻译#89

Closed
gy212 wants to merge 4 commits intoop7418:mainfrom
gy212:feat/i18n-base
Closed

feat(i18n): 添加 i18n 基础设施 + 英文/中文翻译#89
gy212 wants to merge 4 commits intoop7418:mainfrom
gy212:feat/i18n-base

Conversation

@gy212
Copy link
Contributor

@gy212 gy212 commented Feb 23, 2026

概述

为 CodePilot 添加国际化(i18n)基础设施,包含英文(en)和简体中文(zh)两种语言支持。

改动内容

  • 新增 i18n 核心模块(src/i18n/index.ts):翻译函数、类型定义、参数插值
  • 新增英文翻译文件(src/i18n/en.ts)作为基准语言
  • 新增简体中文翻译文件(src/i18n/zh.ts
  • 新增 I18nProvider 上下文组件和 useTranslation Hook
  • 改造所有 UI 组件,将硬编码文本替换为翻译键
  • 设置页面新增语言切换功能,locale 持久化到 app settings

说明

其他语言(zh-TW、ja、es、pt-BR、de、fr、ru)将在独立 PR 中逐一添加。

gy212 and others added 3 commits February 23, 2026 22:01
Add internationalization support with useTranslation hook, I18nProvider,
and language files for: zh, en, zh-TW, ja, es, pt-BR, de, fr, ru

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove extra language files (zh-TW, ja, es, pt-BR, de, fr, ru) from
the base i18n PR. Each language will be added in a separate PR.
op7418 pushed a commit that referenced this pull request Feb 24, 2026
Implements a zero-dependency i18n framework with TypeScript type safety.
Thanks to @gy212 for the original i18n infrastructure design (PR #89)
and comprehensive translation files (PR #90-96) that inspired this implementation.

## New files (5)

- src/i18n/en.ts: English translations (source of truth, ~270 keys),
  exports TranslationKey type for compile-time key completeness
- src/i18n/zh.ts: Chinese translations, typed as Record<TranslationKey, string>
- src/i18n/index.ts: translate() function with {param} interpolation,
  Locale type, SUPPORTED_LOCALES array
- src/components/layout/I18nProvider.tsx: React Context provider,
  loads/persists locale preference via /api/settings/app
- src/hooks/useTranslation.ts: useTranslation() hook returning
  { locale, setLocale, t }

## Infrastructure wiring

- src/app/layout.tsx: I18nProvider wrapped inside ThemeProvider
- src/app/api/settings/app/route.ts: added "locale" to ALLOWED_KEYS
  for persistence

## Language picker

- src/components/settings/GeneralSection.tsx: added language selection
  dropdown (Select component) in Settings > General, using
  SUPPORTED_LOCALES and setLocale()

## String replacements (33 component files)

All hardcoded user-facing strings replaced with t() calls:

High priority (chat):
- ChatListPanel.tsx: session list, search, empty state, relative time
- NavRail.tsx: nav labels, theme toggle, auto-approve indicator
- MessageInput.tsx: command descriptions, mode labels, attach tooltip
- MessageList.tsx: empty state, load earlier, loading indicator
- StreamingMessage.tsx: thinking, permission actions
- chat/[id]/page.tsx: session title fallback

Settings:
- GeneralSection.tsx: update card, auto-approve section, warning dialog
- SettingsLayout.tsx: title, description, sidebar labels
- CliSettingsSection.tsx: form/json tabs, buttons, dynamic field labels
  (skipDangerousModePermissionPrompt etc.), Enabled/Disabled states
- ProviderForm.tsx: dialog title, form labels, buttons
- ProviderManager.tsx: status badges, delete dialog, section headers

Extensions:
- extensions/page.tsx: title, tab labels
- SkillsManager.tsx: empty state, loading, search
- SkillEditor.tsx: toolbar buttons, placeholder
- SkillListItem.tsx: delete confirmation
- CreateSkillDialog.tsx: form labels, scope, templates, validation

Plugins:
- McpManager.tsx: header, tabs, loading state
- McpServerList.tsx: empty state, badges, field labels
- McpServerEditor.tsx: dialog title, form labels, buttons
- ConfigEditor.tsx: save/format buttons

Layout:
- RightPanel.tsx: panel header, open/close tooltips
- FileTree.tsx: search placeholder, empty states
- FilePreview.tsx: back button, line count, copy path
- DocPreview.tsx: iframe title
- ConnectionStatus.tsx: install prompts, version display
- InstallWizard.tsx: phase descriptions, button labels
- ImportSessionDialog.tsx: search, relative time, import buttons
- FolderPicker.tsx: dialog title, loading, buttons
- TaskList.tsx: filter tabs, input placeholder, empty states
@op7418
Copy link
Owner

op7418 commented Feb 24, 2026

Closed — i18n infrastructure and Chinese/English translations have been implemented in v0.13.0 (commit c7c3ba5). Thank you @gy212 for the excellent i18n framework design and comprehensive translation files that inspired this implementation! 🙏 The remaining language translations (zh-TW, ja, es, pt-BR, de, fr, ru) from PRs #90-96 will be integrated in a follow-up release.

@op7418 op7418 closed this Feb 24, 2026
@gy212 gy212 deleted the feat/i18n-base branch March 5, 2026 01:31
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.

2 participants