Tabnine Logo
ResourceBundle
Code IndexAdd Tabnine to your IDE (free)

How to use
ResourceBundle
in
java.util

Best Java code snippets using java.util.ResourceBundle (Showing top 20 results out of 24,435)

Refine searchRefine arrow

  • MessageFormat
  • Locale
  • NbBundle
  • MissingResourceException
  • AccessibleContext
  • Mnemonics
  • JButton
  • DialogDisplayer
origin: lets-blade/blade

  public String format(String key,String ... params) {
    return MessageFormat.format(resourceBundle.getString(key),params);
  }
}
origin: xalan/xalan

   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, "");
origin: SonarSource/sonarqube

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
 }
}
origin: jenkinsci/jenkins

/**
 * 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;
  }
}
origin: SonarSource/sonarqube

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;
}
origin: spring-projects/spring-framework

/**
 * 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);
}
origin: checkstyle/checkstyle

/**
 * 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);
}
origin: javax.el/javax.el-api

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);
origin: org.netbeans.api/org-openide-util

if (throwex) {
  throw new IllegalArgumentException(
    MessageFormat.format(
      NbBundle.getBundle(MapFormat.class).getString("MSG_FMT_ObjectForKey"),
      new Object[] { new Integer(key) }
origin: igniterealtime/Openfire

value = bundle.getString(key);
  MessageFormat messageFormat = new MessageFormat("");
  messageFormat.setLocale(bundle.getLocale());
  messageFormat.applyPattern(value);
  try {
    + " in locale " + locale.toString());
value = "";
origin: spring-projects/spring-framework

@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"));
origin: wildfly/wildfly

  private static ResourceBundle getResourceBundle(Locale locale) {
    if (locale == null) {
      locale = Locale.getDefault();
    }
    return ResourceBundle.getBundle(RESOURCE_NAME, locale);
  }
}
origin: languagetool-org/languagetool

/**
 * 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);
}
origin: org.netbeans.modules/org-netbeans-modules-web-jsf

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();
}
origin: org.jboss.jbossas/jboss-as-profileservice

public DeploymentManagerImpl()
{
 currentLocale = Locale.getDefault();
 formatter.setLocale(currentLocale);
 i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
}
origin: org.netbeans.modules/org-netbeans-modules-web-core

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;
}
origin: org.netbeans.api/org-openide-awt

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"));
origin: dcaoyuan/nbscala

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"));
origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders

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;
}
origin: robovm/robovm

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);
java.utilResourceBundle

Javadoc

ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specific resources. A bundle contains a number of named resources, where the names are Strings. A bundle may have a parent bundle, and when a resource is not found in a bundle, the parent bundle is searched for the resource. If the fallback mechanism reaches the base bundle and still can't find the resource it throws a MissingResourceException.
  • All bundles for the same group of resources share a common base bundle. This base bundle acts as the root and is the last fallback in case none of its children was able to respond to a request.
  • The first level contains changes between different languages. Only the differences between a language and the language of the base bundle need to be handled by a language-specific ResourceBundle.
  • The second level contains changes between different countries that use the same language. Only the differences between a country and the country of the language bundle need to be handled by a country-specific ResourceBundle.
  • The third level contains changes that don't have a geographic reason (e.g. changes that where made at some point in time like PREEURO where the currency of come countries changed. The country bundle would return the current currency (Euro) and the PREEURO variant bundle would return the old currency (e.g. DM for Germany).
Examples
  • BaseName (base bundle)
  • BaseName_de (german language bundle)
  • BaseName_fr (french language bundle)
  • BaseName_de_DE (bundle with Germany specific resources in german)
  • BaseName_de_CH (bundle with Switzerland specific resources in german)
  • BaseName_fr_CH (bundle with Switzerland specific resources in french)
  • BaseName_de_DE_PREEURO (bundle with Germany specific resources in german of the time before the Euro)
  • BaseName_fr_FR_PREEURO (bundle with France specific resources in french of the time before the Euro)
It's also possible to create variants for languages or countries. This can be done by just skipping the country or language abbreviation: BaseName_us__POSIX or BaseName__DE_PREEURO. But it's not allowed to circumvent both language and country: BaseName___VARIANT is illegal.

Most used methods

  • getString
    Gets a string for the given key from this resource bundle or one of its parents. Calling this method
  • getBundle
    Returns a resource bundle using the specified base name, the default locale and the specified contro
  • getKeys
    Returns an enumeration of the keys.
  • getObject
    Gets an object for the given key from this resource bundle or one of its parents. This method first
  • getLocale
    Returns the locale of this resource bundle. This method can be used after a call to getBundle() to d
  • containsKey
    Determines whether the given key is contained in this ResourceBundle or its parent bundles.
  • keySet
    Returns a Set of all keys contained in thisResourceBundle and its parent bundles.
  • clearCache
    Removes all resource bundles from the cache that have been loaded using the given class loader.
  • setParent
    Sets the parent bundle of this bundle. The parent bundle is searched by #getObjectwhen this bundle d
  • getStringArray
    Gets a string array for the given key from this resource bundle or one of its parents. Calling this
  • handleGetObject
    Gets an object for the given key from this resource bundle. Returns null if this resource bundle doe
  • getLoader
  • handleGetObject,
  • getLoader,
  • getLoaderCache,
  • handleGetBundle,
  • missingResourceException,
  • processGetBundle,
  • setLocale,
  • strip,
  • getBaseBundleName,
  • <init>

Popular in Java

  • Finding current android device location
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • Menu (java.awt)
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Reference (javax.naming)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now