Convert the Java locale to a CLDR locale object.
170328
public CLDR.Locale fromJavaLocale(java.util.Locale javaLocale) {
    return MetaLocale.fromJavaLocale(javaLocale);
  }
1154555
@JSFProperty(deferredValueType="java.lang.Object")
    public Locale getLocale()
    {
        if (_locale != null)
        {
            return _locale;
        }
        FacesContext context = FacesContext.getCurrentInstance();
        return context.getViewRoot().getLocale();
    }
749915
public String transform(Map<String, Object> model, Locale locale) {
		return transform(model, locale, engine.getModelAdaptor(), null);
	}
834409
def norm_locale (loc):
    """"""
    loc = locale.normalize(loc)
    # split up the locale into its base components
    pos = loc.find('@')
    if pos >= 0:
        loc = loc[:pos]
    pos = loc.find('.')
    if pos >= 0:
        loc = loc[:pos]
    pos = loc.find('_')
    if pos >= 0:
        loc = loc[:pos]
    return loc
631009
@Override
    public FastStr toUpperCase(Locale locale) {
        String s = toString();
        return unsafeOf(s.toUpperCase(locale));
    }
261583
public Translation getTranslation(String locale) {
        LocaleCodeSpecification.assertCode(locale);

        return this.getTranslations().get(locale);
    }
259369
public CLDR.Locale resolve(java.util.Locale javaLocale) {
    MetaLocale meta = MetaLocale.fromJavaLocale(javaLocale);
    return resolve(meta);
  }
1078639
private Locale getLocale() {
        Locale userlocale = null;
        if (localeName.length() > 0) {
            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) {
                        docenv.error(null, "main.malformed_locale_name", localeName);
                        return null;
                    }
                    country = localeName.substring(firstuscore + 1,
                                                   seconduscore);
                    variant = localeName.substring(seconduscore + 1);
                } else if (localeName.length() == firstuscore + 3) {
                    country = localeName.substring(firstuscore + 1);
                } else {
                    docenv.error(null, "main.malformed_locale_name", localeName);
                    return null;
                }
            } else if (firstuscore == -1 && localeName.length() == 2) {
                language = localeName;
            } else {
                docenv.error(null, "main.malformed_locale_name", localeName);
                return null;
            }
            userlocale = searchLocale(language, country, variant);
            if (userlocale == null) {
                docenv.error(null, "main.illegal_locale_name", localeName);
                return null;
            } else {
                return userlocale;
            }
        } else {
            return Locale.getDefault();
        }
    }
78479
public static Locale fromString(final String locale) {
        final String[] data = Strings.split(locale, '_');
        if (data.length == 1) {
            return new Locale(data[0]);
        } else if (data.length == 2) {
            return new Locale(data[0], data[1]);
        } else if (data.length == 3) {
            return new Locale(data[0], data[1], data[2]);
        }
        throw new IllegalArgumentException("Invalid locale string: " + locale);
    }
228770
public FastStr toLowerCase(Locale locale) {
        String s = toString();
        return unsafeOf(s.toLowerCase(locale));
    }
1370071
public static UnitConverter get(CLDR.Locale locale) {
    MeasurementSystem system = MeasurementSystem.fromLocale(locale);
    return SYSTEMS.getOrDefault(system, METRIC_SYSTEM);
  }
1053242
public static LocalizedMessages getInstance(Locale locale)
  {
    LocalizedMessages instance = null;

    if (locale == null)
    {
      locale = Locale.getDefault();
    }

    String localeKey = locale.getLanguage();
    if (localizedMessages.containsKey(localeKey))
    {
      instance = localizedMessages.get(localeKey);
    } 
    else
    {
      synchronized (LocalizedMessages.class)
      {
        if (instance == null)
        {
          instance = new LocalizedMessages(locale);
          localizedMessages.put(localeKey, instance);
        }
      }
    }

    return instance;
  }
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;
        }
    }
586648
public static LocaleWrapper findTranslationLocaleFromString(final LocaleProvider localeProvider, final String localeString) {
        if (localeString == null) return null;

        final CollectionWrapper<LocaleWrapper> locales = localeProvider.getLocales();
        for (final LocaleWrapper locale : locales.getItems()) {
            if (localeString.equals(locale.getValue())) {
                return locale;
            }
        }

        return null;
    }
1293719
public static String toUpperCase(String string, Locale locale) {

    if (locale == null) {
      return toUpperCase(string, STANDARD_LOCALE);
    }
    return string.toUpperCase(locale);
  }
140771
public static String getLocalizedId(String id, Locale locale) {
        String locstr = locale == null ? "" : ("_" + locale.toString());
        return id + locstr;
    }
245268
public static Locale getLocaleFromString(String locale) throws LocaleException {
		for(Locale l : Locale.getAvailableLocales()) {
			if(locale.toLowerCase().equals(l.toString().toLowerCase())) {
				return l;
			}
		}
		throw new LocaleException();
	}