Files
ZL-Q a83001de0d feat(locale): 实现 App 启动时语言和时区自动设置
- 新增系统语言/时区读取工具函数
- SessionStore 扩展支持时区存储
- 启动流程自动检测并保存系统语言/时区
- 注册时传递语言/时区到后端
- 登录后从服务器同步语言/时区
2026-04-28 17:18:16 +08:00

28 lines
615 B
Dart

import 'dart:ui';
Locale? resolveSystemLocale(Locale systemLocale) {
final lang = systemLocale.languageCode.toLowerCase();
final script = systemLocale.scriptCode;
final country = systemLocale.countryCode;
if (lang == 'en') {
return const Locale('en');
}
if (lang == 'zh') {
if (script == 'Hant' ||
country == 'TW' ||
country == 'HK' ||
country == 'MO') {
return const Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant');
}
return const Locale('zh');
}
return null;
}
Locale getSystemLocale() {
return PlatformDispatcher.instance.locale;
}