Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5086301

ResourceBundle.getBundle("...", locale) locale is ignored

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs



      Name: gm110360 Date: 08/12/2004


      FULL PRODUCT VERSION :
      1.4.2_04-b05

      ADDITIONAL OS VERSION INFORMATION :
      Linux frodo 2.4.22-xfs #1 SMP Fr Sep 19 17:55:45 CEST 2003 i686 GNU/Linux
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Locale is ignored in ResourceBundle. Fallback to Locale.getDefault()

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create two resource bundles, e.g. one german ("messages_de.properties") and one default ("messages.properties")
      2. Create a simple Applet, fetch a ResourceBundle through ResourceBundle.getBundle("messages", Locale.ENGLISH)
      3. Set your system locale to german, e.g. export LANG=de_DE, Windows use the system preferences
      4. Displaying a string from a resourceBundle.getString(...)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The result I should get is the english string, because I aquired the resourcebundle with a english locale.
      ACTUAL -
      I get the german string. (the system default instead of the language specified through the locale argument).

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.applet.Applet;
      import java.util.Locale;
      import java.util.ResourceBundle;

      import javax.swing.JLabel;

      public class MyApplet extends Applet {
          private ResourceBundle bundle;
          public MyApplet() {
              bundle = ResourceBundle.getBundle("messages", Locale.ENGLISH);
          }
          public void init() {
              add(new JLabel(bundle.getString("testString")));
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Provide a property-file for each language you want to support. The default does not work reliable.
      (Incident Review ID: 265333)
      ======================================================================

            okutsu Masayoshi Okutsu
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: