JDK-5086301 : ResourceBundle.getBundle("...", locale) locale is ignored
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-08-12
  • Updated: 2004-08-16
  • Resolved: 2004-08-16
Related Reports
Duplicate :  
Description

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) 
======================================================================

Comments
EVALUATION Under the current ResourceBundle.getBundle, it's a spec to fall back to the default Locale to look up a ResourceBundle. We have a number of requests to be able to specify application's own fallback path. Closing this bug report as a duplicate of 4303146. ###@###.### 2004-08-16
16-08-2004