List of usage examples for java.text DateFormat getAvailableLocales
public static Locale[] getAvailableLocales()
get*Instance
methods of this class can return localized instances. From source file:net.sourceforge.ganttproject.gui.options.InterfaceOptionPageProvider.java
private static Pair<Boolean, File> checkLocale(Locale l) { if (Arrays.asList(DateFormat.getAvailableLocales()).contains(l)) { return Pair.create(Boolean.TRUE, null); }/* w w w. j a v a2 s .com*/ File extDir = getExtDir(); if (!extDir.exists()) { return Pair.create(Boolean.FALSE, null); } if (!extDir.isDirectory()) { return Pair.create(Boolean.FALSE, null); } if (extDir.canWrite()) { GPLogger.logToLogger("Java extensions directory " + extDir + " is writable"); URL libUrl = InterfaceOptionPageProvider.class.getResource("lib"); if (libUrl != null) { try { File galicianLocaleJar = new File(new File(libUrl.toURI()), "javagalician.jar"); File targetJar = new File(extDir, galicianLocaleJar.getName()); GPLogger.logToLogger("Locale extension " + galicianLocaleJar); if (galicianLocaleJar.exists() && !targetJar.exists()) { GPLogger.logToLogger("Exists. Installing now"); FileUtils.copyFileToDirectory(galicianLocaleJar, extDir); return Pair.create(Boolean.TRUE, extDir); } } catch (IOException e) { GPLogger.log(e); } catch (URISyntaxException e) { GPLogger.log(e); } } return Pair.create(Boolean.FALSE, extDir); } else { GPLogger.logToLogger("Java extensions directory " + extDir + " is not writable"); } return Pair.create(Boolean.FALSE, extDir); }
From source file:org.ejbca.ui.web.admin.configuration.EjbcaWebBean.java
/** * Uses the language in the Administration GUI to determine which locale is preferred. * /* ww w . ja va2 s . c om*/ * @return the locale of the Admin GUI */ public Locale getLocale() { Locale[] locales = DateFormat.getAvailableLocales(); // TODO: Why not use Locale.getAvailableLocales()? Difference? Locale returnValue = null; String prefered = adminsweblanguage.getAvailableLanguages()[currentadminpreference.getPreferedLanguage()]; String secondary = adminsweblanguage.getAvailableLanguages()[currentadminpreference.getSecondaryLanguage()]; for (int i = 0; i < locales.length; i++) { if (locales[i].getLanguage().equalsIgnoreCase(prefered)) { returnValue = locales[i]; } else if (returnValue == null && locales[i].getLanguage().equalsIgnoreCase(secondary)) { returnValue = locales[i]; } } if (returnValue == null) { returnValue = Locale.US; } return returnValue; }