You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
import 'dart:ui';
|
|
|
|
import 'package:get/get.dart';
|
|
import 'package:get_storage/get_storage.dart';
|
|
|
|
import 'language/en_us.dart';
|
|
import 'language/zh_cn.dart';
|
|
import 'language/es_es.dart';
|
|
import 'language/zh_hk.dart';
|
|
|
|
class AppTranslations extends Translations {
|
|
static const fallbackLocale = Locale('zh', 'CN');
|
|
static final supportedLocales = [
|
|
const Locale('zh', 'CN'),
|
|
const Locale('zh', 'HK'), // 添加繁体中文支持
|
|
const Locale('en', 'US'),
|
|
const Locale('es', 'ES'), // 添加西班牙语
|
|
];
|
|
|
|
static Locale? deviceLocale() {
|
|
final GetStorage storage = GetStorage();
|
|
Locale? locale = Get.deviceLocale;
|
|
String? language = storage.read('language');
|
|
if (language != null && language != 'system') {
|
|
List languageList = language.split('_');
|
|
locale = Locale(languageList[0], languageList[1]);
|
|
}
|
|
return locale;
|
|
}
|
|
|
|
@override
|
|
Map<String, Map<String, String>> get keys => {
|
|
'en_US': enUS,
|
|
'zh_CN': zhCN,
|
|
'zh_HK': zhHK, // 添加繁体中文映射
|
|
'es_ES': esES, // 添加西班牙语翻译映射
|
|
};
|
|
}
|
|
|