Gets a {@link Locale} instance by the value of the component attribute "locale" which can be String or {@link Locale} or null.
<p>
If NULL is passed the view root default locale is used.

@param locale given locale
@return resolved Locale
492216
public static Locale resolveLocale(Object locale, String clientId) {
        Locale result = null;

        if (locale != null) {
            if (locale instanceof String) {
                result = toLocale((String) locale);
            }
            else if (locale instanceof java.util.Locale) {
                result = (java.util.Locale) locale;
            }
            else {
                throw new IllegalArgumentException("Type:" + locale.getClass() + " is not a valid locale type for: " + clientId);
            }
        }
        else {
            // default to the view local
            result = FacesContext.getCurrentInstance().getViewRoot().getLocale();
        }

        return result;
    }
1006678
protected String getLocaleSpecificTitle(Locale locale) {

        String result = null;

        try {

            if (isDetailRequest()) {
                // this is a request to a detail page
                CmsResource res = getDetailContent();
                CmsFile file = m_cms.readFile(res);
                CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, file);
                result = content.getHandler().getTitleMapping(m_cms, content, m_cms.getRequestContext().getLocale());
                if (result == null) {
                    // title not found, maybe no mapping OR not available in the current locale
                    // read the title of the detail resource as fall back (may contain mapping from another locale)
                    result = m_cms.readPropertyObject(
                        res,
                        CmsPropertyDefinition.PROPERTY_TITLE,
                        false,
                        locale).getValue();
                }
            }
            if (result == null) {
                // read the title of the requested resource as fall back
                result = m_cms.readPropertyObject(
                    m_cms.getRequestContext().getUri(),
                    CmsPropertyDefinition.PROPERTY_TITLE,
                    true,
                    locale).getValue();
            }
        } catch (CmsException e) {
            LOG.debug(e.getLocalizedMessage(), e);
        }
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(result)) {
            result = "";
        }

        return result;
    }
1114214
public <T> T getField(String locale, String key) {
    return localize(locale).getField(key);
  }
1176626
@Override
    public String getEncodingFromLocale(Locale locale) {
        if (null == locale) {
            return null;
        }
        if (locale.equals(this.cachedLocale)) {
            return this.cachedEncoding;
        }

        String encoding = localeMap.get(locale.toString());
        if (null == encoding) {
            final String lang = locale.getLanguage();
            encoding = localeMap.get(lang + '_' + locale.getCountry());
            if (null == encoding) {
                encoding = localeMap.get(lang);
            }
        }

        this.cachedEncoding = encoding;
        this.cachedLocale = locale;

        return encoding;
    }
489026
public Locale getLocale()
    {
        String strLanguage = this.getProperty(Params.LANGUAGE);
        if ((strLanguage != null) && (strLanguage.length() > 0))
        {
            Locale locale = Locale.getDefault();
            if (!strLanguage.equalsIgnoreCase(locale.getLanguage()))
                locale = new Locale(strLanguage, "");
            if (locale != null)
            {
                try {
                    Locale.setDefault(locale);
                } catch (java.security.AccessControlException ex) {
                    Util.getLogger().warning("Can't change locale");   // Ignore and continue
                }
            }
        }
        return Locale.getDefault();
    }
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);
    }
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();
	}
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;
        }
    }
1201702
public String getTitle(Locale locale)
   {
      String result = null;

      if (m_title != null)
      {
         result = m_title;
      }
      else
      {
         if (m_fieldType != null)
         {
            result = m_project.getCustomFields().getCustomField(m_fieldType).getAlias();
            if (result == null)
            {
               result = m_fieldType.getName(locale);
            }
         }
      }

      return (result);
   }
1208497
public static Currency getInstance(Locale locale) {
        synchronized (localesToCurrencies) {
            if (locale == null) {
                throw new NullPointerException("locale == null");
            }
            Currency currency = localesToCurrencies.get(locale);
            if (currency != null) {
                return currency;
            }

            String currencyCode = ICU.getCurrencyCode(locale);
            if (currencyCode == null) {
                throw new IllegalArgumentException("Unsupported ISO 3166 country: " + locale);
            } else if (currencyCode.equals("XXX")) {
                return null;
            }
            Currency result = getInstance(currencyCode);
            localesToCurrencies.put(locale, result);
            return result;
        }
    }
1111136
public String getDisplayName(final String locale) {
        if (this.uiInfo != null) {
            val displayName = getLocalizedValues(locale, this.uiInfo.getDisplayNames());
            return displayName != null ? displayName : super.getDisplayName();
        }
        return super.getDisplayName();
    }
1043569
private function getTranslationByLocale($locale)
    {
        $attributeValueTranslation = null;

        foreach ($this->entity->getTranslations() as $translation) {
            if ($translation->getLocale() == $locale) {
                $attributeValueTranslation = $translation;
                break;
            }
        }

        return $attributeValueTranslation;
    }
283264
public function getDefaultResourceForLocale( $locale )
    {
        $resource = null;

        if( $this->getValue() && !$this->getValue()->isEmpty() )
        {
            foreach( $this->getValue() as $index => $item )
            {
                if( $item->{$this->getModel()->getLocaleKey()} === $locale )
                {
                    $resource = $item;
                }
            }
        }

        return $resource;
    }
1352910
public SoapFault locale(String locale) {
        LocaleEditor localeEditor = new LocaleEditor();
        localeEditor.setAsText(locale);
        this.locale = (Locale) localeEditor.getValue();
        return this;
    }
1366945
public static Locale toLocale(String localeString)
    {
        if ((localeString == null) || (localeString.length() == 0))
        {
            Locale locale = Locale.getDefault();
            if(log.isLoggable(Level.WARNING))
            {
                log.warning("Locale name in faces-config.xml null or empty, setting locale to default locale : "
                        + locale.toString());
            }
            return locale;
        }

        int separatorCountry = localeString.indexOf('_');
        char separator;
        if (separatorCountry >= 0)
        {
            separator = '_';
        }
        else
        {
            separatorCountry = localeString.indexOf('-');
            separator = '-';
        }

        String language;
        String country;
        String variant;
        if (separatorCountry < 0)
        {
            language = localeString;
            country = "";
            variant = "";
        }
        else
        {
            language = localeString.substring(0, separatorCountry);

            int separatorVariant = localeString.indexOf(separator, separatorCountry + 1);
            if (separatorVariant < 0)
            {
                country = localeString.substring(separatorCountry + 1);
                variant = "";
            }
            else
            {
                country = localeString.substring(separatorCountry + 1, separatorVariant);
                variant = localeString.substring(separatorVariant + 1);
            }
        }

        return new Locale(language, country, variant);
    }
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;
  }
259369
public CLDR.Locale resolve(java.util.Locale javaLocale) {
    MetaLocale meta = MetaLocale.fromJavaLocale(javaLocale);
    return resolve(meta);
  }