List of usage examples for java.util Locale getVariant
public String getVariant()
From source file:org.apache.struts.tiles.TestTilesPlugin.java
/** * String representation of a Locale. A bug in the * Locale.toString() method results in Locales with * just a variant being incorrectly displayed. *//* w ww . j a v a 2 s. c o m*/ private String print(Locale locale) { return locale.getLanguage() + "_" + locale.getCountry() + "_" + locale.getVariant(); }
From source file:com.enonic.cms.business.localization.resource.LocalizationResourceBundleServiceImpl.java
private LocalizationResourceBundle createResourceBundle(Locale locale, ResourceKey defaultLocalizationResourceKey) { Properties props = new Properties(); String lang = locale.getLanguage(); String country = locale.getCountry(); String variant = locale.getVariant(); props.putAll(loadBundle(defaultLocalizationResourceKey, "")); if (StringUtils.isNotEmpty(lang)) { lang = lang.toLowerCase();//from w ww . j a v a 2 s .co m props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang)); } if (StringUtils.isNotEmpty(country)) { country = country.toLowerCase(); props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang + "_" + country)); } if (StringUtils.isNotEmpty(variant)) { variant = variant.toLowerCase(); props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang + "_" + country + "_" + variant)); } return new LocalizationResourceBundle(props); }
From source file:org.openengsb.core.api.l10n.BundleStrings.java
private String buildEntryFilename(Locale locale) { String name = ""; if (!locale.getLanguage().isEmpty()) { name += '_' + locale.getLanguage(); if (!locale.getCountry().isEmpty()) { name += '_' + locale.getCountry(); if (!locale.getVariant().isEmpty()) { name += '_' + locale.getVariant(); }/*from www. j a va 2 s .co m*/ } } return name; }
From source file:com.enonic.cms.core.localization.LocalizationResourceBundleServiceImpl.java
private LocalizationResourceBundle createResourceBundle(final Locale locale, final ResourceKey defaultLocalizationResourceKey) { Properties props = new Properties(); String lang = locale.getLanguage(); String country = locale.getCountry(); String variant = locale.getVariant(); props.putAll(loadBundle(defaultLocalizationResourceKey, "")); if (StringUtils.isNotEmpty(lang)) { lang = lang.toLowerCase();/*w w w .j a va2 s.c om*/ props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang)); } if (StringUtils.isNotEmpty(country)) { country = country.toLowerCase(); props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang + "_" + country)); } if (StringUtils.isNotEmpty(variant)) { variant = variant.toLowerCase(); props.putAll(loadBundle(defaultLocalizationResourceKey, "_" + lang + "_" + country + "_" + variant)); } return new LocalizationResourceBundle(props); }
From source file:org.fao.gast.gui.GuiBuilder.java
private ResourceBundle lookupResourceBundle(URL guiSpec, Locale locale) throws IOException { String[] parts = { locale.getLanguage(), locale.getCountry(), locale.getVariant() }; String baseString = guiSpec.toExternalForm(); if (baseString.indexOf('.') > 0) { baseString = baseString.substring(0, baseString.lastIndexOf(".")); }/*from w w w. j a v a 2s . c o m*/ for (int i = parts.length; i >= 0; i--) { ResourceBundle bundle = locateResourceBundleFile(baseString, parts, i); if (bundle != null) { return bundle; } } throw new IllegalStateException("Unable to find gui.xml file"); }
From source file:org.squale.welcom.addons.message.MessageResourcesAddons.java
/** * Get the parent Locale. e.g. en_US will return en * /* ww w. j a v a 2 s . c o m*/ * @param currentLocale : Locale courante * @return locale */ private Locale getParentLocale(final Locale currentLocale) { Locale theReturnLocale = null; if (null == currentLocale) { theReturnLocale = null; } else if (!currentLocale.getVariant().equals("")) { theReturnLocale = new Locale(currentLocale.getLanguage(), currentLocale.getCountry()); } else if (!currentLocale.getCountry().equals("")) { theReturnLocale = new Locale(currentLocale.getLanguage(), ""); } return theReturnLocale; }
From source file:org.lockss.util.TestMetadataUtil.java
void assertLocale(String lang, String country, String variant, Locale l) { assertEquals("Language", lang, l.getLanguage()); assertEquals("Country", country, l.getCountry()); assertEquals("Variant", variant, l.getVariant()); }
From source file:net.technicpack.launcher.lang.ResourceLoader.java
private String getCodeFromLocale(Locale locale) { if (locale.getLanguage().isEmpty()) { return "default"; } else if (locale.getCountry().isEmpty()) { return locale.getLanguage(); } else if (locale.getVariant().isEmpty()) { return String.format("%s,%s", locale.getLanguage(), locale.getCountry()); } else {/*w w w .j av a2 s . c om*/ return String.format("%s,%s,%s", locale.getLanguage(), locale.getCountry(), locale.getVariant()); } }
From source file:com.processpuzzle.internalization.domain.ProcessPuzzleLocale.java
public int hashCode() { Locale javaLocale = getJavaLocale(); return new HashCodeBuilder().append(javaLocale.getLanguage()).append(javaLocale.getCountry()) .append(javaLocale.getVariant()).toHashCode(); }
From source file:com.evolveum.midpoint.web.component.menu.top.LocaleDescriptor.java
@Override public int compareTo(LocaleDescriptor o) { if (o == null) { return 0; }// www. ja v a 2 s. c o m Locale other = o.getLocale(); int val = compareStrings(locale.getCountry(), other.getCountry()); if (val != 0) { return val; } val = compareStrings(locale.getLanguage(), other.getLanguage()); if (val != 0) { return val; } val = compareStrings(locale.getVariant(), other.getVariant()); if (val != 0) { return val; } return 0; }