更新
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user