From 879ebd2dc7248d09b23d477f750a309c3f77cbc1 Mon Sep 17 00:00:00 2001
From: lzt404 <2596933790@qq.com>
Date: Thu, 23 Jul 2026 13:36:37 +0800
Subject: [PATCH] fix(i18n): display language options in their native names
---
src/App.tsx | 13 +++----------
src/i18n/index.tsx | 10 ++++++++++
src/i18n/ja.ts | 4 ----
src/i18n/resources.ts | 8 --------
tests/i18n.test.ts | 11 ++++++++++-
5 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/App.tsx b/src/App.tsx
index 772f07d..d4230b8 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -28,17 +28,10 @@ import { QuotaPage } from './pages/QuotaPage';
import { AgentsPage } from './pages/AgentsPage';
import { ThinkingAliasesPage } from './pages/ThinkingAliasesPage';
import { UsageRecordsPage } from './pages/UsageRecordsPage';
-import { useI18n } from './i18n';
+import { languageOptions, useI18n } from './i18n';
const CONTACT_URL = 'https://qm.qq.com/q/3queDaIG';
-const languageOptions = [
- { value: 'zh-CN', labelKey: 'app.language.zhCN' },
- { value: 'zh-TW', labelKey: 'app.language.zhTW' },
- { value: 'ja', labelKey: 'app.language.ja' },
- { value: 'en', labelKey: 'app.language.en' },
-] as const;
-
const pages = [
{
id: 'kernel',
@@ -282,7 +275,7 @@ function AppContent() {
onClick={() => setLanguageMenuOpen((open) => !open)}
>
- {t(selectedLanguage.labelKey)}
+ {selectedLanguage.nativeLabel}
- {t(option.labelKey)}
+ {option.nativeLabel}
{selected ? : null}
);
diff --git a/src/i18n/index.tsx b/src/i18n/index.tsx
index 2893455..9e86c94 100644
--- a/src/i18n/index.tsx
+++ b/src/i18n/index.tsx
@@ -4,6 +4,16 @@ import { en, ja, zhCN, zhTW, type MessageKey, type MessageVariables } from './re
export type AppLocale = 'zh-CN' | 'zh-TW' | 'ja' | 'en';
+export const languageOptions: ReadonlyArray<{
+ value: AppLocale;
+ nativeLabel: string;
+}> = [
+ { value: 'zh-CN', nativeLabel: '简体中文' },
+ { value: 'zh-TW', nativeLabel: '繁體中文' },
+ { value: 'ja', nativeLabel: '日本語' },
+ { value: 'en', nativeLabel: 'English' },
+];
+
const STORAGE_KEY = 'easy-cli-proxy-api.locale';
const resources = { 'zh-CN': zhCN, 'zh-TW': zhTW, ja, en } as const;
let currentLocale: AppLocale = 'zh-CN';
diff --git a/src/i18n/ja.ts b/src/i18n/ja.ts
index 06bff74..a60c577 100644
--- a/src/i18n/ja.ts
+++ b/src/i18n/ja.ts
@@ -2,10 +2,6 @@ import type { MessageKey } from './resources';
export const jaOverrides = {
'app.language': '言語',
- 'app.language.zhCN': '簡体字中国語',
- 'app.language.zhTW': '繁体字中国語',
- 'app.language.ja': '日本語',
- 'app.language.en': 'English',
'app.desktopConsole': 'デスクトップコンソール',
'app.navigation': 'メインナビゲーション',
'app.nav.kernel': 'コア',
diff --git a/src/i18n/resources.ts b/src/i18n/resources.ts
index aaf30ae..44dc60b 100644
--- a/src/i18n/resources.ts
+++ b/src/i18n/resources.ts
@@ -5,10 +5,6 @@ export type MessageVariables = Record;
export const zhCN = {
'app.language': '语言',
- 'app.language.zhCN': '简体中文',
- 'app.language.zhTW': '繁体中文',
- 'app.language.ja': '日语',
- 'app.language.en': 'English',
'app.desktopConsole': '桌面控制台',
'app.navigation': '主导航',
'app.nav.kernel': '内核',
@@ -682,10 +678,6 @@ export type MessageKey = keyof typeof zhCN;
export const en: Record = {
'app.language': 'Language',
- 'app.language.zhCN': '简体中文',
- 'app.language.zhTW': 'Traditional Chinese',
- 'app.language.ja': 'Japanese',
- 'app.language.en': 'English',
'app.desktopConsole': 'Desktop Console',
'app.navigation': 'Main navigation',
'app.nav.kernel': 'Core',
diff --git a/tests/i18n.test.ts b/tests/i18n.test.ts
index e4d4132..c375c24 100644
--- a/tests/i18n.test.ts
+++ b/tests/i18n.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'bun:test';
-import { normalizeLocale, translate } from '../src/i18n';
+import { languageOptions, normalizeLocale, translate } from '../src/i18n';
import { en, ja, zhCN, zhTW } from '../src/i18n/resources';
import { jaOverrides } from '../src/i18n/ja';
@@ -25,6 +25,15 @@ describe('i18n', () => {
.toBe('1.2.3 をインストールしています');
});
+ it('uses each language native name independently of the active locale', () => {
+ expect(languageOptions).toEqual([
+ { value: 'zh-CN', nativeLabel: '简体中文' },
+ { value: 'zh-TW', nativeLabel: '繁體中文' },
+ { value: 'ja', nativeLabel: '日本語' },
+ { value: 'en', nativeLabel: 'English' },
+ ]);
+ });
+
it('keeps both locale dictionaries structurally aligned', () => {
expect(Object.keys(en).sort()).toEqual(Object.keys(zhCN).sort());
expect(Object.keys(zhTW).sort()).toEqual(Object.keys(zhCN).sort());