List of usage examples for java.util Locale getAvailableLocales
public static Locale[] getAvailableLocales()
From source file:jease.cms.web.servlet.JeaseController.java
public void init(FilterConfig config) throws ServletException { contextPath = config.getServletContext().getContextPath(); dispatcher = config.getServletContext().getInitParameter(Names.JEASE_SITE_DISPATCHER); servlets = Pattern.compile(//w ww. ja va 2s . c o m String.format("/(%s).*", config.getServletContext().getInitParameter(Names.JEASE_SITE_SERVLETS))); locales = new HashSet<>(); for (Locale locale : Locale.getAvailableLocales()) { locales.add(locale.getLanguage()); } }
From source file:edu.ku.brc.af.core.SchemaI18NService.java
/** * Only Loads the Locales with empty Country and Variant *//*ww w . j av a 2 s. c o m*/ public static void initializeLocales() { SchemaI18NService srv = getInstance(); if (srv != null) { Vector<Locale> locs = srv.getLocales(); if (locs.size() == 0) { for (Locale locale : Locale.getAvailableLocales()) { if (StringUtils.isNotEmpty(locale.getCountry())) { locs.add(locale); } } Collections.sort(locs, new Comparator<Locale>() { public int compare(Locale o1, Locale o2) { return o1.getDisplayName().compareTo(o2.getDisplayName()); } }); } } }
From source file:com.hypersocket.i18n.I18NServiceImpl.java
@Override public Locale getLocale(String locale) { for (Locale l : Locale.getAvailableLocales()) { if (l.toString().equals(locale)) { return l; }//from w w w. j a v a2s . c o m } if (log.isWarnEnabled()) { log.warn(locale + " is missing"); } return Locale.ENGLISH; }
From source file:org.pentaho.reporting.engine.classic.demo.ancient.demo.internationalisation.LocaleSelectionReportController.java
private KeyedComboBoxModel createLocalesModel() { final KeyedComboBoxModel cn = new KeyedComboBoxModel(); final Locale[] locales = Locale.getAvailableLocales(); for (int i = 0; i < locales.length; i++) { final Locale locale = locales[i]; cn.add(locale, locale.getDisplayName()); }//from w w w .ja v a 2s . c o m cn.setSelectedKey(Locale.getDefault()); return cn; }
From source file:com.mfalaize.ant.LocalizeTask.java
/** * Get the list of available//from ww w . j av a2s . c om * <code>ResourceBundle</code> in the project. * * @return The list of <code>ResourceBundle</code> available in the project * to build. * @throws BuildException when the <code>ResourceBundle</code> cannot be * find. */ private List<ResourceBundle> getAvailableResourceBundles() throws BuildException { List<ResourceBundle> list = new ArrayList<ResourceBundle>(); for (Locale locale : Locale.getAvailableLocales()) { try { ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceBundleBaseName, locale); if (locale.equals(resourceBundle.getLocale())) { list.add(resourceBundle); } else { log(String.format("No resource bundle exists for the locale %s. Continue...", locale.getLanguage()), Project.MSG_VERBOSE); } } catch (Throwable ex) { throw new BuildException(ex); } } return list; }
From source file:pt.webdetails.cdc.plugin.CdcLifeCycleListener.java
private void listCatalogsInLocales() { //Trying to ensure all locales are covered //TODO: explain why are we doing this List<String> configuredLocales = CdcConfig.getConfig().getLocales(); Locale[] locales;/* ww w .ja v a2 s . c o m*/ Locale originalLocale = LocaleHelper.getLocale(); if (configuredLocales.size() == 1 && "all".equals(configuredLocales.get(0))) { locales = Locale.getAvailableLocales(); } else { locales = new Locale[configuredLocales.size()]; for (int i = 0; i < configuredLocales.size(); i++) { String[] splitLocale = configuredLocales.get(i).split("_"); locales[i] = new Locale(splitLocale[0], splitLocale[1]); } } logger.debug("Setting schema cache for " + locales.length + " locales."); IMondrianCatalogService mondrianCatalogService = PentahoSystem.get(IMondrianCatalogService.class, IMondrianCatalogService.class.getSimpleName(), null); for (int i = 0; i < locales.length; i++) { LocaleHelper.setLocale(locales[i]); mondrianCatalogService.listCatalogs(CdcLifeCycleListener.getSessionForCatalogCache(), true); } logger.debug("Reverting to original locale " + originalLocale); LocaleHelper.setLocale(originalLocale); }
From source file:net.rrm.ehour.ui.admin.config.MainConfigBackingBean.java
@SuppressWarnings("UnusedDeclaration") public List<Locale> getAvailableLanguages() { Locale[] locales = Locale.getAvailableLocales(); Map<String, Locale> localeMap = new HashMap<>(); // remove all variants for (Locale locale : locales) { if (isTranslationsOnly() && !ArrayUtils.contains(config.getAvailableTranslations(), locale.getLanguage())) { continue; }//from w ww . ja v a2 s . co m if (localeMap.containsKey(locale.getLanguage()) && locale.getDisplayName().indexOf('(') != -1) { continue; } localeMap.put(locale.getLanguage(), locale); } SortedSet<Locale> localeSet = new TreeSet<>(new LocaleComparator(LocaleComparator.CompareType.LANGUAGE)); for (Locale locale : localeMap.values()) { localeSet.add(locale); } return new ArrayList<>(localeSet); }
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);/*w w w.j av a 2 s . co 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:com.robestone.hudson.compactcolumns.CompactColumnsTest.java
/** * Shows that all locale handling will be okay. *//* w ww . ja va 2 s .c o m*/ public void testNoBadLocale() { Locale[] locales = Locale.getAvailableLocales(); for (Locale locale : locales) { String s = AbstractStatusesColumn.getBuildTimeString(1277416568304L, locale); assertNotNull(s); } }
From source file:net.rrm.ehour.ui.admin.config.MainConfigBackingBean.java
public static List<Locale> getAvailableLocales() { List<Locale> locales = new ArrayList<>(); for (Locale locale : Locale.getAvailableLocales()) { if (!StringUtils.isBlank(locale.getDisplayCountry())) { locales.add(locale);/*from www. j a va 2s .co m*/ } } Collections.sort(locales, new LocaleComparator(LocaleComparator.CompareType.COUNTRY)); return locales; }