fix(Locale): Set Intl locale to currently set language in LunaSea

This commit is contained in:
Jagandeep Brar
2021-04-28 00:36:11 -05:00
parent 35330af178
commit e823d69ab7
3 changed files with 12 additions and 4 deletions

View File

@@ -15,6 +15,7 @@
#### FIXES
- `[Locale]` Ensure that the date formatter uses the currently set locale
- `[Search]` Indexers would not load in some cases when the headers map was null/empty
- `[Settings]` (Connection Test) Connection test could fail unexpectedly
- `[Sonarr]` (Edit) Grey screen could be shown when a user has no tags

View File

@@ -10,11 +10,13 @@ Future<void> main() async {
runZonedGuarded(
() async {
await _init();
LunaLocalization localization = LunaLocalization();
return runApp(
EasyLocalization(
supportedLocales: LunaLocalization().supportedLocales,
path: LunaLocalization().fileDirectory,
fallbackLocale: LunaLocalization().fallbackLocale,
supportedLocales: localization.supportedLocales,
path: localization.fileDirectory,
fallbackLocale: localization.fallbackLocale,
startLocale: localization.fallbackLocale,
useFallbackTranslations: true,
child: LunaBIOS(),
),
@@ -91,6 +93,8 @@ class _State extends State<LunaBIOS> {
_firebaseOnMessageOpenedAppListener =
LunaFirebaseMessaging().onMessageOpenedAppListener();
// Remaining boot sequence
Intl.defaultLocale =
LunaLanguage.ENGLISH.fromLocale(context.locale)?.languageTag ?? 'en';
LunaQuickActions().initialize();
LunaChangelog().checkAndShowChangelog();
LunaFirebaseAnalytics().appOpened();

View File

@@ -62,7 +62,10 @@ class _State extends State<_Widget> with LunaScrollControllerMixin {
onTap: () async {
Tuple2<bool, LunaLanguage> result =
await SettingsDialogs().changeLanguage(context);
if (result.item1) result.item2.use(context);
if (result.item1) {
result.item2.use(context);
Intl.defaultLocale = result.item2?.languageTag;
}
},
);
}