22 lines
581 B
Dart
22 lines
581 B
Dart
import 'dart:ui';
|
|
|
|
class ChangeLanguageFormat {
|
|
static Locale convertLocale(Locale locale) {
|
|
if (locale.languageCode == 'zh') {
|
|
if (locale.scriptCode == 'Hans') {
|
|
// 简体中文
|
|
return const Locale('zh', 'CN');
|
|
} else if (locale.scriptCode == 'Hant') {
|
|
// 繁体中文
|
|
if (locale.countryCode == 'CN') {
|
|
return const Locale('zh', 'TW');
|
|
} else if (locale.countryCode == 'HK') {
|
|
return const Locale('zh', 'HK');
|
|
}
|
|
}
|
|
}
|
|
// 默认返回 Locale 的完整格式
|
|
return locale;
|
|
}
|
|
}
|