Eval locale from language string
@param language
@return new Locale constructed from the language
12712
public static Locale locale(String language) {
        if (language.contains("_")) {
            String[] sa = language.split("_");
            if (sa.length > 2) {
                return new Locale(sa[0], sa[1], sa[2]);
            } else if (sa.length > 1) {
                return new Locale(sa[0], sa[1]);
            } else {
                return new Locale(sa[0]);
            }
        }
        return new Locale(language);
    }
293314
def execute_with_locale(locale = ::I18n.locale, &block)
      actual_locale = ::I18n.locale
      ::I18n.locale = locale

      block.call

      ::I18n.locale = actual_locale
    end
1077807
def from_locale(cls, locale):
        
        locale = str(locale)
        if locale is 'unknown':
            return UnknownLanguage(locale)
        try:
            return cls._from_xyz('locale', locale)
        except NotALanguageException:
            log.warning('Unknown locale: {}'.format(locale))
            return UnknownLanguage(locale)
506940
public final Locale setLocale(Locale loc)
    {
        if (sealed) onSealedMutation();
        Locale result = locale;
        locale = loc;
        return result;
    }
1213519
public static BaseLocale createInstance(String language, String region) {
        BaseLocale base = new BaseLocale(language, region);
        CACHE.put(new Key(language, region), base);
        return base;
    }
154368
public Object eval( String statements, NameSpace nameSpace )
        throws EvalError
    {
        String s = ( statements.endsWith(";") ? statements : statements+";" );
        return eval(
            new StringReader(s), nameSpace,
            "inline evaluation of: ``"+ showEvalString(s)+"''" );
    }
630481
public String getLang(final Locale locale, final String key) {
        return langs.get(locale.toString()).getProperty(key);
    }
1294987
public void setParamLanguage(String language) {

        if (language != null) {
            if (m_paramSelectedLanguages == null) {
                m_paramSelectedLanguages = new HashSet<String>();
            }
            // add all available values here
            String[] values = getParameterMap().get(PARAM_LANGUAGE);
            for (int i = 0; i < values.length; i++) {
                m_paramSelectedLanguages.add(decodeParamValue(PARAM_LANGUAGE, values[i]));
            }
        }
    }
209856
private static Locale createConstant(String lang, String country) {
        BaseLocale base = BaseLocale.createInstance(lang, country);
        return getInstance(base, null);
    }
1096725
public static Locale parseLocaleString(String locale) {
		String lang = GeneralUtils.isEmpty(locale) ? "pt" : locale.substring(0, 2);
		String country = GeneralUtils.isEmpty(locale) ? "" : locale.substring(3, 5);
		return new Locale(lang, country);
	}
437586
public void setLocale(Locale locale) {

        getStateHelper().put(PropertyKeys.locale, locale);
        // Make sure to appraise the EL of this switch in Locale.
        FacesContext.getCurrentInstance().getELContext().setLocale(locale);

    }
1374999
public static Locale parseLocale(String localeString) {
        if (localeString == null || localeString.length() == 0) {
            return Locale.getDefault();
        }
        localeString = localeString.trim();

        if (localeString == null) {
            return null;
        }

        String language = "";
        String country = "";
        String variant = "";

        // language
        int start = 0;
        int index = localeString.indexOf("_");

        if (index >= 0) {
            language = localeString.substring(start, index).trim();

            // country
            start = index + 1;
            index = localeString.indexOf("_", start);

            if (index >= 0) {
                country = localeString.substring(start, index).trim();

                // variant
                variant = localeString.substring(index + 1).trim();
            } else {
                country = localeString.substring(start).trim();
            }
        } else {
            language = localeString.substring(start).trim();
        }

        return new Locale(language, country, variant);
    }
512813
public static Validator forLanguage(String language) {
        if (!Languages.XML_DTD_NS_URI.equals(language)) {
            return new JAXPValidator(language);
        }
        return new ParsingValidator(Languages.XML_DTD_NS_URI);
    }
131557
public static Locale getLocale(final String localeString) {
        final String language = getLanguage(localeString);
        final String country = getCountry(localeString);

        // // XXX: variant
        return new Locale(language, country);
    }
1020564
private static String toLanguageTag(String locale) {
        if (locale == null) {
            return null;
        }
        // assume we are already a language tag
        if (!locale.contains("_")) {
            return locale;
        }

        // language can be missing, in which case we don't even bother
        if (locale.startsWith("_")) {
            return locale;
        }

        // Java 6 does "lang_country_variant". If country is missing, then "lang__variant". If no
        // variant, then just "lang_country".
        String [] parts = locale.split("_", 3);

        String lang = parts[0];
        String country = parts[1];
        String variant = parts.length == 3 ? parts[2] : "";

        return toLanguageTag(new Locale(lang, country, variant));
    }
875537
public CLDR.Locale resolve(String languageTag) {
    MetaLocale meta = MetaLocale.fromLanguageTag(languageTag);
    return resolve(meta);
  }
640772
public String get(final String key, final Locale locale) {
        return get(Keys.LANGUAGE, key, locale);
    }