addLocale method

  1. @override
void addLocale(
  1. String localeName,
  2. Function findLocale
)

If we do not already have a locale for localeName then findLocale will be called and the result stored as the lookup mechanism for that locale.

Implementation

@override
void addLocale(String localeName, Function findLocale) {
  if (localeExists(localeName)) return;
  var canonical = Intl.canonicalizedLocale(localeName);
  var newLocale = findLocale(canonical);
  if (newLocale != null) {
    availableMessages[localeName] = newLocale;
    availableMessages[canonical] = newLocale;
    // If there was already a failed lookup for [newLocale], null the cache.
    if (_lastLocale == newLocale) {
      _lastLocale = null;
      _lastLookup = null;
    }
  }
}