This commit is contained in:
wyf
2025-08-04 18:19:53 +08:00
parent 4c4f324c56
commit 00215e99d2
13 changed files with 879 additions and 134 deletions

View File

@@ -74,6 +74,7 @@ class AppLanguage extends Translations {
Get.clearTranslations(); // 清除之前加载的翻译,确保切换时不混乱
Get.addTranslations({languageCode: translations});
Get.updateLocale(Locale(languageCode)); // 切换语言
// Get.updateLocale(isChinese()? Locale('zh', 'CN') : Locale('en', 'US')); // 切换语言
_currentLanguageCode = languageCode; // 可选:记录当前语言码
} catch (e) {
@@ -107,8 +108,9 @@ class AppLanguage extends Translations {
}
Locale get currentLocale {
final parts = _currentLanguageCode.split('-');
return Locale(parts[0], parts.length > 1 ? parts[1] : null);
// final parts = _currentLanguageCode.split('-');
// return Locale(parts[0], parts.length > 1 ? parts[1] : null);
return isChinese()? Locale('zh', 'CN') : Locale('en', 'US');
}
bool isChinese() {