thaihuynhxyz

Fix fallback locale not working if missing country code

@@ -279,8 +279,9 @@ extension Trans on String { @@ -279,8 +279,9 @@ extension Trans on String {
279 Get.translations[Get.locale.languageCode].containsKey(this)) { 279 Get.translations[Get.locale.languageCode].containsKey(this)) {
280 return Get.translations[Get.locale.languageCode][this]; 280 return Get.translations[Get.locale.languageCode][this];
281 // If there is no corresponding language or corresponding key, return the key. 281 // If there is no corresponding language or corresponding key, return the key.
282 - } else if (Get.fallbackLocale != null &&  
283 - Get.translations.containsKey( 282 + } else if (Get.fallbackLocale == null) {
  283 + return this;
  284 + } else if (Get.translations.containsKey(
284 "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}") && 285 "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}") &&
285 Get.translations[ 286 Get.translations[
286 "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}"] 287 "${Get.fallbackLocale.languageCode}_${Get.fallbackLocale.countryCode}"]
@@ -290,6 +291,9 @@ extension Trans on String { @@ -290,6 +291,9 @@ extension Trans on String {
290 [this]; 291 [this];
291 292
292 // Checks if there is a callback language in the absence of the specific country, and if it contains that key. 293 // Checks if there is a callback language in the absence of the specific country, and if it contains that key.
  294 + } else if (Get.translations.containsKey(Get.fallbackLocale.languageCode) &&
  295 + Get.translations[Get.fallbackLocale.languageCode].containsKey(this)) {
  296 + return Get.translations[Get.fallbackLocale.languageCode][this];
293 } else { 297 } else {
294 return this; 298 return this;
295 } 299 }