Skip to content

Commit b8365eb

Browse files
tylergraydevTyler Grayclaude
authored
feat(i18n): add Simplified Chinese (zh-CN) localization (#219) (#239)
Closes #219. ## What Adds Simplified Chinese alongside existing English and Traditional Chinese. The reporter assumed React, but the app is Svelte and already has a working i18n framework with `zh-TW` — this just adds the third locale. ## How - New `locales/zh-CN.ts` with all 721 strings. Initial pass is a mechanical Traditional → Simplified character conversion with CN-specific vocabulary swaps applied: 项目 (vs 專案), 设置 (vs 設定), 文件 (vs 檔案), 加载 (vs 載入), 刷新 (vs 重新整理), 默认 (vs 預設), 软件 (vs 軟體), 视频 (vs 影片), 仓库 (vs 儲存庫), 服务器 (vs 伺服器), 消息 (vs 訊息), 命令 (vs 指令 for slash commands kept as 命令 to match CN convention), 默认 (vs 預設), 重启 (vs 重新啟動), etc. - Locale switcher labels updated from `EN` / `中文` (ambiguous) to `EN` / `简` / `繁` so users can distinguish the two Chinese options at a glance. `zh-CN` listed before `zh-TW` since CN has the larger user base; cycle order is EN → 简 → 繁 → EN. - `Locale` type union extended with `'zh-CN'`. The existing detect logic already handles bare `zh` browser preferences via prefix matching — `zh-CN` browsers will now match directly instead of falling through to `zh-TW`. - TypeScript validates 1:1 key coverage via `type Translations = Record<TranslationKey, string>` where `TranslationKey = keyof typeof en`. `npm run check` confirms zero missing keys (still at 11-error main baseline, no new errors). ## Native-speaker review wanted This is a translator-as-second-language pass. Some phrasing may feel stiff or use slightly off vocabulary for the context. Inviting follow-up PRs from native zh-CN speakers (especially the issue reporter) — file is structured in section comments mirroring the en/zh-TW files so spot-fixes are easy. ## Test plan - [x] `npm run check` — 11 errors (same as main; Translations type validated all 721 keys present) - [x] `npx vitest run` — 1567/1567 pass - [ ] Manual: launch app on a `zh-CN` system, confirm UI renders Simplified Chinese, test language switcher cycles EN → 简 → 繁 Co-authored-by: Tyler Gray <tylerg@emergentsoftware.net> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 250776a commit b8365eb

3 files changed

Lines changed: 734 additions & 3 deletions

File tree

src/lib/i18n/i18n.svelte.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import { en } from './locales/en';
22
import { zhTW } from './locales/zh-TW';
3+
import { zhCN } from './locales/zh-CN';
34
import type { Locale, LocaleInfo, TranslationKey, Translations } from './types';
45

56
const locales: Record<Locale, Translations> = {
67
en,
7-
'zh-TW': zhTW
8+
'zh-TW': zhTW,
9+
'zh-CN': zhCN
810
};
911

1012
const localeInfos: LocaleInfo[] = [
1113
{ code: 'en', label: 'EN' },
12-
{ code: 'zh-TW', label: '中文' }
14+
{ code: 'zh-CN', label: '简' },
15+
{ code: 'zh-TW', label: '繁' }
1316
];
1417

1518
function detectLocale(): Locale {

0 commit comments

Comments
 (0)