List of usage examples for java.util Locale getCountry
public String getCountry()
From source file:com.aoindustries.website.signup.ServerConfirmationCompletedActionHelper.java
public static String getHtmlLang(Locale locale) { String language = locale.getLanguage(); if (language != null) { String country = locale.getCountry(); if (country != null) { String variant = locale.getVariant(); if (variant != null) return language + "-" + country + "-" + variant; return language + "-" + country; }//from www . j a v a 2s.com return language; } return null; }
From source file:com.jslsolucoes.tagria.lib.util.TagUtil.java
public static String localization(JspContext jspContext) { Locale locale = locale(jspContext); List<String> fullLocale = Lists.newArrayList(locale.getLanguage()); if (!StringUtils.isEmpty(locale.getCountry())) { fullLocale.add(locale.getCountry()); }/* w w w . jav a 2s.c o m*/ return StringUtils.join(fullLocale, "-"); }
From source file:it.eng.spagobi.commons.utilities.PortletUtilities.java
private static boolean isLocaleSupported(Locale locale) { String defaultLocal = SingletonConfig.getInstance().getConfigValue("SPAGOBI.LANGUAGE_SUPPORTED.LANGUAGES"); String tmp = "[" + locale.getLanguage() + "," + locale.getCountry() + "]"; logger.debug("Check if " + tmp + " is supported"); return defaultLocal.contains(tmp); }
From source file:org.openmrs.ConceptNameTag.java
/** * Method that generates a concept name tag based on a specified locale's country code. * /*from w w w. ja va2 s. com*/ * @param locale * @return Returns the short country Name tag for the specified locale's country. */ public static ConceptNameTag shortCountryTagFor(Locale locale) { return shortCountryTagFor(locale.getCountry()); }
From source file:com.google.android.mms.transaction.HttpUtils.java
private static void addLocaleToHttpAcceptLanguage(StringBuilder builder, Locale locale) { String language = locale.getLanguage(); if (language != null) { builder.append(language);//from w w w . j ava2 s .co m String country = locale.getCountry(); if (country != null) { builder.append("-"); builder.append(country); } } }
From source file:at.porscheinformatik.common.spring.web.extended.util.LocaleUtils.java
public static Locale closestSupportedLocale(List<Locale> supportedLocales, Locale locale) { if (locale == null || supportedLocales == null) { return null; }//from w w w . j a v a 2 s .co m Locale closest = null; int closestMatches = 0; for (Locale l : supportedLocales) { int matches = 0; // If the language does not match no more processing is needed if (ObjectUtils.equals(l.getLanguage(), locale.getLanguage())) { matches++; // if the country does not match no more processing is needed if (ObjectUtils.equals(l.getCountry(), locale.getCountry())) { matches++; if (ObjectUtils.equals(l.getVariant(), locale.getVariant())) { matches++; } } } /* * If language, country and variant match, we have our locale and no * more iteration is needed */ if (matches == 3) { return l; } if (matches > closestMatches) { closestMatches = matches; closest = l; } } return closest; }
From source file:com.limegroup.gnutella.gui.LanguageUtils.java
/** * Returns a score between -1 and 3 how well <code>specificLocale</code> * matches <code>genericLocale</code>. * // ww w .jav a 2s . com * @return -1, if locales do not match, 3 if locales are equal */ public static int getMatchScore(Locale specificLocale, Locale genericLocale) { int i = 0; if (specificLocale.getLanguage().equals(genericLocale.getLanguage())) { i += 1; } else if (genericLocale.getLanguage().length() > 0) { return -1; } if (specificLocale.getCountry().equals(genericLocale.getCountry())) { i += 1; } else if (genericLocale.getCountry().length() > 0) { return -1; } if (specificLocale.getVariant().equals(genericLocale.getVariant())) { i += 1; } else if (genericLocale.getVariant().length() > 0) { return -1; } return i; }
From source file:nl.knaw.dans.common.lang.ResourceLocator.java
private static String getFullPath(final String path, final Locale locale, final String extension) { final StringBuilder sb = new StringBuilder(path); sb.append("_"); sb.append(locale.getLanguage());/* w ww . ja va 2 s.c om*/ sb.append("_"); sb.append(locale.getCountry()); addExtension(extension, sb); return sb.toString(); }
From source file:com.aurel.track.lucene.index.listFields.LocalizedListIndexer.java
/** * Gets the sets with locales having localized strings * @return/*www. ja v a 2 s.c o m*/ */ private static Locale getDefaultLocaleAndLocaleSets(Set<Locale> countrySet, Set<Locale> languageSet) { List<LabelValueBean> localeBeans = LocaleHandler.getPossibleLocales(); Locale defaultLocale = null; for (LabelValueBean localeBean : localeBeans) { String localeString = localeBean.getValue(); Locale locale = LocaleHandler.getLocaleFromString(localeString); if (locale != null) { if ("".equals(localeString)) { defaultLocale = locale; } else { String country = locale.getCountry(); if (country == null || "".equals(country)) { languageSet.add(locale); } else { countrySet.add(locale); } } } } return defaultLocale; }
From source file:com.astamuse.asta4d.util.i18n.LocalizeUtil.java
public static String[] getCandidatePaths(String path, Locale locale) { int dotIndex = path.lastIndexOf("."); String name = dotIndex > 0 ? path.substring(0, dotIndex) : path; String extension = dotIndex > 0 ? path.substring(dotIndex) : StringUtils.EMPTY; List<String> candidatePathList = new ArrayList<>(); if (!StringUtils.isEmpty(locale.getVariant())) { candidatePathList.add(name + '_' + locale.getLanguage() + "_" + locale.getCountry() + "_" + locale.getVariant() + extension); }// ww w . j a v a 2s. c om if (!StringUtils.isEmpty(locale.getCountry())) { candidatePathList.add(name + '_' + locale.getLanguage() + "_" + locale.getCountry() + extension); } if (!StringUtils.isEmpty(locale.getLanguage())) { candidatePathList.add(name + '_' + locale.getLanguage() + extension); } candidatePathList.add(path); return candidatePathList.toArray(new String[candidatePathList.size()]); }