Committed by
GitHub
Update internacionalization.dart
Fixes #2039
Localization don't work for Locale('en_US') or Locale('de_DE')
With this change, it supports both situations:
When locale has only language code like Locale('en') or Locale('en_US')
Showing
1 changed file
with
2 additions
and
2 deletions
| @@ -69,13 +69,13 @@ extension Trans on String { | @@ -69,13 +69,13 @@ extension Trans on String { | ||
| 69 | final translationsWithNoCountry = Get.translations | 69 | final translationsWithNoCountry = Get.translations |
| 70 | .map((key, value) => MapEntry(key.split("_").first, value)); | 70 | .map((key, value) => MapEntry(key.split("_").first, value)); |
| 71 | final containsKey = | 71 | final containsKey = |
| 72 | - translationsWithNoCountry.containsKey(Get.locale!.languageCode); | 72 | + translationsWithNoCountry.containsKey(Get.locale!.languageCode.split("_").first); |
| 73 | 73 | ||
| 74 | if (!containsKey) { | 74 | if (!containsKey) { |
| 75 | return null; | 75 | return null; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | - return translationsWithNoCountry[Get.locale!.languageCode]; | 78 | + return translationsWithNoCountry[Get.locale!.languageCode.split("_").first]; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | String get tr { | 81 | String get tr { |
-
Please register or login to post a comment