mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-25 23:14:18 +03:00
Use English as fallback.
This commit is contained in:
parent
4702666631
commit
c8e84eb72d
@ -49,9 +49,17 @@ final l10nProvider = Provider<AppLocalizations>(
|
|||||||
(ref) => ref.watch(_l10nProvider),
|
(ref) => ref.watch(_l10nProvider),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
AppLocalizations _getL10n(Locale locale) {
|
||||||
|
try {
|
||||||
|
return lookupAppLocalizations(locale);
|
||||||
|
} catch (_) {
|
||||||
|
return lookupAppLocalizations(const Locale('en'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _L10nNotifier extends StateNotifier<AppLocalizations>
|
class _L10nNotifier extends StateNotifier<AppLocalizations>
|
||||||
with WidgetsBindingObserver {
|
with WidgetsBindingObserver {
|
||||||
_L10nNotifier() : super(lookupAppLocalizations(window.locale)) {
|
_L10nNotifier() : super(_getL10n(window.locale)) {
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +72,7 @@ class _L10nNotifier extends StateNotifier<AppLocalizations>
|
|||||||
@override
|
@override
|
||||||
@protected
|
@protected
|
||||||
void didChangeLocales(List<Locale>? locales) {
|
void didChangeLocales(List<Locale>? locales) {
|
||||||
state = lookupAppLocalizations(window.locale);
|
state = _getL10n(window.locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user