Charlatan.addLocale(name, data) -> void
- name (string): locale name, for example `en-US`
- data (object|string): locale hash or yaml file

Load locale to Charlatan. Charlatan preload some
[locales](https://github.com/nodeca/charlatan/tree/master/lib)
490775
function addLocale(name, data) {
  // if data not set, then check available
  if (typeof data === 'undefined') {
    if (!available_locales[name]) {
      throw new Error('Locale not found:' + name);
    }

    data = available_locales[name];

    // load base language, if exists
    var lang = name.split('-')[0];

    if (name !== lang && available_locales[lang]) {
      addLocale(lang);
    }
  }

  // data in file
  if (typeof data === 'string') {
    if (!fs.existsSync(data)) {
      throw new Error('Config ' + data + ' not found');
    }
    data = yaml.safeLoad(fs.readFileSync(data, 'utf8'))[name];

  }
  locales[name] = data;

  // compatibility layer for ruby Faker: we DON'T use intermediate
  // level `faker`, but wish to have universal localizations.
  // So, if `faker` section exists then its children moved 1 level up.
  if (data.faker) {
    Object.keys(data.faker).forEach(function (k) {
      locales[name][k] = data.faker[k];
    });
  }

  return true;
}
1032518
def setCurrentLocale(self, locale):
        
        locale = str(locale)
        for i in xrange(self.count()):
            if self.itemData(i) == locale:
                self.setCurrentIndex(i)
                return True
        return False
1227138
function localeIsLoaded(locale) {
  return !!(Cldr._raw && Cldr._raw.main && Cldr._raw.main[getLocaleKey(locale)]);
}
1090225
def _localized_name(val, klass):
    """"""
    try:
        (text, lang) = val
        return klass(text=text, lang=lang)
    except ValueError:
        return klass(text=val, lang="en")
995212
function updateLocalesCache() {
    cached_available_locales = [];

    fs.readdir(global.config.public_http + '/assets/locales', function (err, files) {
        if (err) {
            if (err.code === 'ENOENT') {
                winston.error('No locale files could be found at ' + err.path);
            } else {
                winston.error('Error reading locales.', err);
            }
        }

        (files || []).forEach(function (file) {
            if (file.substr(-5) === '.json') {
                cached_available_locales.push(file.slice(0, -5));
            }
        });
    });
}
497381
function getLocaleMonthNames(locale, formStyle, width) {
    var /** @type {?} */ data = findLocaleData(locale);
    var /** @type {?} */ monthsData = /** @type {?} */ ([data[5 /* MonthsFormat */], data[6 /* MonthsStandalone */]]);
    var /** @type {?} */ months = getLastDefinedValue(monthsData, formStyle);
    return getLastDefinedValue(months, width);
}
314797
private void initializeLocale() {
        final String locale = getProperty(LOCALE, applicationProperties);
        if (locale != null && !"".equals(locale)) {
            final String[] localeParts = locale.split("_");
            if (localeParts.length == 2) {
                currentLocale = new Locale(localeParts[0], localeParts[1]);
            } else {
                currentLocale = new Locale(localeParts[0]);
            }
        } else {
            currentLocale = Locale.getDefault();
        }
        logger.info(Messages.getMessage(CONTEXT_LOCALE_USED), currentLocale);
    }
1045031
public static String getLocalDisplayName(String locale) {
		String desc = "" + locale;
		if (locale != null) {
			String[] langArray = locale.split("_");
	        Locale loc = null;
	        if (langArray.length == 1) {
	            loc = new Locale(langArray[0]);
	        } else if (langArray.length == 2) {
	            loc = new Locale(langArray[0], langArray[1]);
	        } else if (langArray.length == 3) {
	            loc = new Locale(langArray[0], langArray[1], langArray[2]);
	        }
	        if (loc != null) {
	        	desc = loc.getDisplayLanguage(loc);
	        }
		}
		return desc;
	}
758188
private Locale getLocale(String localeName) throws ToolException {
        Locale userlocale = null;
        if (localeName == null || localeName.isEmpty()) {
            return Locale.getDefault();
        }
        int firstuscore = localeName.indexOf('_');
        int seconduscore = -1;
        String language = null;
        String country = null;
        String variant = null;
        if (firstuscore == 2) {
            language = localeName.substring(0, firstuscore);
            seconduscore = localeName.indexOf('_', firstuscore + 1);
            if (seconduscore > 0) {
                if (seconduscore != firstuscore + 3
                        || localeName.length() <= seconduscore + 1) {
                    String text = messager.getText("main.malformed_locale_name", localeName);
                    throw new ToolException(CMDERR, text);
                }
                country = localeName.substring(firstuscore + 1,
                        seconduscore);
                variant = localeName.substring(seconduscore + 1);
            } else if (localeName.length() == firstuscore + 3) {
                country = localeName.substring(firstuscore + 1);
            } else {
                String text = messager.getText("main.malformed_locale_name", localeName);
                throw new ToolException(CMDERR, text);
            }
        } else if (firstuscore == -1 && localeName.length() == 2) {
            language = localeName;
        } else {
            String text = messager.getText("main.malformed_locale_name", localeName);
            throw new ToolException(CMDERR, text);
        }
        userlocale = searchLocale(language, country, variant);
        if (userlocale == null) {
            String text = messager.getText("main.illegal_locale_name", localeName);
            throw new ToolException(CMDERR, text);
        } else {
            return userlocale;
        }
    }
1042925
public static Locale getLocaleFromName(String name) {
        String language = "";
        String country = "";
        String variant = "";

        int i1 = name.indexOf('_');
        if (i1 < 0) {
            language = name;
        } else {
            language = name.substring(0, i1);
            ++i1;
            int i2 = name.indexOf('_', i1);
            if (i2 < 0) {
                country = name.substring(i1);
            } else {
                country = name.substring(i1, i2);
                variant = name.substring(i2+1);
            }
        }

        return new Locale(language, country, variant);
    }
829693
function writeLocales (locales, params, callback) {
  try {
    var jsonPath, json;
    for (var key in locales) {
      if (locales.hasOwnProperty(key)) {
        json = locales[key];
        jsonPath = path.join(params.dirPath, json.localeName, 'messages.json');

        // remove empty messages
        for (var msg_key in json.messages) {
          if (json.messages.hasOwnProperty(msg_key)) {
            if (json.messages[msg_key]['message'] == undefined) {
              delete json.messages[msg_key];
            }
          }
        }

        fs.outputJsonSync(jsonPath, json.messages);
        if (params.debug) {
          log('Created file', jsonPath, json.messages);
        }
      }
    }
    callback(null);
  } catch (err) {
    callback(err);
  }
}
385407
def locale(qsetting=''):
    
    override_flag = QSettings(qsetting).value(
        'locale/overrideFlag', True, type=bool)

    default = 'en_US'

    if override_flag:
        locale_name = QSettings(qsetting).value(
            'locale/userLocale', default, type=str)
    else:
        # noinspection PyArgumentList
        locale_name = QLocale.system().name()

    if locale_name == 'C':
        # On travis, locale/userLocale is equal to C. We want 'en'.
        locale_name = default

    # NOTES: we split the locale name because we need the first two
    # character i.e. 'id', 'af, etc
    locale_name = str(locale_name).split('_')[0]
    return locale_name
442102
def local_names
      ISO3166.configuration.locales = (ISO3166.configuration.locales + languages.map(&:to_sym)).uniq
      reload

      @local_names ||= languages.map { |language| translations[language] }
    end
616667
function defaultLocale() {
		var sLocale;
		// use the current session locale, if available
		if (window.sap && window.sap.ui && sap.ui.getCore) {
			sLocale = sap.ui.getCore().getConfiguration().getLanguage();
			sLocale = normalize(sLocale);
		}
		// last fallback is english if no or no valid locale is given
		return sLocale || "en";
	}
872272
function removeLocale(locale) {
    if (store.state[moduleName].translations.hasOwnProperty(locale)) {
      store.dispatch({
        type: "".concat(moduleName, "/removeLocale"),
        locale: locale
      });
    }
  }
751513
public void addAvailableLocale(String localeName) {

        Locale locale = getLocale(localeName);
        // add full variation (language / country / variant)
        if (!m_availableLocales.contains(locale)) {
            m_availableLocales.add(locale);
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_I18N_CONFIG_ADD_LOCALE_1, locale));
            }
        }
        // add variation with only language and country
        locale = new Locale(locale.getLanguage(), locale.getCountry());
        if (!m_availableLocales.contains(locale)) {
            m_availableLocales.add(locale);
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_I18N_CONFIG_ADD_LOCALE_1, locale));
            }
        }
        // add variation with language only
        locale = new Locale(locale.getLanguage());
        if (!m_availableLocales.contains(locale)) {
            m_availableLocales.add(locale);
            if (CmsLog.INIT.isInfoEnabled()) {
                CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_I18N_CONFIG_ADD_LOCALE_1, locale));
            }
        }
    }
886286
def NAME(self, node):
        
        # Locate the name in locals / function / globals scopes.
        if isinstance(node.ctx, (ast.Load, ast.AugLoad)):
            self.handleNodeLoad(node)
            if (node.id == 'locals' and isinstance(self.scope, FunctionScope) and
                    isinstance(node.parent, ast.Call)):
                # we are doing locals() call in current scope
                self.scope.usesLocals = True
        elif isinstance(node.ctx, (ast.Store, ast.AugStore, ast.Param)):
            self.handleNodeStore(node)
        elif isinstance(node.ctx, ast.Del):
            self.handleNodeDelete(node)
        else:
            # Unknown context
            raise RuntimeError("Got impossible expression context: %r" % (node.ctx,))