From ce526d8d2682ca6cbb4d7c483aa06e483f1a60ec Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Mon, 27 Feb 2023 19:00:50 -0500 Subject: [PATCH] Language bugfix + package upgrades + incr. ver. --- lib/main.dart | 10 +++++++++- lib/pages/settings.dart | 2 +- lib/providers/settings_provider.dart | 11 +++++++++++ pubspec.lock | 4 ++-- pubspec.yaml | 2 +- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 477d983..e992e75 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; // ignore: implementation_imports import 'package:easy_localization/src/localization.dart'; -const String currentVersion = '0.11.4'; +const String currentVersion = '0.11.5'; const String currentReleaseTag = 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES @@ -211,6 +211,14 @@ class _ObtainiumState extends State { false) ]); } + if (!supportedLocales + .map((e) => e.languageCode) + .contains(context.locale.languageCode) || + settingsProvider.forcedLocale == null && + context.deviceLocale.languageCode != + context.locale.languageCode) { + settingsProvider.resetLocaleSafe(context); + } // Register the background update task according to the user's setting if (existingUpdateInterval != settingsProvider.updateInterval) { if (existingUpdateInterval != -1) { diff --git a/lib/pages/settings.dart b/lib/pages/settings.dart index 3caf161..6e707e4 100644 --- a/lib/pages/settings.dart +++ b/lib/pages/settings.dart @@ -152,7 +152,7 @@ class _SettingsPageState extends State { if (value != null) { context.setLocale(Locale(value)); } else { - context.resetLocale(); + settingsProvider.resetLocaleSafe(context); } }); diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index ea6985a..a7c6bc1 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -178,4 +178,15 @@ class SettingsProvider with ChangeNotifier { bool setEqual(Set a, Set b) => a.length == b.length && a.union(b).length == a.length; + + void resetLocaleSafe(BuildContext context) { + if (context.supportedLocales + .map((e) => e.languageCode) + .contains(context.deviceLocale.languageCode)) { + context.resetLocale(); + } else { + context.setLocale(context.fallbackLocale!); + context.deleteSaveLocale(); + } + } } diff --git a/pubspec.lock b/pubspec.lock index 64df9f3..c8a940f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -670,10 +670,10 @@ packages: dependency: "direct main" description: name: sqflite - sha256: "78324387dc81df14f78df06019175a86a2ee0437624166c382e145d0a7fd9a4f" + sha256: "851d5040552cf911f4cabda08d003eca76b27da3ed0002978272e27c8fbf8ecc" url: "https://pub.dev" source: hosted - version: "2.2.4+1" + version: "2.2.5" sqflite_common: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7363fb8..86a1cd0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.11.4+123 # When changing this, update the tag in main() accordingly +version: 0.11.5+124 # When changing this, update the tag in main() accordingly environment: sdk: '>=2.18.2 <3.0.0'