-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0, 5.0
-
b38
-
generic, x86
-
generic, windows_xp
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Widows XP Pro / sp1
A DESCRIPTION OF THE PROBLEM :
When the default locale is the same language (but different country code) as the requested locale for a call to ResourceBundle.getBundle(), and a bundle exists for the default locale, the default bundle will NOT be chosen. Instead the root bundle will be chosen.
Example:
If my default locale is en_US and I have the following bundles:
MessagesBundle.properties
MessagesBundle_en_US.properties
and if I try to retrieve a bundle using the Locale.UK (en_GB), I will get back the MessagesBundle.properties bundle, NOT the MessagesBundle_en_US.properties bundle.
I would expect that if I have a bundle that matches the default locale and I try to retrieve a bundle with a locale that I DO NOT have a bundle for, then the default bundle will be retrieved, and not the Root bundle. (see Steps to Reproduce for example program)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Setup the following bundles:
MessagesBundle_en_US.properties:
greetings = Hello.
farewell = Goodbye.
inquiry = How are you?
MessagesBundle.properties:
greetings = Hiya.
farewell = Seeya.
inquiry = How you doing?
Use the following Java class:
import java.util.*;
public class RBSample {
static public void main(String[] args) {
String language;
String country;
Locale.setDefault(new Locale("en", "US"));
List<Locale> localeList = new ArrayList<Locale>();
localeList.add(Locale.UK);
localeList.add(Locale.KOREA);
Locale currentLocale;
ResourceBundle messages;
Iterator<Locale> iter = localeList.iterator();
while (iter.hasNext()){
currentLocale = iter.next();
System.out.println("\ncurrentLocale = "
+ currentLocale.getDisplayName());
messages =
ResourceBundle.getBundle("MessagesBundle",currentLocale);
Locale messagesLocale = messages.getLocale();
System.out.println("messagesLocale = "
+ messagesLocale.getDisplayName());
System.out.println(messages.getString("greetings"));
System.out.println(messages.getString("inquiry"));
System.out.println(messages.getString("farewell"));
}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the following output:
currentLocale = English (United Kingdom)
messagesLocale = English (United States)
Hello.
How are you?
Goodbye.
currentLocale = Korean (South Korea)
messagesLocale = English (United States)
Hello.
How are you?
Goodbye.
ACTUAL -
[The system is using the root MessagesBundle.properties, not the default MessagesBundle_en_US.properties.]
currentLocale = English (United Kingdom)
messagesLocale =
Hiya.
How you doing?
Seeya.
currentLocale = Korean (South Korea)
messagesLocale = English (United States)
Hello.
How are you?
Goodbye.
REPRODUCIBILITY :
This bug can be reproduced always.
###@###.### 11/4/04 18:34 GMT
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Widows XP Pro / sp1
A DESCRIPTION OF THE PROBLEM :
When the default locale is the same language (but different country code) as the requested locale for a call to ResourceBundle.getBundle(), and a bundle exists for the default locale, the default bundle will NOT be chosen. Instead the root bundle will be chosen.
Example:
If my default locale is en_US and I have the following bundles:
MessagesBundle.properties
MessagesBundle_en_US.properties
and if I try to retrieve a bundle using the Locale.UK (en_GB), I will get back the MessagesBundle.properties bundle, NOT the MessagesBundle_en_US.properties bundle.
I would expect that if I have a bundle that matches the default locale and I try to retrieve a bundle with a locale that I DO NOT have a bundle for, then the default bundle will be retrieved, and not the Root bundle. (see Steps to Reproduce for example program)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Setup the following bundles:
MessagesBundle_en_US.properties:
greetings = Hello.
farewell = Goodbye.
inquiry = How are you?
MessagesBundle.properties:
greetings = Hiya.
farewell = Seeya.
inquiry = How you doing?
Use the following Java class:
import java.util.*;
public class RBSample {
static public void main(String[] args) {
String language;
String country;
Locale.setDefault(new Locale("en", "US"));
List<Locale> localeList = new ArrayList<Locale>();
localeList.add(Locale.UK);
localeList.add(Locale.KOREA);
Locale currentLocale;
ResourceBundle messages;
Iterator<Locale> iter = localeList.iterator();
while (iter.hasNext()){
currentLocale = iter.next();
System.out.println("\ncurrentLocale = "
+ currentLocale.getDisplayName());
messages =
ResourceBundle.getBundle("MessagesBundle",currentLocale);
Locale messagesLocale = messages.getLocale();
System.out.println("messagesLocale = "
+ messagesLocale.getDisplayName());
System.out.println(messages.getString("greetings"));
System.out.println(messages.getString("inquiry"));
System.out.println(messages.getString("farewell"));
}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the following output:
currentLocale = English (United Kingdom)
messagesLocale = English (United States)
Hello.
How are you?
Goodbye.
currentLocale = Korean (South Korea)
messagesLocale = English (United States)
Hello.
How are you?
Goodbye.
ACTUAL -
[The system is using the root MessagesBundle.properties, not the default MessagesBundle_en_US.properties.]
currentLocale = English (United Kingdom)
messagesLocale =
Hiya.
How you doing?
Seeya.
currentLocale = Korean (South Korea)
messagesLocale = English (United States)
Hello.
How are you?
Goodbye.
REPRODUCIBILITY :
This bug can be reproduced always.
###@###.### 11/4/04 18:34 GMT
- relates to
-
JDK-4353454 (rb) Second attempt at loading base resource bundle fails
-
- Resolved
-