Red Hat Bugzilla – Bug 1031080
Texts are displayed in the OS system language when the "English locale is selected"
Last modified: 2014-08-06 16:09:24 EDT
Created attachment 824575 [details]
Some texts not in English
Description of problem:
Installation of dashuilder in a non-english OS (JVM default locale non-english). The OS language must be one of the languages supported by dashbuilder i.e:
Once logged into the UI if the user selected the "English" language from the language selector menu some texts are displayed in the OS system language and not in English. For instance, Showcase>Administration>Data providers.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Install on a host with a non-english supported language (or change the JVM default locale)
2. Do login as admin, select the English language.
3. Go to Showcase>Administration>Data providers.
Some texts displayed in the default OS language not in English.
All the texts displayed in English.
This issue is caused because the app's resource bundles in English are the default ones (with no language prefix: messages.properties).
One work-around to deal with this is to set the JVM default locale to English before running the app. In fact, we think this is the best approach since the app assumes English is set as the default.
We have found the cause and a possible solution:
- The default Oracle JVM ResourceBundle class implementation for the method getBundle(...) is based on:
1.- Obtain the bundle using the locale argument
2.- If the bundle for the locale argument does not exist, use the fallback bundle. In both JDK 6/7 the default fallback bundle is obtained using the default JVM locale.
3.- If the bundle for default jvm locale is not found, use the global one.
- In the whole dashbuilder module there is no bundles for "en" region (the global ones are the english ones).
-> So, if you run the dashbuilder web application using the Spanish locale and change it using the UI (language combo selector) to English, as the resource bundle for "en" is not found and by the other hand the resource bundle for default jvm locale ("ES") is found, the returned language will be Spanish.
-> This error only happens to static bundles (existing properties files in the module). For all dynamic texts introduced by the user or by the pre-installed workspaces it works fine, as they are not resource bundles, are database field. This is the reason why some texts are in english and some in spanish when reproducing this issue.
Change the behavior of the fallback bundle for ResourceBundle class implementation. For more information see http://docs.oracle.com/javase/6/docs/api/java/util/ResourceBundle.Control.html.
The idea is to encapsulate all dashbuilder module calls to ResourceBundle methods into the org.jboss.dashboard.LocaleManager class. Then, delegate to the JDK ResourceBundle but using a different ResourceBundle.Control implementation. The impl to use is ResourceBundle.NoFallbackControl.
This is the first approach, so the solution details are not commented yet.
The solution has been to encapsulate all calls to ResourceBundle#getBundle method into a new method in org.jboss.dashboard.LocaleManager#getBundle. This encapsulation uses a NoFallbackControl implementation for ResourceBundle.Control instance.
For jsp files, a new custom i18n tag class has been created to encapsulate the same logic.
Commits on master
Commits on 6.0.x
Uuuups - wrong field.
Reproduced on Spanish OS (Fedora 20) and BPMS 6.0.0.ER5
Verified on Spanish OS (Fedora 20) and BPMS 6.0.0.ER7