List of usage examples for java.util Locale getDisplayName
public String getDisplayName(Locale inLocale)
From source file:Main.java
public static void main(String[] args) { Locale locale = new Locale("ENGLISH", "US"); System.out.println("Locale:" + locale); // print display name for locale - based on inLocale System.out.println("Name:" + locale.getDisplayName(new Locale("GERMAN", "GERMANY"))); }
From source file:org.jahia.izpack.ResourcesConverter.java
/** * Performs conversion of the property files into XML language packs. * /*www. j a va2 s . com*/ * @param args * @throws FileNotFoundException */ public static void main(String[] args) throws FileNotFoundException { String bundleName = args[0]; String[] locales = args[1].split(","); File targetDir = new File(args[2]); System.out.println("Converting resource bundle " + bundleName + " to XML language packs..."); for (String lc : locales) { Locale currentLocale = new Locale(lc.trim()); System.out.println("...locale " + currentLocale.getDisplayName(Locale.ENGLISH)); convert(bundleName, currentLocale, targetDir); } System.out.println("...converting done."); }
From source file:SimpleMenu.java
/** A simple test program for the above code */ public static void main(String[] args) { // Get the locale: default, or specified on command-line Locale locale; if (args.length == 2) locale = new Locale(args[0], args[1]); else//from w w w .j a v a 2 s.c om locale = Locale.getDefault(); // Get the resource bundle for that Locale. This will throw an // (unchecked) MissingResourceException if no bundle is found. ResourceBundle bundle = ResourceBundle.getBundle("com.davidflanagan.examples.i18n.Menus", locale); // Create a simple GUI window to display the menu with final JFrame f = new JFrame("SimpleMenu: " + // Window title locale.getDisplayName(Locale.getDefault())); JMenuBar menubar = new JMenuBar(); // Create a menubar. f.setJMenuBar(menubar); // Add menubar to window // Define an action listener for that our menu will use. ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { String s = e.getActionCommand(); Component c = f.getContentPane(); if (s.equals("red")) c.setBackground(Color.red); else if (s.equals("green")) c.setBackground(Color.green); else if (s.equals("blue")) c.setBackground(Color.blue); } }; // Now create a menu using our convenience routine with the resource // bundle and action listener we've created JMenu menu = SimpleMenu.create(bundle, "colors", new String[] { "red", "green", "blue" }, listener); // Finally add the menu to the GUI, and pop it up menubar.add(menu); // Add the menu to the menubar f.setSize(300, 150); // Set the window size. f.setVisible(true); // Pop the window up. }
From source file:org.smigo.user.Language.java
public static Map<String, String> getLanguagesForDisplay(Enumeration<Locale> locales, Locale additionalLocale) { SortedMap<String, String> ret = new TreeMap<>(); for (Language t : Language.values()) { ret.put(t.locale.toString(), StringUtils.capitalize(t.locale.getDisplayName(t.locale))); }//from w w w .ja v a 2 s . c o m while (locales.hasMoreElements()) { Locale locale = locales.nextElement(); ret.put(locale.toString(), StringUtils.capitalize(locale.getDisplayName(locale))); } ret.put(additionalLocale.toString(), StringUtils.capitalize(additionalLocale.getDisplayName(additionalLocale))); return ret; }
From source file:util.CreateDocIndexUtil.java
/** * Returns the full locale name for a locale tag. * //from ww w. j a v a 2 s. c o m * @see Locale.getDisplayName(Locale inLocale) * @author Henry Pijffers (henry.pijffers@saxnot.com) * @author Didier Briel */ private static String getLocaleName(String localeTag) { String language = localeTag.substring(0, 2); String name = langExceptionsNames.getProperty(language); if (name == null) { String country = localeTag.length() >= 5 ? localeTag.substring(3, 5) : ""; Locale locale = new Locale(language, country); name = locale.getDisplayName(locale); } return name; }
From source file:org.projectforge.web.wicket.converter.LanguageConverter.java
public static final Locale getLanguage(final String language, final Locale locale) { synchronized (localeMap) { if (localeMap.containsKey(locale) == false) { final Map<String, Locale> m = new HashMap<String, Locale>(); for (final Locale lc : Locale.getAvailableLocales()) { m.put(lc.getDisplayName(locale), lc); }// w ww . java 2 s . c o m localeMap.put(locale, m); } } return localeMap.get(locale).get(language); }
From source file:org.projectforge.web.wicket.converter.LanguageConverter.java
public static final String getLanguageAsString(final Locale language, final Locale locale) { if (language == null) { return ""; }//from ww w.jav a 2s. co m return language.getDisplayName(locale); }
From source file:com.limegroup.gnutella.gui.LanguageUtils.java
/** * Returns an array of supported language as a LanguageInfo[], always having * the English language as the first element. * /*w ww . j a va 2 s .c om*/ * This will only include languages that can be displayed using the given * font. If the font is null, all languages are returned. */ public static Locale[] getLocales(Font font) { final List<Locale> locales = new LinkedList<Locale>(); File jar = FileUtils.getJarFromClasspath(LanguageUtils.class.getClassLoader(), BUNDLE_MARKER); if (jar != null) { addLocalesFromJar(locales, jar); } else { LOG.warn("Could not find bundle jar to determine locales"); } Collections.sort(locales, new Comparator<Locale>() { public int compare(Locale o1, Locale o2) { return o1.getDisplayName(o1).compareToIgnoreCase(o2.getDisplayName(o2)); } }); locales.remove(Locale.ENGLISH); locales.add(0, Locale.ENGLISH); // remove languages that cannot be displayed using this font if (font != null && !OSUtils.isMacOSX()) { for (Iterator<Locale> it = locales.iterator(); it.hasNext();) { Locale locale = it.next(); if (!GUIUtils.canDisplay(font, locale.getDisplayName(locale))) { it.remove(); } } } return locales.toArray(new Locale[0]); }
From source file:org.jahia.ajax.gwt.helper.LanguageHelper.java
/** * Get display name//from w ww . ja va2 s . c o m * * @param langCode * @return */ public static String getDisplayName(String langCode) { if (langCode == null) { return ""; } langCode = Patterns.DASH.matcher(langCode).replaceAll("_"); Locale currentLocale = LanguageCodeConverters.getLocaleFromCode(langCode); return StringUtils.capitalize(currentLocale.getDisplayName(currentLocale)); }
From source file:com.kenshoo.freemarker.view.FreeMarkerOnlineView.java
private static List<SelectionOption> toLocaleSelectionOptions(Map<String, Locale> localeMap) { ArrayList<SelectionOption> selectionOptions = new ArrayList<SelectionOption>(localeMap.size()); for (Map.Entry<String, Locale> ent : localeMap.entrySet()) { Locale locale = ent.getValue(); selectionOptions.add(new SelectionOption(ent.getKey(), truncate(locale.getDisplayName(Locale.US), 18) + "; " + locale.toString())); }/*from w w w. j a va 2 s. c om*/ Collections.sort(selectionOptions); return selectionOptions; }