This is my messages_en_US.properties
file in WEB-INF/classes
folder :-
Login=Login
And then i created messages_fr_FR.properties
:-
Login=frenchLogin
Then in my JSF page i wrote this :-
<f:loadBundle basename="messages" var="msg"/>
<h:commandButton id="btnLogin" value="#{msg.Login}" actionListener="#{IndexBean.doLogin}"/>
I can correctly see the Login text by default. But when i go in firefox and change my default language to fr-fr, my text still remains the same ie i can't see frenchLogin.
I don't have anything in my faces-config.xml
What am i doing wrong? Thanks in advance :)
You have to have this in the faces-config.xml
<application>
<message-bundle>com.mydomain.resources.Messages</message-bundle>
<locale-config>
<default-locale>fr_FR</default-locale>
<supported-locale>en_EN</supported-locale>
</locale-config>
</application>
You need a Messages.properties which will be the default one.
in your jsf page:
<f:loadBundle basename="com.mydomain.resources.Messages" var="msg" />
The messages file has to be in src/main/java/
and then in a package. Mine is /src/main/java/com/mydomain/resources
Also be careful with the capital letters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.