From e823d69ab78214b47e65f6ff32036eee9a0aea6c Mon Sep 17 00:00:00 2001 From: Jagandeep Brar Date: Wed, 28 Apr 2021 00:36:11 -0500 Subject: [PATCH] fix(Locale): Set Intl locale to currently set language in LunaSea --- CHANGELOG.md | 1 + lib/main.dart | 10 +++++++--- .../routes/configuration_localization/route.dart | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59a53c7a..f258e278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/main.dart b/lib/main.dart index ac82cc6f..c19fda49 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,11 +10,13 @@ Future 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 { _firebaseOnMessageOpenedAppListener = LunaFirebaseMessaging().onMessageOpenedAppListener(); // Remaining boot sequence + Intl.defaultLocale = + LunaLanguage.ENGLISH.fromLocale(context.locale)?.languageTag ?? 'en'; LunaQuickActions().initialize(); LunaChangelog().checkAndShowChangelog(); LunaFirebaseAnalytics().appOpened(); diff --git a/lib/modules/settings/routes/configuration_localization/route.dart b/lib/modules/settings/routes/configuration_localization/route.dart index 98775853..30af22f1 100644 --- a/lib/modules/settings/routes/configuration_localization/route.dart +++ b/lib/modules/settings/routes/configuration_localization/route.dart @@ -62,7 +62,10 @@ class _State extends State<_Widget> with LunaScrollControllerMixin { onTap: () async { Tuple2 result = await SettingsDialogs().changeLanguage(context); - if (result.item1) result.item2.use(context); + if (result.item1) { + result.item2.use(context); + Intl.defaultLocale = result.item2?.languageTag; + } }, ); }