Language fix for #185

This commit is contained in:
Imran Remtulla
2022-12-22 07:57:21 -05:00
parent 0da7a36f1a
commit 45a23e9025
2 changed files with 11 additions and 3 deletions

View File

@@ -43,12 +43,16 @@ final globalNavigatorKey = GlobalKey<NavigatorState>();
Future<void> loadTranslations() async {
// See easy_localization/issues/210
await EasyLocalizationController.initEasyLocation();
var s = SettingsProvider();
await s.initializeSettings();
var forceLocale = s.forcedLocale;
final controller = EasyLocalizationController(
saveLocale: true,
forceLocale: forceLocale != null ? Locale(forceLocale) : null,
fallbackLocale: fallbackLocale,
supportedLocales: supportedLocales,
assetLoader: const RootBundleAssetLoader(),
useOnlyLangCode: false,
useOnlyLangCode: true,
useFallbackTranslations: true,
path: localeDir,
onLoadError: (FlutterError e) {
@@ -160,6 +164,7 @@ void main() async {
supportedLocales: supportedLocales,
path: localeDir,
fallbackLocale: fallbackLocale,
useOnlyLangCode: true,
child: const Obtainium()),
));
}

View File

@@ -145,8 +145,11 @@ class _SettingsPageState extends State<SettingsPage> {
],
onChanged: (value) {
settingsProvider.forcedLocale = value;
context.setLocale(Locale(settingsProvider.forcedLocale ??
context.fallbackLocale!.languageCode));
if (value != null) {
context.setLocale(Locale(value));
} else {
context.resetLocale();
}
});
var intervalDropdown = DropdownButtonFormField(