List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static ResourceBundle getBundle(String baseName, Module module)
From source file:XMLResourceBundleControl.java
public static void main(String args[]) { ResourceBundle bundle = ResourceBundle.getBundle("Strings", new XMLResourceBundleControl()); String string = bundle.getString("Key"); System.out.println("Key: " + string); }
From source file:XMLResourceBundleControl.java
public static void main(String args[]) { ResourceBundle bundle = ResourceBundle.getBundle("Strings", new XMLResourceBundleControl()); String string = bundle.getString("Key"); System.out.println("Key: " + string); }/*from w w w . j a v a 2 s . c o m*/
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;/*from w w w . j a v a 2 s.c o m*/ if (args.length == 2) locale = new Locale(args[0], args[1]); else 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:edu.ku.brc.specify.config.init.SpecifyDBSetupWizardFrame.java
/** * @param args//from w w w. j a v a 2 s .c om */ public static void main(String[] args) { // Set App Name, MUST be done very first thing! UIRegistry.setAppName("Specify"); //$NON-NLS-1$ try { ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$ } catch (MissingResourceException ex) { Locale.setDefault(Locale.ENGLISH); UIRegistry.setResourceLocale(Locale.ENGLISH); } try { if (!System.getProperty("os.name").equals("Mac OS X")) { UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new DesertBlue()); } } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, e); e.printStackTrace(); } AppBase.processArgs(args); AppBase.setupTeeForStdErrStdOut(true, false); System.setProperty("appdatadir", ".."); // Then set this IconManager.setApplicationClass(Specify.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$ // Load Local Prefs AppPreferences localPrefs = AppPreferences.getLocalPrefs(); //try { //System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+(new File(UIRegistry.getAppDataDir()).getCanonicalPath())+"]"); //} catch (IOException ex) {} localPrefs.setDirPath(UIRegistry.getAppDataDir()); // Check to see if we should check for a new version if (localPrefs.getBoolean(VERSION_CHECK, null) == null) { localPrefs.putBoolean(VERSION_CHECK, true); } if (localPrefs.getBoolean(EXTRA_CHECK, null) == null) { localPrefs.putBoolean(EXTRA_CHECK, true); } if (UIHelper.isLinux()) { Specify.checkForSpecifyAppsRunning(); } if (UIRegistry.isEmbedded()) { ProcessListUtil.checkForMySQLProcesses(new ProcessListener() { @Override public void done(PROC_STATUS status) // called on the UI thread { if (status == PROC_STATUS.eOK || status == PROC_STATUS.eFoundAndKilled) { startupContinuing(); } } }); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { startupContinuing(); } }); } }
From source file:cz.afrosoft.whattoeat.core.gui.I18n.java
public static void init(final String language) { Locale locale = new Locale(language); I18n.resourceBundle = ResourceBundle.getBundle(TEXTS_BUNDLE_NAME, locale); I18n.collator = Collator.getInstance(locale); }
From source file:PropertiesDemo.java
static void displayValue(Locale currentLocale, String key) { ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", currentLocale); String value = labels.getString(key); System.out.println(/*from w ww . j av a 2 s . c o m*/ "Locale = " + currentLocale.toString() + ", " + "key = " + key + ", " + "value = " + value); }
From source file:fr.mael.microrss.util.Tools.java
public static String getMessage(String message, Locale locale) { ResourceBundle bundle = ResourceBundle.getBundle("fr.mael.microrss.i18n.messages", locale); return bundle.getString(message); }
From source file:edu.ku.brc.specify.config.init.secwiz.SpecifyDBSecurityWizardFrame.java
/** * @param args/*from w ww . j av a2 s. co m*/ */ public static void main(String[] args) { // Set App Name, MUST be done very first thing! UIRegistry.setAppName("Specify"); //$NON-NLS-1$ try { ResourceBundle.getBundle("resources", Locale.getDefault()); //$NON-NLS-1$ } catch (MissingResourceException ex) { Locale.setDefault(Locale.ENGLISH); UIRegistry.setResourceLocale(Locale.ENGLISH); } try { if (!System.getProperty("os.name").equals("Mac OS X")) { UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); PlasticLookAndFeel.setPlasticTheme(new DesertBlue()); } } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSecurityWizard.class, e); e.printStackTrace(); } AppBase.processArgs(args); AppBase.setupTeeForStdErrStdOut(true, false); System.setProperty("appdatadir", ".."); SwingUtilities.invokeLater(new Runnable() { public void run() { // Then set this IconManager.setApplicationClass(Specify.class); IconManager.loadIcons(XMLHelper.getConfigDir("icons_datamodel.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_plugins.xml")); //$NON-NLS-1$ IconManager.loadIcons(XMLHelper.getConfigDir("icons_disciplines.xml")); //$NON-NLS-1$ // Load Local Prefs AppPreferences localPrefs = AppPreferences.getLocalPrefs(); //try { //System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+(new File(UIRegistry.getAppDataDir()).getCanonicalPath())+"]"); //} catch (IOException ex) {} localPrefs.setDirPath(UIRegistry.getAppDataDir()); // Check to see if we should check for a new version String VERSION_CHECK = "version_check.auto"; if (localPrefs.getBoolean(VERSION_CHECK, null) == null) { localPrefs.putBoolean(VERSION_CHECK, true); } String EXTRA_CHECK = "extra.check"; if (localPrefs.getBoolean(EXTRA_CHECK, null) == null) { localPrefs.putBoolean(EXTRA_CHECK, true); } if (UIHelper.isLinux()) { Specify.checkForSpecifyAppsRunning(); } if (UIRegistry.isEmbedded()) { checkForMySQLProcesses(); } Specify.setUpSystemProperties(); final SpecifyDBSecurityWizardFrame wizardFrame = new SpecifyDBSecurityWizardFrame(); if (localPrefs.getBoolean(VERSION_CHECK, true) && localPrefs.getBoolean(EXTRA_CHECK, true)) { try { com.install4j.api.launcher.SplashScreen.hide(); ApplicationLauncher.Callback callback = new ApplicationLauncher.Callback() { public void exited(int exitValue) { UIHelper.centerAndShow(wizardFrame); } public void prepareShutdown() { } }; ApplicationLauncher.launchApplication("100", null, true, callback); } catch (Exception ex) { UIHelper.centerAndShow(wizardFrame); } } else { UIHelper.centerAndShow(wizardFrame); } } }); }
From source file:io.bibleget.BibleGetI18N.java
/** * * @param s//from w w w. j a v a2 s . c o m * @return */ public static String __(String s) { lcl = BibleGetIO.getLocale(); Locale myLocale; myLocale = new Locale(lcl); try { myResource = ResourceBundle.getBundle("io.bibleget.resources.messages", myLocale); } catch (MissingResourceException ex) { myResource = ResourceBundle.getBundle("io.bibleget.resources.messages"); } if (myResource.containsKey(s)) { try { String val = myResource.getString(s); return new String(val.getBytes("ISO-8859-1"), "UTF-8"); } catch (UnsupportedEncodingException ex) { Logger.getLogger(BibleGetI18N.class.getName()).log(Level.SEVERE, null, ex); } } else { return s; } return null; }
From source file:ChoiceFormatDemo.java
static void displayMessages(Locale currentLocale) { System.out.println("currentLocale = " + currentLocale.toString()); System.out.println();//www.j a va 2s .c o m ResourceBundle bundle = ResourceBundle.getBundle("ChoiceBundle", currentLocale); MessageFormat messageForm = new MessageFormat(""); messageForm.setLocale(currentLocale); double[] fileLimits = { 0, 1, 2 }; String[] fileStrings = { bundle.getString("noFiles"), bundle.getString("oneFile"), bundle.getString("multipleFiles") }; ChoiceFormat choiceForm = new ChoiceFormat(fileLimits, fileStrings); String pattern = bundle.getString("pattern"); Format[] formats = { choiceForm, null, NumberFormat.getInstance() }; messageForm.applyPattern(pattern); messageForm.setFormats(formats); Object[] messageArguments = { null, "XDisk", null }; for (int numFiles = 0; numFiles < 4; numFiles++) { messageArguments[0] = new Integer(numFiles); messageArguments[2] = new Integer(numFiles); String result = messageForm.format(messageArguments); System.out.println(result); } }