List of usage examples for java.util Locale toString
@Override public final String toString()
Locale
object, consisting of language, country, variant, script, and extensions as below: language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensionsLanguage is always lower case, country is always upper case, script is always title case, and extensions are always lower case.
From source file:org.apache.wookie.server.LocaleHandler.java
public void showLocales() { for (Locale locale : fLocales) { _logger.debug("locale found:" + locale.toString()); }/*w w w.ja v a2 s . c o m*/ }
From source file:org.craftercms.engine.targeting.impl.LocaleTargetIdManager.java
@Override public String getCurrentTargetId() throws IllegalStateException { Locale currentLocale = LocaleContextHolder.getLocale(); if (currentLocale != null) { return StringUtils.lowerCase(currentLocale.toString()); } else {// w w w . j a v a 2 s . c o m return null; } }
From source file:net.kamhon.ieagle.util.MessageFactory.java
private void setResources(String key, Locale locale) throws SystemErrorException { if (!MESSAGE_RESOURCES.containsKey(key + locale.toString())) { try {/*ww w .j a v a 2 s.co m*/ PropertyResourceBundle bundle = (PropertyResourceBundle) PropertyResourceBundle.getBundle(key, locale); PropertyResourceBundleMorpher morph = new PropertyResourceBundleMorpher(bundle); MESSAGE_RESOURCES.put(key + locale.toString(), morph); } catch (Exception ex) { log.fatal("ERROR SETUP MESSAGE FACTORY!!. APPLICATION FAILURE!!.", ex); throw new SystemErrorException(ex); } } }
From source file:org.b3log.latke.util.Locales.java
/** * Gets locale with the specified request. * <p>/* w w w . j a va2 s .c o m*/ * By the following steps: * <ol> * <li>Gets from session of the specified request</li> * <li>Gets from the specified request header</li> * <li>Using {@link Latkes#getLocale() server configuration}</li> * </ol> * * @param request the specified request * @return locale */ public static Locale getLocale(final HttpServletRequest request) { Locale locale = null; // Gets from session final HttpSession session = request.getSession(false); if (session != null) { locale = (Locale) session.getAttribute(Keys.LOCALE); } if (null == locale) { // Gets from request header final String languageHeader = request.getHeader("Accept-Language"); LOGGER.log(Level.DEBUG, "[Accept-Language={0}]", languageHeader); String language = "zh"; String country = "CN"; if (StringUtils.isNotBlank(languageHeader)) { language = getLanguage(languageHeader); country = getCountry(languageHeader); } locale = new Locale(language, country); if (!hasLocale(locale)) { // Uses default locale = Latkes.getLocale(); LOGGER.log(Level.DEBUG, "Using the default locale[{0}]", locale.toString()); } else { LOGGER.log(Level.DEBUG, "Got locale[{0}] from request.", locale.toString()); } } else { LOGGER.log(Level.DEBUG, "Got locale[{0}] from session.", locale.toString()); } return locale; }
From source file:com.enonic.cms.core.user.field.UserFieldHelper.java
private String formatLocale(Locale value) { return value.toString(); }
From source file:com.hypersocket.i18n.I18NServiceImpl.java
@Override public Locale getLocale(String locale) { for (Locale l : Locale.getAvailableLocales()) { if (l.toString().equals(locale)) { return l; }/*from ww w .j a v a2 s .co m*/ } if (log.isWarnEnabled()) { log.warn(locale + " is missing"); } return Locale.ENGLISH; }
From source file:org.intelligentsia.dowsers.core.serializers.jackson.LocaleJsonSerializer.java
@Override public void serialize(final Locale locale, final JsonGenerator jgen, final SerializerProvider provider) throws IOException, JsonGenerationException { jgen.writeString(locale.toString()); }
From source file:com.anrisoftware.sscontrol.httpd.fudforum.core.LocaleRenderer.java
private String toString(Locale locale, String formatString) { if (StringUtils.equals(formatString, LANGUAGE_KEY)) { return locale.getLanguage(); }//from w w w . j a v a2 s .c o m return locale.toString(); }
From source file:org.shredzone.cilla.core.repository.impl.LanguageDaoHibImpl.java
@Transactional(readOnly = true) @Override/*w ww . j a va 2s .c om*/ public Language fetchForLocale(Locale locale) { return (Language) getCurrentSession().createQuery("FROM Language WHERE locale=:locale") .setParameter("locale", locale.toString()).uniqueResult(); }