Determine the normalized locale code string.

    >>> normalize_locale_code('ko-kr')
    'ko_KR'
    >>> normalize_locale_code('zh_TW')
    'zh_Hant_TW'
    >>> normalize_locale_code(Locale.parse('en_US'))
    'en_US'
323767
def normalize_locale_code(locale: Union[Locale, str]) -> str:
    
    if not isinstance(locale, Locale):
        locale = Locale.parse(locale.replace('-', '_'))
    return str(locale)
469258
def get_locale(self, language=None, country=None, variant=None):
        
        # http://www.openoffice.org/api/docs/common/ref/com/sun/star/lang/Locale.html
        locale = uno.createUnoStruct('com.sun.star.lang.Locale')
        if language:
            locale.Language = language
        if country:
            locale.Country = country
        if variant:
            locale.Variant = variant
        formats = self._target.getNumberFormats()
        return Locale(locale, formats)
741475
def normalize_keys(locale, key, scope, separator = nil)
      separator ||= I18n.default_separator

      keys = []
      keys.concat normalize_key(locale, separator)
      keys.concat normalize_key(scope, separator)
      keys.concat normalize_key(key, separator)
      keys
    end
1118950
def prefix_locale?(locale = Language.current.code)
      multi_language? && locale != ::I18n.default_locale.to_s
    end
692492
def guess_file_encoding(fh, default=DEFAULT_ENCODING):
    """"""
    start = fh.tell()
    detector = chardet.UniversalDetector()
    while True:
        data = fh.read(1024 * 10)
        if not data:
            detector.close()
            break
        detector.feed(data)
        if detector.done:
            break

    fh.seek(start)
    return normalize_result(detector.result, default=default)
1003299
private Locale getLocale(String acceptLanguage) {
		if (acceptLanguage == null) {
			acceptLanguage = "fr";
		}
		String[] langs = acceptLanguage.split(",");
		return Locale.forLanguageTag(langs[0].split("-")[0]);
	}
1162212
private String localize(String key, String defaultValue) {
    String result = defaultValue;
    if (bundle != null) {
      try {
        result = bundle.getString(key);
      }
      catch (MissingResourceException mre) {
      }
    }
    return result;
  }
628852
public String getLocalizedName(Locale locale) {

        if (m_messageContainer != null) {
            return m_messageContainer.key(locale);
        }
        return m_key;
    }
1223683
String getLocalName() {

        if (!locale_set) {
            setLocale(Locale.getDefault());
        }

        String key = this.getTypeName();

        return BundleHandler.getString(hnd_local_names, key);
    }
215372
def _get_encoding(self):
        """"""
        enco = 'utf-8'

        #  Currently only cp1252 is allowed?
        if WIN:
            import ctypes
            codepage = to_text_string(ctypes.cdll.kernel32.GetACP())
            # import locale
            # locale.getpreferredencoding()  # Differences?
            enco = 'cp' + codepage
        return enco
39096
public String getLangDesc(String s) {
    if (s.equals("en"))
      return "English";
    if (s.equals("nl"))
      return "Nederlands (Dutch)";
    if (s.equals("de"))
      return "Deutsch (German)";
    if (s.equals("ru"))
      return "\u0440\u0443\u0301\u0441\u0441\u043a\u0438\u0439 (Russian)";
    return "\"" + s + "\"";
  }
332024
protected static String getLang() {
        Locale locale = Locale.getDefault();

        if (null == locale)
            return DEFAULT_LANGUAGE_CODE;

        String language = locale.getLanguage();
        String country = locale.getCountry();
        String localeString = String.format("%s_%s",
                language != null ? language.toLowerCase(Locale.ENGLISH) : "",
                country != null ? country.toUpperCase(Locale.ENGLISH) : "");

        // 1. if no language is specified, return the default language
        if (null == language)
            return DEFAULT_LANGUAGE_CODE;

        // 2. try to match the language or the entire locale string among the
        // list of available language codes
        String matchedLanguageCode = null;
        for (String languageCode : VALID_LANGUAGE_CODES) {
            if (languageCode.equals(localeString)) {
                // return here as this is the most precise match we can get
                return localeString;
            }

            if (languageCode.equals(language)) {
                // set the matched language code, and continue iterating as we
                // may match the localeString in a later iteration.
                matchedLanguageCode = language;
            }
        }

        if (null != matchedLanguageCode)
            return matchedLanguageCode;

        return DEFAULT_LANGUAGE_CODE;
    }
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)
191760
public static String getEncodingFromLocale(Locale locale) {
    	init();
        if (locale == cachedLocale) {
            return cachedEncoding;
        }

        String encoding = null;
        /*(String) _localeMap.get(locale.toString());

        if (encoding == null) {
            encoding = (String) _localeMap.get(locale.getLanguage() + "_" + locale.getCountry());

            if (encoding == null) {
                encoding = (String) _localeMap.get(locale.getLanguage());
            }            
        }*/
        if (encoding == null) {
            //check the com.ibm.wsspi.http.EncodingUtils
            com.ibm.wsspi.http.EncodingUtils encodingUtils = com.ibm.ws.webcontainer.osgi.WebContainer.getEncodingUtils();
            if (encodingUtils!=null) {
                encoding = encodingUtils.getEncodingFromLocale(locale);
            }
        }

        cachedEncoding = encoding;
        cachedLocale = locale;

        return encoding;
    }
1331168
def get_default_language(language_code=None):
    

    if not language_code:
        language_code = settings.LANGUAGE_CODE

    languages = dict(settings.LANGUAGES).keys()

    # first try if there is an exact language
    if language_code in languages:
        return language_code

    # otherwise split the language code if possible, so iso3
    language_code = language_code.split("-")[0]

    if language_code not in languages:
        raise ImproperlyConfigured("No match in LANGUAGES for LANGUAGE_CODE %s" % settings.LANGUAGE_CODE)

    return language_code
312402
def extract_country_code(input, options={})
      options[:region] ||= Phoney.region
      intl_prefix = international_call_prefix_for(input, region: options[:region])
      
      # only try to extract a country code if we're dialing internationally
      if intl_prefix
        rest   = input[intl_prefix.count(NUMPAD_CHARS)..-1]
        region = Phoney::Region.all.find { |r| rest.start_with? r.country_code.to_s }
        
        region.country_code.to_s if region
      end
    end
376413
protected String getI18n(final String aMessageKey, final int aIntDetail) {
        return StringUtils.normalizeWS(myBundle.get(aMessageKey, Integer.toString(aIntDetail)));
    }