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.
29 lines
804 B
29 lines
804 B
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';
|
|
|
|
class AppTranslations extends Translations {
|
|
static const fallbackLocale = Locale('zh', 'CN');
|
|
static final supportedLocales = [
|
|
const Locale('zh', 'CN'),
|
|
const Locale('en', 'US'),
|
|
];
|
|
|
|
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};
|
|
}
|
|
|