tr property

String get tr

Implementation

String get tr {
  // print('language');
  // print(Flower.locale!.languageCode);
  // print('contains');
  // print(Flower.translations.containsKey(Flower.locale!.languageCode));
  // print(Flower.translations.keys);
  // Returns the key if locale is null.
  if (Flower.locale?.languageCode == null) return this;

  if (_fullLocaleAndKey) {
    return Flower.translations[
            "${Flower.locale!.languageCode}_${Flower.locale!.countryCode}"]![
        this]!;
  }
  final 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 (Flower.fallbackLocale != null) {
    final fallback = Flower.fallbackLocale!;
    final key = "${fallback.languageCode}_${fallback.countryCode}";

    if (Flower.translations.containsKey(key) &&
        Flower.translations[key]!.containsKey(this)) {
      return Flower.translations[key]![this]!;
    }
    if (Flower.translations.containsKey(fallback.languageCode) &&
        Flower.translations[fallback.languageCode]!.containsKey(this)) {
      return Flower.translations[fallback.languageCode]![this]!;
    }
    return this;
  } else {
    return this;
  }
}