Reputation: 2818
The instantiated resourceBundle does not correspond to the requestd locale(zh_TW). As a result strings from the fallback messages.properties are being picked. What am I missing?
This doesn't happen with locale which contain no underscores(Ex : es, pl, fr etc)
Locale myLocale = new Locale("zh_TW");
ResourceBundle resourceBundle = ResourceBundle.getBundle("messages", myLocale);
System.out.println("ResourceBundle locale : " + resourceBundle.getLocale());
Output
Default locale : en_US
ResourceBundle locale :
Upvotes: 1
Views: 587
Reputation: 1063
Also note that when ResourceBundle.getBundle() parses the properties file and finds an invalid character, it fails silently and falls back on the default properties file.
Upvotes: 1
Reputation: 494
The Locale class provides three constructors:
Locale(String language)
Locale(String language, String country)
Locale(String language, String country, String variant)
You most probably need to do:
Locale myLocale = new Locale("zh", "TW");
Upvotes: 0