getTextForLocale method

String? getTextForLocale(
  1. String textId,
  2. String? locale
)

The text for textId in locale, searching in order:

  1. locale, the given form;
  2. locale, no form (if fallbackDefaultForm and a form was given);
  3. then the same in the default locale, if both fallbacks are on and locale isn't the default.

Returns null if nothing is found. Throws UnregisteredLocaleException if locale is null or undefined.

Implementation

String? getTextForLocale(String textId, String? locale) {
  var text = getRawText(locale, textId);
  if (text == null && fallbackDefaultForm && textId.contains(';')) {
    text = getRawText(locale, textId.substring(0, textId.indexOf(';')));
  }
  final defaultLocale = _defaultLocale;
  if (text == null &&
      fallbackDefaultLocale &&
      locale != defaultLocale &&
      defaultLocale != null &&
      fallbackDefaultForm) {
    text = getTextForLocale(textId, defaultLocale);
  }
  return text;
}