[英]Why is internationalization not working properly? JSF
This is my messages_en_US.properties
file in WEB-INF/classes
folder :- 这是我的
WEB-INF/classes
文件夹中的messages_en_US.properties
文件:
Login=Login
And then i created messages_fr_FR.properties
:- 然后我创建了
messages_fr_FR.properties
Login=frenchLogin
Then in my JSF page i wrote this :- 然后在我的JSF页面中,我这样写:-
<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.
但是当我进入Firefox并将默认语言更改为fr-fr时,我的文本仍然保持不变,即我看不到frenchLogin。
I don't have anything in my faces-config.xml 我的faces-config.xml中没有任何内容
What am i doing wrong? 我究竟做错了什么? Thanks in advance :)
提前致谢 :)
You have to have this in the faces-config.xml
您必须在
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. 您需要一个Messages.properties,它将是默认值。
in your jsf page: 在您的jsf页面中:
<f:loadBundle basename="com.mydomain.resources.Messages" var="msg" />
The messages file has to be in src/main/java/
and then in a package. 消息文件必须位于
src/main/java/
,然后位于一个包中。 Mine is /src/main/java/com/mydomain/resources
我的是
/src/main/java/com/mydomain/resources
Also be careful with the capital letters. 也请注意大写字母。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.