Reputation: 153
My problem now is that I can't get localization working with FacesMessage
I've tried:
try {
ResourceBundle bundle = ResourceBundle.getBundle("translations", context.getViewRoot().getLocale());
text = bundle.getString("loginFail");
} catch (Exception e) {
System.out.println("EXCEPTION: " + e);
}
FacesContext.getCurrentInstance().addMessage("", new FacesMessage(text));
but the following exception is thrown
java.util.MissingResourceException: Can't find bundle for base name translations, locale cs
faces-config.xml contains:
<application>
<locale-config>
<default-locale>cs</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
<resource-bundle>
<base-name>tr.translations</base-name>
<var>txt</var>
</resource-bundle>
<message-bundle>
tr.translations
</message-bundle>
</application>
Files translations_cs.properties and translations_en.properties are in the tr package, the location is definitely ok.
Do you have any idea how to get it working? Thanks in advance
Upvotes: 9
Views: 7064
Reputation: 1109322
The basename in getBundle()
should be tr.translations
, exactly as you have in faces-config.xml
.
Upvotes: 7