开发者

Why is internationalization not working properly? JSF

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开发者_JS百科" 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 i.e 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜