tr property
String
get
tr
Implementation
String get tr {
// print('language');
// print(Get.locale!.languageCode);
// print('contains');
// print(Get.translations.containsKey(Get.locale!.languageCode));
// print(Get.translations.keys);
// Returns the key if locale is null.
if (Get.locale?.languageCode == null) {
return this;
}
if (_fullLocaleAndKey) {
return Get.translations[
"${Get.locale!.languageCode}_${Get.locale!.countryCode}"]![this]!;
}
final Map<String, String>? similarTranslation =
_getSimilarLanguageTranslation;
if (similarTranslation != null && similarTranslation.containsKey(this)) {
return similarTranslation[this]!;
// If there is no corresponding language or corresponding key, return
// the key.
} else if (Get.fallbackLocale != null) {
final Locale fallback = Get.fallbackLocale!;
final String key = "${fallback.languageCode}_${fallback.countryCode}";
if (Get.translations.containsKey(key) &&
Get.translations[key]!.containsKey(this)) {
return Get.translations[key]![this]!;
}
if (Get.translations.containsKey(fallback.languageCode) &&
Get.translations[fallback.languageCode]!.containsKey(this)) {
return Get.translations[fallback.languageCode]![this]!;
}
return this;
} else {
return this;
}
}