List of usage examples for org.apache.commons.lang LocaleUtils toLocale
public static Locale toLocale(String str)
Converts a String to a Locale.
This method takes the string format of a locale and creates the locale object from it.
LocaleUtils.toLocale("en") = new Locale("en", "") LocaleUtils.toLocale("en_GB") = new Locale("en", "GB") LocaleUtils.toLocale("en_GB_xxx") = new Locale("en", "GB", "xxx") (#)
(#) The behaviour of the JDK variant constructor changed between JDK1.3 and JDK1.4.
From source file:de.hybris.platform.secureportaladdon.cockpit.label.CMSSiteLabelProvider.java
@Override protected String getItemLabel(final CMSSiteModel cmsSite, final String languageIso) { return StringUtils.trimToEmpty(cmsSite.getName(LocaleUtils.toLocale(languageIso))); }
From source file:com.haulmont.cuba.core.sys.AvailableLocalesFactory.java
@Override public Object build(String string) { if (string == null) return null; return Arrays.stream(string.split(";")).map(item -> item.split("\\|")) .collect(Collectors.toMap(parts -> parts[0], parts -> LocaleUtils.toLocale(parts[1]))); }
From source file:com.fredhopper.connector.index.TestLocale.java
@Test public void test() { final String lang = "de_DE"; final Locale loc = new Locale(lang); System.out.println(loc.GERMANY); System.out.println(loc);//from www . j a va 2s . c om final Locale loc2 = LocaleUtils.toLocale(lang); System.out.println(loc2); }
From source file:com.switchfly.inputvalidation.sanitizer.LocaleCodeSanitizer.java
@Override public String execute(String content) { if (StringUtils.isBlank(content)) { return content; }//from www.ja v a 2 s .co m Locale locale; try { locale = LocaleUtils.toLocale(content); } catch (Exception e) { return getDefaultLocale(content); } if (!Arrays.asList(Locale.getAvailableLocales()).contains(locale)) { return getDefaultLocale(content); } return locale.toString(); }
From source file:de.hybris.platform.commercefacades.storesession.converters.populator.LanguagePopulator.java
protected Locale toLocale(final LanguageModel source) { return LocaleUtils.toLocale(source.getIsocode()); }
From source file:dk.i2m.jsf.converters.LocaleConverter.java
public Object getAsObject(FacesContext ctx, UIComponent comp, String value) throws ConverterException { System.out.println("GEtting Locale as object: " + value); String localeValue = value.replaceAll("-", "_"); Locale locale = LocaleUtils.toLocale(localeValue); return locale; }
From source file:com.nabla.wapp.server.general.UserSession.java
public UserSession(final Integer userId, boolean isRoot, final String locale) { this.userId = userId; this.isRoot = isRoot; try {/*from w w w . jav a2 s. c om*/ this.locale = LocaleUtils.toLocale(locale); } catch (IllegalArgumentException __) { if (log.isErrorEnabled()) log.error("unsupported locale '" + locale + "'"); this.locale = Locale.UK; } this.sessionId = UUID.randomUUID().toString(); }
From source file:de.Keyle.MyPet.util.locale.Locales.java
public static String getString(String key, String localeString) { localeString = Util.cutString(localeString, 2); LocaleUtils.toLocale(localeString); if (latestMyPetLocales == null) { return key; }//from www. j av a 2s . c o m return latestMyPetLocales.getText(key, localeString); }
From source file:com.opoopress.maven.plugins.plugin.InitMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (skipInit) { getLog().info("Skiping initialize site."); return;//from w w w . j av a 2 s .c o m } Locale loc = null; if (StringUtils.isNotEmpty(locale)) { loc = LocaleUtils.toLocale(locale); } try { siteManager.initialize(baseDirectory, loc); } catch (Exception e) { throw new MojoFailureException(e.getMessage(), e); } }
From source file:edu.jhuapl.openessence.i18n.SupportedLocale.java
public Locale toLocale() { // org.springframework.util.StringUtils.parseLocaleString also works return LocaleUtils.toLocale(code); }