Reputation: 303
I am trying to show a welcoming message in a JSF page in different languages (English or Spanish) depending on the user's browser configuration.
These are the steps I follow:
1-In Netbeans I create a WAR project
2-In the folder Source Packages I create a package named locale, and inside that package, I create 2 files (messages.properties, messages_es.properties)
messages.properties
greeting = Welcome!
messages_es.properties
greeting = Bienvenido!
3-In the folder Web Pages I create the file index.html
<h:outputText value="#{msg['greeting']}" />
4-In faces-config.xml I write this code:
<locale-config>
<default-locale>en</default-locale>
<supported-locale>es</supported-locale>
</locale-config>
<resource-bundle>
<base-name>locale.messages</base-name>
<var>msg</var>
</resource-bundle>
When I run the application in my browser always is shown the welcoming message in Spanish (BIenvenido!), also when I change the preference order (Preferences-Content-Language) to show the web page in English.
What am I doing wrong?
Upvotes: 1
Views: 458
Reputation: 303
I finally managed to find the error. I changed the messages.properties file name to messages_en.properties and it works well.
Upvotes: 2