Skip to content

Commit

Permalink
if locale has a countryCode set, fallbackTranslations should attempt …
Browse files Browse the repository at this point in the history
…to merge base lang translations with fallback translations
  • Loading branch information
kyle-tbx authored and aissat committed Dec 25, 2021
1 parent 724c6dc commit ef037ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/src/easy_localization_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ class EasyLocalizationController extends ChangeNotifier {
data = await loadTranslationData(_locale);
_translations = Translations(data);
if (useFallbackTranslations && _fallbackLocale != null) {
Map<String, dynamic>? baseLangData;
if (_locale.countryCode != null && _locale.countryCode!.isNotEmpty) {
baseLangData = await loadTranslationData(Locale(locale.languageCode));
}
data = await loadTranslationData(_fallbackLocale!);
if (baseLangData != null) {
data.addAll(baseLangData);
}
_fallbackTranslations = Translations(data);
}
} on FlutterError catch (e) {
Expand Down

0 comments on commit ef037ae

Please sign in to comment.