List of usage examples for java.util Locale getCountry
public String getCountry()
From source file:com.gammalabs.wifianalyzer.wifi.band.Country.java
Country() { countries = new TreeMap<>(); for (Locale locale : Locale.getAvailableLocales()) { String countryCode = locale.getCountry(); if (StringUtils.isNotEmpty(countryCode) && StringUtils.isAlpha(countryCode) && countryCode.length() == 2) { countries.put(StringUtils.capitalize(countryCode), locale); }//from ww w. jav a 2 s.c o m } }
From source file:de.cosmocode.commons.converter.LocaleCountryIsoConverter.java
@Override public String encode(Locale input) { return toAlpha3(input.getCountry()); }
From source file:ca.sqlpower.dao.session.LocaleConverter.java
@Override public String convertToSimpleType(Locale convertFrom, Object... additionalInfo) { return convertFrom.getLanguage() + SEPARATOR + convertFrom.getCountry() + SEPARATOR + convertFrom.getVariant();/*from www . j a v a2 s . c om*/ }
From source file:com.aqnote.app.wifianalyzer.wifi.band.Country.java
public Country() { countries = new ArrayList<>(); for (Locale locale : Locale.getAvailableLocales()) { String countryCode = locale.getCountry(); if (StringUtils.isNotEmpty(countryCode)) { countries.add(locale);//from ww w . ja v a 2 s. c o m } } Collections.sort(countries, new LocaleCountryComparator()); }
From source file:com.terradue.jcatalogue.client.internal.converters.LocaleConverter.java
public Object convert(@SuppressWarnings("rawtypes") Class type, Object value) { if (value == null) { throw new ConversionException("Null values not supported in this version."); }/*w ww. jav a 2 s .com*/ if (String.class == type) { if (value instanceof Locale) { Locale locale = (Locale) value; return locale.getLanguage() + SEPARATOR + locale.getCountry(); } } else if (Locale.class == type) { if (value instanceof String) { StringTokenizer tokenizer = new StringTokenizer((String) value, SEPARATOR); return new Locale(tokenizer.nextToken(), tokenizer.nextToken()); } } throw new ConversionException(format("type %s and value %s not supported", type, value)); }
From source file:org.apache.cocoon.forms.datatype.convertor.LocaleMap.java
private final String getFullKey(Locale locale) { return locale.getLanguage() + '-' + locale.getCountry() + '-' + locale.getVariant(); }
From source file:cn.vlabs.duckling.vwb.ui.rsi.profile.SiteLanguageService.java
public Object getLanguage(RestSession session, Object message) throws ServiceException { LanguageRequest request = (LanguageRequest) message; VWBContainer container = VWBContainerImpl.findContainer(); String language = container.getSiteConfig().getProperty(request.getSiteId(), KeyConstants.SITE_LANGUAGE); if (StringUtils.isEmpty(language)) { Locale locale = this.getRequest().getLocale(); language = locale.getLanguage() + "_" + locale.getCountry(); }//from ww w .ja v a2s . co m return language; }
From source file:org.dspace.core.I18nUtil.java
/** * Gets the appropriate supported Locale according for a given Locale If * no appropriate supported locale is found, the DEFAULTLOCALE is used * * @param locale/*from w w w . ja va2 s. c o m*/ * Locale to find the corresponding Locale * @return supportedLocale * Locale for session according to locales supported by this DSpace instance as set in dspace.cfg */ public static Locale getSupportedLocale(Locale locale) { Locale[] availableLocales = getSupportedLocales(); boolean isSupported = false; Locale supportedLocale = null; String testLocale = ""; if (availableLocales == null) { supportedLocale = DEFAULTLOCALE; } else { if (!locale.getVariant().equals("")) { testLocale = locale.toString(); for (int i = 0; i < availableLocales.length; i++) { if (testLocale.equalsIgnoreCase(availableLocales[i].toString())) { isSupported = true; supportedLocale = availableLocales[i]; } } } if (!(isSupported && locale.getCountry().equals(""))) { testLocale = locale.getLanguage() + "_" + locale.getCountry(); for (int i = 0; i < availableLocales.length; i++) { if (testLocale.equalsIgnoreCase(availableLocales[i].toString())) { isSupported = true; supportedLocale = availableLocales[i]; } } } if (!isSupported) { testLocale = locale.getLanguage(); for (int i = 0; i < availableLocales.length; i++) { if (testLocale.equalsIgnoreCase(availableLocales[i].toString())) { isSupported = true; supportedLocale = availableLocales[i]; } } } if (!isSupported) { supportedLocale = DEFAULTLOCALE; } } return supportedLocale; }
From source file:countries.ListCountry.java
/** Create Map with country code and languages. */ public void initLanguageMap() { for (Locale locale : getAvailableLocales()) { if (!isBlank(locale.getDisplayCountry())) { languagesOfCountries.put(locale.getCountry(), locale.getLanguage()); }// ww w . j a v a 2s . c om } }
From source file:org.netxilia.api.impl.format.CurrencyFormatter.java
@Override public void init() { if (country != null) { if (country.equals("EUR")) { setLocaleObject(new Locale("fr", "FR", "EUR")); } else {/*from w w w .j a va2 s.c o m*/ Locale setLocale = Locale.getDefault(); for (Locale locale : Locale.getAvailableLocales()) { if (country.equalsIgnoreCase(locale.getCountry())) { setLocale = locale; break; } } setLocaleObject(setLocale); } } else { setLocaleObject(Locale.getDefault()); } }