From 77d4fcbf3f89cafa523a48e13a18e30bfc7216ba Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Sun, 7 Dec 2025 12:08:17 +0000 Subject: [PATCH] fmt --- crates/services/src/services/config/versions/v6.rs | 8 ++++---- frontend/src/i18n/config.ts | 10 +++++++--- frontend/src/i18n/languages.ts | 9 ++++++++- frontend/src/i18n/locales/zh-Hans/common.json | 2 +- frontend/src/i18n/locales/zh-Hans/projects.json | 2 +- frontend/src/i18n/locales/zh-Hans/settings.json | 2 +- frontend/src/i18n/locales/zh-Hans/tasks.json | 2 +- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/crates/services/src/services/config/versions/v6.rs b/crates/services/src/services/config/versions/v6.rs index 35b49487..e5bfdd6d 100644 --- a/crates/services/src/services/config/versions/v6.rs +++ b/crates/services/src/services/config/versions/v6.rs @@ -15,10 +15,10 @@ use crate::services::config::versions::v5; pub enum UiLanguage { #[default] Browser, // Detect from browser - En, // Force English - Ja, // Force Japanese - Es, // Force Spanish - Ko, // Force Korean + En, // Force English + Ja, // Force Japanese + Es, // Force Spanish + Ko, // Force Korean ZhHans, // Force Simplified Chinese } diff --git a/frontend/src/i18n/config.ts b/frontend/src/i18n/config.ts index 567f6d89..298ff918 100644 --- a/frontend/src/i18n/config.ts +++ b/frontend/src/i18n/config.ts @@ -73,11 +73,15 @@ i18n .use(initReactI18next) .init({ resources, - fallbackLng: 'en', + fallbackLng: { + zh: ['zh-Hans'], // Map generic Chinese to Simplified Chinese + default: ['en'], + }, defaultNS: 'common', debug: import.meta.env.DEV, - supportedLngs: SUPPORTED_I18N_CODES, - load: 'languageOnly', // Load 'en' instead of 'en-US' etc. + supportedLngs: [...SUPPORTED_I18N_CODES, 'zh'], // Include 'zh' for browser detection + nonExplicitSupportedLngs: true, // Accept zh -> zh-Hans mapping + load: 'currentOnly', // Load exact language code interpolation: { escapeValue: false, // React already escapes diff --git a/frontend/src/i18n/languages.ts b/frontend/src/i18n/languages.ts index ca09b168..300210a4 100644 --- a/frontend/src/i18n/languages.ts +++ b/frontend/src/i18n/languages.ts @@ -14,7 +14,14 @@ export const UI_TO_I18N = { ZH_HANS: 'zh-Hans', } as const; -const SUPPORTED_UI_LANGUAGES = ['BROWSER', 'EN', 'JA', 'ES', 'KO', 'ZH_HANS'] as const; +const SUPPORTED_UI_LANGUAGES = [ + 'BROWSER', + 'EN', + 'JA', + 'ES', + 'KO', + 'ZH_HANS', +] as const; export const SUPPORTED_I18N_CODES = Object.values(UI_TO_I18N); const FALLBACK_ENDONYMS = { diff --git a/frontend/src/i18n/locales/zh-Hans/common.json b/frontend/src/i18n/locales/zh-Hans/common.json index 1b7c51a0..3ce12909 100644 --- a/frontend/src/i18n/locales/zh-Hans/common.json +++ b/frontend/src/i18n/locales/zh-Hans/common.json @@ -85,4 +85,4 @@ "errorDescription": "验证您的账户时出现问题", "tryAgain": "重试" } -} \ No newline at end of file +} diff --git a/frontend/src/i18n/locales/zh-Hans/projects.json b/frontend/src/i18n/locales/zh-Hans/projects.json index 13cbf88e..4b195373 100644 --- a/frontend/src/i18n/locales/zh-Hans/projects.json +++ b/frontend/src/i18n/locales/zh-Hans/projects.json @@ -48,4 +48,4 @@ "openInIDE": "在 IDE 中打开", "createdDate": "创建于 {{date}}", "copyFilesPlaceholderWithSearch": "文件路径或 glob 模式(例如:.env、config/*.json)" -} \ No newline at end of file +} diff --git a/frontend/src/i18n/locales/zh-Hans/settings.json b/frontend/src/i18n/locales/zh-Hans/settings.json index b5efecc6..7bb48471 100644 --- a/frontend/src/i18n/locales/zh-Hans/settings.json +++ b/frontend/src/i18n/locales/zh-Hans/settings.json @@ -384,4 +384,4 @@ } } } -} \ No newline at end of file +} diff --git a/frontend/src/i18n/locales/zh-Hans/tasks.json b/frontend/src/i18n/locales/zh-Hans/tasks.json index 2ae0ee97..2c8c0ddc 100644 --- a/frontend/src/i18n/locales/zh-Hans/tasks.json +++ b/frontend/src/i18n/locales/zh-Hans/tasks.json @@ -428,4 +428,4 @@ "discardChanges": "放弃更改" } } -} \ No newline at end of file +}