getOrDefault method

String getOrDefault(
  1. String locale,
  2. String key,
  3. String defaultValue, [
  4. List args = const [],
])

Get the translation for the given key. If the key is not found, it returns the message in the defaultLocale locale. If the key is not found in the defaultLocale locale, it returns the key. Read more at LocalizerLocale.getOrDefault.

Implementation

String getOrDefault(String locale, String key, String defaultValue,
    [List args = const []]) {
  final localeData = getLocaleOrNull(locale) ?? getDefaultLocale();
  return localeData.contains(key)
      ? localeData.get(key, args)
      : getDefaultLocale().getOrDefault(key, defaultValue, args);
}