List of usage examples for java.util Locale getDisplayName
public String getDisplayName(Locale inLocale)
From source file:org.jahia.taglibs.functions.Functions.java
public static java.lang.String displayLocaleNameWith(Locale localeToDisplay, Locale localeUsedForRendering) { return WordUtils.capitalizeFully(localeToDisplay.getDisplayName(localeUsedForRendering)); }
From source file:com.hack23.cia.service.impl.ConfigurationManagerImpl.java
/** * Gets the supported locales language data. * * @return the supported locales language data *//*from ww w . j a v a2 s .c om*/ private static List<LanguageData> getSupportedLocalesLanguageData() { final List<LanguageData> languages = new ArrayList<>(); for (final Locale locale : SimpleDateFormat.getAvailableLocales()) { if (locale.getDisplayCountry(Locale.ENGLISH).length() == 0 && !StringUtils.isEmpty(locale.toString()) && locale.toString().trim().length() == EXPECTED_LOCALE_LENGTH) { languages.add(new LanguageData().withCreatedDate(new Date()).withLanguageCode(locale.toString()) .withLanguageName(locale.getDisplayName(Locale.ENGLISH)).withLanguageEnabled(false)); } } return languages; }
From source file:org.jahia.utils.LanguageCodeConverters.java
public static List<Locale> getAvailableBundleLocalesSorted(Locale currentLocale) { Map<String, Locale> sortedLocales = new TreeMap<String, Locale>(); for (Locale locale : getAvailableBundleLocales(ResourceBundles.JAHIA_INTERNAL_RESOURCES, null)) { sortedLocales.put(locale.getDisplayName(currentLocale), locale); }//www . ja v a 2 s . co m return new LinkedList<Locale>(sortedLocales.values()); }
From source file:org.jahia.utils.LanguageCodeConverters.java
public static List<Locale> getAvailableBundleLocalesSorted() { Map<String, Locale> sortedLocales = new TreeMap<String, Locale>(); for (Locale locale : getAvailableBundleLocales(ResourceBundles.JAHIA_INTERNAL_RESOURCES, null)) { sortedLocales.put(WordUtils.capitalizeFully(locale.getDisplayName(locale)), locale); }// w w w .j av a 2 s . c o m return new LinkedList<Locale>(sortedLocales.values()); }
From source file:org.itracker.core.resources.ITrackerResources.java
public static String getLocaleNativeName(Locale locale) { try {/*from www . j ava2s . co m*/ return getString(KEY_BASE_LOCALE_NAME, locale); } catch (MissingResourceException e) { return locale.getDisplayName(locale); } }
From source file:org.obiba.opal.web.magma.Dtos.java
public static LocaleDto asDto(Locale locale, @Nullable Locale displayLocale) { LocaleDto.Builder builder = LocaleDto.newBuilder().setName(locale.toString()); if (displayLocale != null) { builder.setDisplay(locale.getDisplayName(displayLocale)); }//from ww w . ja va 2s . co m return builder.build(); }
From source file:org.web4thejob.web.util.ZkUtil.java
private static Combobox getComboLocaleType() { Combobox localebox = new Combobox(); localebox.setReadonly(true);/*from ww w . jav a 2 s. co m*/ localebox.setWidth("65%"); List<Locale> locales = Arrays.asList(Locale.getAvailableLocales()); Collections.sort(locales, new Comparator<Locale>() { private String getDisplayName(Locale locale) { return locale.getDisplayName(CoreUtil.getUserLocale()); } @Override public int compare(Locale o1, Locale o2) { return getDisplayName(o1).compareTo(getDisplayName(o2)); } }); Comboitem comboitem = new Comboitem( "* User locale (" + CoreUtil.getUserLocale().getDisplayName(CoreUtil.getUserLocale()) + ")"); //add the user locale comboitem.setValue(CoreUtil.getUserLocale()); comboitem.setParent(localebox); comboitem = new Comboitem( "** System locale (" + Locale.getDefault().getDisplayName(CoreUtil.getUserLocale()) + ")"); //add the system locale comboitem.setValue(Locale.getDefault()); comboitem.setParent(localebox); for (Locale locale : locales) { comboitem = new Comboitem(locale.getDisplayName(CoreUtil.getUserLocale())); comboitem.setValue(locale); comboitem.setParent(localebox); } comboitem = new Comboitem(""); //add the null locale comboitem.setValue(null); comboitem.setParent(localebox); return localebox; }
From source file:com.michellemay.mappings.DisplayNamesMapping.java
/** * Instantiates a new Display names mapping. * * @param name the name//from ww w . j a v a 2s .c o m * @param displayLocale the display locale */ public DisplayNamesMapping(String name, Locale displayLocale) { super(name); this.displayLocale = displayLocale; // Build reverse map HashMap<String, Locale> map = new HashMap<String, Locale>(); for (String isoCode : Locale.getISOLanguages()) { Locale loc = LocaleUtils.toLocale(isoCode); String displayName = loc.getDisplayName(displayLocale).toLowerCase(); if (isoCode.length() > 0 && !map.containsKey(displayName)) { map.put(displayName, loc); } } this.withMapping(map).withCaseSensitive(false); }
From source file:org.primeframework.mvc.control.form.LocaleSelect.java
/** * Adds the countries Map and then calls super. *///from w ww. j a va 2 s. co m @Override protected Map<String, Object> makeParameters() { LinkedHashMap<String, String> locales = new LinkedHashMap<>(); String preferred = (String) attributes.get("preferredLocales"); if (preferred != null) { String[] parts = preferred.split(","); for (String part : parts) { Locale locale = LocaleUtils.toLocale(part); locales.put(locale.toString(), locale.getDisplayName(locale)); } } boolean includeCountries = attributes.containsKey("includeCountries") ? (Boolean) attributes.get("includeCountries") : true; List<Locale> allLocales = new ArrayList<>(); Collections.addAll(allLocales, Locale.getAvailableLocales()); allLocales.removeIf((locale) -> locale.getLanguage().isEmpty() || locale.hasExtensions() || !locale.getScript().isEmpty() || !locale.getVariant().isEmpty() || (!includeCountries && !locale.getCountry().isEmpty())); allLocales.sort((one, two) -> one.getDisplayName(locale).compareTo(two.getDisplayName(locale))); for (Locale locale : allLocales) { if (!locales.containsKey(locale.getCountry())) { locales.put(locale.toString(), locale.getDisplayName(this.locale)); } } attributes.put("items", locales); return super.makeParameters(); }
From source file:edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionDataGetter.java
private Map<String, Object> buildLocaleMap(Locale locale, Locale currentLocale) throws FileNotFoundException { Map<String, Object> map = new HashMap<>(); map.put("code", locale.toString()); map.put("label", locale.getDisplayName(currentLocale)); map.put("imageUrl", LocaleSelectorUtilities.getImageUrl(vreq, locale)); map.put("selected", currentLocale.equals(locale)); return map;//from w ww. j av a 2 s . co m }