diff --git a/docs/theme.md b/docs/theme.md index 1f7226883..294ed5d92 100644 --- a/docs/theme.md +++ b/docs/theme.md @@ -71,6 +71,8 @@ 应用使用 Vue I18n Composition API,语言标识为 `en`、`zh-Hans`、`zh-Hant`。资源按领域存放在 `frontend/src/i18n/locales/`,使用 `领域.功能.用途` 的语义 key,例如 `accounts.connectionTest.description`,三种语言保持相同 key 和具名参数 +默认语言为简体中文,浏览器本地保存的有效语言选择优先;未保存选择、保存值无效或存储不可用时使用简体中文 + 业务语言包及对应 UI 文案按语言加载,首次只加载当前语言,加载成功后缓存资源。缺失消息显示为空,不回退到其他语言或显示 key;切换时语言包加载失败则保留当前语言 - 标签、帮助、ARIA、通知和图表显式取消息;列定义、选项和展示投影使用响应式计算,不把翻译结果存进业务数据 diff --git a/frontend/src/i18n/locale.ts b/frontend/src/i18n/locale.ts index d0442c9bf..84dda7078 100644 --- a/frontend/src/i18n/locale.ts +++ b/frontend/src/i18n/locale.ts @@ -12,25 +12,6 @@ export function isLocale(value: unknown): value is Locale { return localeOptions.some(option => option.value === value) } -export function normalizeLocale(language: string): Locale { - try { - const { language: base, script, region } = new Intl.Locale(language) - if (base === 'zh') { - if (script === 'Hant') - return 'zh-Hant' - if (script === 'Hans') - return 'zh-Hans' - return region && ['TW', 'HK', 'MO'].includes(region) - ? 'zh-Hant' - : 'zh-Hans' - } - } - catch { - // 无效的浏览器语言使用应用默认语言 - } - return 'en' -} - export function readInitialLocale(): Locale { try { const saved = localStorage.getItem(storageKey) @@ -38,9 +19,9 @@ export function readInitialLocale(): Locale { return saved } catch { - // 存储不可用时继续使用浏览器语言 + // 存储不可用时使用默认语言 } - return normalizeLocale(navigator.language) + return 'zh-Hans' } export function applyLocale(value: string): void { diff --git a/frontend/src/i18n/locales/en/auth.json b/frontend/src/i18n/locales/en/auth.json index b6bb11a88..e21aae4c3 100644 --- a/frontend/src/i18n/locales/en/auth.json +++ b/frontend/src/i18n/locales/en/auth.json @@ -8,8 +8,8 @@ "method": "Login method", "title": "Console login", "welcome": "Welcome back", - "username": "Admin account", - "usernamePlaceholder": "Enter your admin account", + "username": "Account", + "usernamePlaceholder": "Enter your account", "passwordPlaceholder": "Enter your password", "apiKeyPlaceholder": "Enter your API key", "pageLabel": "Log in to Codex Proxy RS", diff --git a/frontend/src/i18n/locales/zh-Hans/auth.json b/frontend/src/i18n/locales/zh-Hans/auth.json index b11001555..f3259ad9c 100644 --- a/frontend/src/i18n/locales/zh-Hans/auth.json +++ b/frontend/src/i18n/locales/zh-Hans/auth.json @@ -8,14 +8,14 @@ "method": "选择登录方式", "title": "控制台登录", "welcome": "「 欢迎回来,登录以开始您的数据之旅 」", - "username": "管理员账号", - "usernamePlaceholder": "输入会话账号", + "username": "账号", + "usernamePlaceholder": "输入账号", "passwordPlaceholder": "输入会话密钥", "apiKeyPlaceholder": "输入 API密钥", "pageLabel": "Codex Proxy RS 登录", "password": "密码", "apiKey": "API密钥", - "adminRealm": "管理员", + "adminRealm": "Admin", "keyRealm": "API密钥" } } diff --git a/frontend/src/i18n/locales/zh-Hant/auth.json b/frontend/src/i18n/locales/zh-Hant/auth.json index f3eabd2fc..0f710a307 100644 --- a/frontend/src/i18n/locales/zh-Hant/auth.json +++ b/frontend/src/i18n/locales/zh-Hant/auth.json @@ -8,14 +8,14 @@ "method": "選擇登錄方式", "title": "控制檯登錄", "welcome": "「 歡迎回來,登錄以開始您的數據之旅 」", - "username": "管理員賬號", - "usernamePlaceholder": "輸入會話賬號", + "username": "賬號", + "usernamePlaceholder": "輸入賬號", "passwordPlaceholder": "輸入會話密鑰", "apiKeyPlaceholder": "輸入 API密鑰", "pageLabel": "Codex Proxy RS 登錄", "password": "密碼", "apiKey": "API密鑰", - "adminRealm": "管理員", + "adminRealm": "Admin", "keyRealm": "API密鑰" } }