0
votes

A part of my faces-config.xml file is this:

<locale-config>
    <default-locale>el</default-locale>
    <supported-locale>en</supported-locale>
</locale-config>
<resource-bundle>
    <base-name>com.application.model.resources.Labels</base-name>
    <var>labels</var>
</resource-bundle>

I also have the files Labels_el.properties and Labels_en.properties in the corresponding package/folder.

The problem is this:

Firefox

When I start the application, all texts are in Greek language (default locale). Whenever I click on a commandButton or commandLink, all texts are changed in English language. However, the locale remains in Greek (el).

Chrome

The application starts correctly in Greek language and during page navigation the language remains the same. I have a dropdown list where I can change the locale. When I change the locale to English (en), tha page is refreshed correctly. After that, when I click on a commandButton or commandLink, the locale's value remains in English, but the text changes again to Greek.

Hence, the problem is that during page navigation, the language in Firefox changes to English and in Chrome changes to Greek (the locale doesn't change unless I select the desired one from the dropdown list).

Any solution to this issue?

1
Where are you keeping the locale? It must be kept in session scope and you have to force your view to use it, notice the locale attribute for f:view tag.Xtreme Biker
You are right! Using f:view tag is the solution! :)Puma
Do you want me to publish it as an answer? Otherwise you can write your own answer to mark the thread as closed ;-)Xtreme Biker
Sure, you can publish it :) Thank you! :)Puma
Done, you're welcome!Xtreme Biker

1 Answers

1
votes

You have to use <f:view/> tag with its locale attribute, which should be bound to a SessionScoped bean variable (or another scope, if you want only an specific part of your application to be in a different language). That will render the current view based in that locale value.