does somebody know whats wrong with the next method?
public static String getMessageBundleString(String key, String localeAcronym) throws MissingResourceException {
FacesContext facesContext = FacesContext.getCurrentInstance();
String messageBundleName = facesContext.getApplication().getMessageBundle();
ResourceBundle bundle = ResourceBundle.getBundle(messageBundleName, new Locale(localeAcronym));
//THE LOCALE OF THIS BUNDLE IS ALWAYS 'es_ES' !!!
return bundle.getString(key);
}
In a Primefaces/JSF environment, I want to retrieve a key from the proper i18n properties file.
But it always take it from the messages_es_ES.properties file.
Following invocations return same value (='Inicio'):
getMessageBundleString("home", "es_ES")
getMessageBundleString("home", "uk_UK")
messages_es_ES.properties:
home=Inicio
messages_uk_UK.properties:
home=Home
Thanks
Here some of my faces-config.xml content:
<application>
<locale-config>
<supported-locale>es_ES</supported-locale>
<supported-locale>uk_UK</supported-locale>
</locale-config>
<message-bundle>cfg.i18n.messages</message-bundle>
<resource-bundle>
<base-name>cfg.i18n.messages</base-name>
<var>msgs</var>
</resource-bundle>
</application>