Allow web platform to try and load locale

This commit is contained in:
Shawn 2023-07-11 12:07:40 -06:00
parent 23a1741722
commit 35070ad8a0

View File

@ -13,14 +13,11 @@ class LocaleLogic {
Future<void> load() async {
Locale locale = _defaultLocal;
if (kIsWeb) return; // exit early on web as [findSystemLocale] throws errors as of Dec, 2022
final localeCode = settingsLogic.currentLocale.value ?? await findSystemLocale();
locale = Locale(localeCode.split('_')[0]);
if (kDebugMode) {
// locale = Locale('zh'); // uncomment to test chinese
}
final localeCode = settingsLogic.currentLocale.value ?? await findSystemLocale();
// Try and find a supported locale
locale = Locale(localeCode.split('_')[0]);
// Fall back to default
if (AppLocalizations.supportedLocales.contains(locale) == false) {
locale = _defaultLocal;
}