throws MissingResourceException Locale locale = Locale.getDefault(); return (ListResourceBundle)ResourceBundle.getBundle(className, locale); return (ListResourceBundle)ResourceBundle.getBundle( className, new Locale("en", "US")); throw new MissingResourceException( "Could not load any resource bundles." + className, className, "");
protected void initPlugin(String pluginKey) { try { String bundleKey = BUNDLE_PACKAGE + pluginKey; ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control); Enumeration<String> keys = bundle.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); propertyToBundles.put(key, bundleKey); } } catch (MissingResourceException e) { // ignore } }
/** * Gets a human readable message for the given Win32 error code. * * @return * null if no such message is available. */ @CheckForNull public static String getWin32ErrorMessage(int n) { try { ResourceBundle rb = ResourceBundle.getBundle("/hudson/win32errors"); return rb.getString("error"+n); } catch (MissingResourceException e) { LOGGER.log(Level.WARNING,"Failed to find resource bundle",e); return null; } }
public Locale getEffectiveLocale(Locale locale) { Locale bundleLocale = ResourceBundle.getBundle(BUNDLE_PACKAGE + "core", locale, this.classloader, this.control).getLocale(); locale.getISO3Language(); return bundleLocale.getLanguage().isEmpty() ? Locale.ENGLISH : bundleLocale; }
/** * Register bean definitions contained in a ResourceBundle. * <p>Similar syntax as for a Map. This method is useful to enable * standard Java internationalization support. * @param rb the ResourceBundle to load from * @param prefix a filter within the keys in the map: e.g. 'beans.' * (can be empty or {@code null}) * @return the number of bean definitions found * @throws BeanDefinitionStoreException in case of loading or parsing errors */ public int registerBeanDefinitions(ResourceBundle rb, @Nullable String prefix) throws BeanDefinitionStoreException { // Simply create a map and call overloaded method. Map<String, Object> map = new HashMap<>(); Enumeration<String> keys = rb.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); map.put(key, rb.getObject(key)); } return registerBeanDefinitions(map, prefix); }
/** * Gets the check message 'as is' from appropriate 'messages.properties' * file. * * @param messageBundle the bundle name. * @param messageKey the key of message in 'messages.properties' file. * @param arguments the arguments of message in 'messages.properties' file. * @return The message of the check with the arguments applied. */ private static String internalGetCheckMessage( String messageBundle, String messageKey, Object... arguments) { final ResourceBundle resourceBundle = ResourceBundle.getBundle( messageBundle, Locale.getDefault(), Thread.currentThread().getContextClassLoader(), new LocalizedMessage.Utf8Control()); final String pattern = resourceBundle.getString(messageKey); final MessageFormat formatter = new MessageFormat(pattern, Locale.ROOT); return formatter.format(arguments); }
locale = Locale.getDefault(); ResourceBundle rb = null; if (null == (rb = (ResourceBundle) threadMap.get(locale.toString()))) { rb = ResourceBundle.getBundle("javax.el.PrivateMessages", locale); threadMap.put(locale.toString(), rb); result = rb.getString(messageId); if (null != params) { result = MessageFormat.format(result, params);
value = bundle.getString(key); MessageFormat messageFormat = new MessageFormat(""); messageFormat.setLocale(bundle.getLocale()); messageFormat.applyPattern(value); try { + " in locale " + locale.toString()); value = "";
@Test public void testInternalResourceViewResolverWithJstlAndContextParam() throws Exception { Locale locale = !Locale.GERMAN.equals(Locale.getDefault()) ? Locale.GERMAN : Locale.FRENCH; vr.setApplicationContext(wac); View view = vr.resolveViewName("example1", Locale.getDefault()); assertEquals("Correct view class", JstlView.class, view.getClass()); assertEquals("Correct URL", "example1", ((JstlView) view).getUrl()); assertEquals("message1", lc.getResourceBundle().getString("code1")); assertEquals("message2", lc.getResourceBundle().getString("code2"));
private static ResourceBundle getResourceBundle(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } return ResourceBundle.getBundle(RESOURCE_NAME, locale); } }
/** * Translate a text string based on our i18n files. * @since 3.1 */ public static String i18n(ResourceBundle messages, String key, Object... messageArguments) { MessageFormat formatter = new MessageFormat(""); formatter.applyPattern(messages.getString(key).replaceAll("'", "''")); return formatter.format(messageArguments); }
public FileObject showDialog() { JButton[] options = new JButton[]{ new JButton(NbBundle.getMessage(BrowseFolders.class, "LBL_SelectFile")), // NOI18N new JButton(NbBundle.getMessage(BrowseFolders.class, "LBL_Cancel")), // NOI18N }; OptionsListener optionsListener = new OptionsListener(this); options[0].setActionCommand(OptionsListener.COMMAND_SELECT); options[0].addActionListener(optionsListener); options[0].getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/dialogs/Bundle").getString("ACSD_SelectFile")); options[1].setActionCommand(OptionsListener.COMMAND_CANCEL); options[1].addActionListener(optionsListener); options[1].getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/dialogs/Bundle").getString("ACSD_Cancel")); DialogDescriptor dialogDescriptor = new DialogDescriptor( this, // innerPane NbBundle.getMessage(BrowseFolders.class, "LBL_BrowseFiles"), // displayName true, // modal options, // options options[ 0], // initial value DialogDescriptor.BOTTOM_ALIGN, // options align null, // helpCtx null); // listener dialogDescriptor.setClosingOptions(new Object[]{options[0], options[1]}); Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor); dialog.setVisible(true); return optionsListener.getResult(); }
public DeploymentManagerImpl() { currentLocale = Locale.getDefault(); formatter.setLocale(currentLocale); i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale); }
public boolean showDialog() { dialogOK = false; String displayName = ""; // NOI18N try { displayName = NbBundle.getBundle("org.netbeans.modules.web.core.palette.items.resources.Bundle").getString("NAME_jsp-GetProperty"); // NOI18N } catch (Exception e) { Exceptions.printStackTrace(e); } descriptor = new DialogDescriptor(this, NbBundle.getMessage(GetPropertyCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, new ActionListener() { // NOI18N public void actionPerformed(ActionEvent e) { if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { evaluateInput(); dialogOK = true; } dialog.dispose(); } }); dialog = DialogDisplayer.getDefault().createDialog(descriptor); dialog.setVisible(true); repaint(); return dialogOK; }
private void initAccessible() { if (nameFormat == null) { ResourceBundle bundle = NbBundle.getBundle(SplittedPanel.class); nameFormat = new MessageFormat(bundle.getString("ACS_SplittedPanel_Name")); getAccessibleContext().setAccessibleName( nameFormat.format( new Object[] { ((firstComponent == null) || !(firstComponent instanceof Accessible)) ? null : firstComponent.getAccessibleContext() .getAccessibleName(), ((secondComponent == null) || !(secondComponent instanceof Accessible)) ? null : secondComponent.getAccessibleContext() .getAccessibleName() ResourceBundle bundle = NbBundle.getBundle(SplittedPanel.class); descriptionFormat = new MessageFormat(bundle.getString("ACS_SplittedPanel_Description"));
getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(MainClassChooser.class).getString("AD_MainClassChooser")); jLabel1.setLabelFor(jMainClassList); org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getBundle(MainClassChooser.class).getString("CTL_AvaialableMainClasses")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; jMainClassList.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(MainClassChooser.class).getString("AD_jMainClassList"));
public String getDisplayName () { if (format == null) { format = new MessageFormat (NbBundle.getBundle (DataShadow.class).getString ("FMT_shadowName")); } String n = format.format (createArguments ()); try { obj.getPrimaryFile().getFileSystem().getStatus().annotateName(n, obj.files()); } catch (FileStateInvalidException fsie) { // ignore } return n; }
if (cl != null) { try { return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl); } catch (MissingResourceException ignored) { if (cl != null) { try { return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl); } catch (MissingResourceException ignored) { throw new MissingResourceException("Failed to load the specified resource bundle \"" + resourceBundleName + "\"", resourceBundleName, null);