List of usage examples for java.util Locale getCountry
public String getCountry()
From source file:org.pentaho.reporting.engine.classic.core.DefaultReportEnvironment.java
public Object getEnvironmentProperty(final String key) { if ("engine.version".equals(key)) { return ClassicEngineInfo.getInstance().getVersion(); } else if ("engine.version.major".equals(key)) { return ClassicEngineInfo.getInstance().getReleaseMajor(); } else if ("engine.version.minor".equals(key)) { return ClassicEngineInfo.getInstance().getReleaseMinor(); } else if ("engine.version.patch".equals(key)) { return ClassicEngineInfo.getInstance().getReleaseMilestone(); } else if ("engine.version.candidate-token".equals(key)) { return ClassicEngineInfo.getInstance().getReleaseCandidateToken(); } else if ("engine.version.buildnumber".equals(key)) { return ClassicEngineInfo.getInstance().getReleaseBuildNumber(); } else if ("engine.product-id".equals(key)) { return ClassicEngineInfo.getInstance().getProductId(); } else if ("engine.name".equals(key)) { return ClassicEngineInfo.getInstance().getName(); } else if ("locale".equals(key)) { return getLocale().toString(); } else if ("locale-short".equals(key)) { Locale l = getLocale(); if (StringUtils.isEmpty(l.getCountry())) { return l.getLanguage(); }// w w w. j a v a2s . co m return l.getLanguage() + "_" + l.getCountry(); } else if ("locale-language".equals(key)) { return getLocale().getLanguage(); } final String configProperty = configuration.getConfigProperty(ENVIRONMENT_KEY + key); final String configType = configuration.getConfigProperty(ENVIRONMENT_TYPE + key); if (configType == null) { return configProperty; } try { final ClassLoader loader = ObjectUtilities.getClassLoader(DefaultReportEnvironment.class); final Class aClass = Class.forName(configType, false, loader); return ConverterRegistry.toPropertyValue(configProperty, aClass); } catch (Throwable t) { // ignore .. if (logger.isDebugEnabled()) { logger.debug("Failed to convert typed report-environment property"); } } return configProperty; }
From source file:com.swtxml.i18n.ResourceBundleLabelTranslator.java
private List<String> getResourceBundleNames(String baseName, Locale locale) { List<String> results = new ArrayList<String>(4); if (StringUtils.isNotEmpty(locale.getLanguage())) { if (StringUtils.isNotEmpty(locale.getCountry())) { if (StringUtils.isNotEmpty(locale.getVariant())) { results.add(baseName + "_" + locale.getLanguage() + "_" + locale.getCountry() + "_" + locale.getVariant()); }// w ww . ja v a 2 s .c o m results.add(baseName + "_" + locale.getLanguage() + "_" + locale.getCountry()); } results.add(baseName + "_" + locale.getLanguage()); } results.add(baseName); return results; }
From source file:com.cyclopsgroup.waterview.core.DefaultModuleManager.java
/** * Get i18n instance/*w w w . j ava 2s. c om*/ * * @param path Module path * @param locale Locale * @return I18N instance */ synchronized I18N getInternationalization(Path path, Locale locale) { String key = "internationalization/" + locale.getCountry() + "/" + locale.getLanguage() + "/" + path.getFullPath(); I18N loc = null; if (cache.contains(this, key)) { loc = (I18N) cache.get(this, key); } else { List resourceBundles = new ArrayList(); //TODO addBundleToList(resourceBundles, externalBundle, locale); addBundleToList(resourceBundles, path.getPackage() + path.getPathWithoutExtension() + "_ResourceBundle", locale); addBundleToList(resourceBundles, path.getPackage() + "/ResourceBundle", locale); loc = new DefaultI18N(locale, resourceBundles, this); cache.put(this, key, loc); } return loc; }
From source file:nl.strohalm.cyclos.utils.conversion.LocaleConverter.java
public String toString(final Locale locale) { if (locale == null) { return null; }//w ww. j av a 2 s .c om final String variant = locale.getVariant(); if (StringUtils.isEmpty(variant)) { return locale.getLanguage() + "_" + locale.getCountry(); } else { return locale.getLanguage() + "_" + locale.getCountry() + "_" + locale.getVariant(); } }
From source file:org.mifos.framework.util.helpers.LabelTagUtils.java
/** * This helper method returns the user-preferred locale as a Java locale ID string. Note: user-preferred locales are * unimplemented.//from w w w .j a va 2 s. c o m */ public String getUserPreferredLocale(PageContext pageContext) { String userPreferredLocale = null; Locale locale = getUserPreferredLocale(); if (null != locale) { userPreferredLocale = locale.getLanguage() + "_" + locale.getCountry(); } return userPreferredLocale; }
From source file:com.github.mrstampy.gameboot.messages.context.GameBootContextLoader.java
@Override public Map<String, Map<Integer, ResponseContext>> getErrorProperties() throws Exception { Map<String, Map<Integer, ResponseContext>> map = new ConcurrentHashMap<>(); Locale[] locales = Locale.getAvailableLocales(); for (Locale locale : locales) { if (isNotEmpty(locale.getCountry())) { String suffix = "_" + locale.getLanguage() + "_" + locale.getCountry(); addToMap(map, suffix);//from w ww .j a va 2s . c o m } String suffix = "_" + locale.getLanguage(); addToMap(map, suffix); } additionalLocales.forEach(suffix -> { try { addToMap(map, suffix); } catch (Exception e) { log.error("Unexpected exception", e); } }); Map<Integer, ResponseContext> root = getForLocale(GameBootContextLookup.ROOT); if (root == null) throw new IllegalStateException("No error.properties file"); map.put(GameBootContextLookup.ROOT, root); return map; }
From source file:org.esco.web.servlet.ServerNameLocaleResolverAdaptor.java
@Override public void setLocale(final HttpServletRequest request, final HttpServletResponse response, final Locale locale) { // Add the server name variant to the locale final String serverName = request.getServerName(); Locale variantLocale = new Locale(locale.getLanguage(), locale.getCountry(), serverName); request.setAttribute(LOCALE_ATTRIBUTE_KEY, variantLocale); if (this.storeLocaleInSession) { // Store the locale in session request.getSession().setAttribute(LOCALE_ATTRIBUTE_KEY, variantLocale); }/*from w w w . ja va2 s . c o m*/ }
From source file:org.marketcetera.util.ws.wrappers.MarshalledLocale.java
/** * Creates a new marshalled form for the locale given in its raw * form./* w w w .j a v a 2 s. c o m*/ * * @param locale The locale, which may be null. */ public MarshalledLocale(Locale locale) { if (locale == null) { return; } setLanguage(locale.getLanguage()); setCountry(locale.getCountry()); setVariant(locale.getVariant()); }
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 w w w . jav a2s . c om*/ } } return name; }
From source file:griffon.plugins.i18n.ExtendedResourceBundleMessageSource.java
@Override protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException { resolver();/*from w w w . j av a 2s . c o m*/ List<ResourceBundle> bundles = new ArrayList<ResourceBundle>(); bundles.addAll(loadBundleForFilename(basename + "_" + locale.getLanguage() + "_" + locale.getCountry())); bundles.addAll(loadBundleForFilename(basename + "_" + locale.getLanguage())); bundles.addAll(loadBundleForFilename(basename)); return new CompositeResourceBundle(bundles.toArray(new ResourceBundle[bundles.size()])); }