localizeOr method

String localizeOr(
  1. String key,
  2. List<String> alterKeys
)

Tries to localize text by given key.

If given key is not found, then tries to localize one of alterKeys.

Enable/Disable debug mode to show/hide missing localizations.

Implementation

String localizeOr(String key, List<String> alterKeys) {
  if (_data.containsKey(key)) {
    return _data[key];
  }

  for (final alterKey in alterKeys) {
    if (_data.containsKey(alterKey)) {
      return _data[alterKey];
    }
  }

  return debug ? '${key}_$_locale' : '';
}