i have a few questions about jsf and localization.
assume i have the following definition in faces-config.xml
In my jsf page i use bundle.abc to get the value of abc (which is mapped in labels.properties). i also have labels_de.properties
the question is - what locale is used in in this bundle?
i configured the locales:
but it didnt make the page take the values from labels_de.
only when i define <f:view locale="de_DE"/> in the page, the value is taken from labels_de.properties.
Can someone please explain how this works?
First of all you don't have to put the view tag to all of your pages. You can put it in a template file and then all your pages that use that template have it defined.
When you define the locale change it to point to a backing bean (or to facescontext) so that it can change dynamically. I for example have it defined like this
so I can change the locale as I want based on the users preferences.
I can explain how it works in more detail if you want (when I have more time).
The reason we need to use the f:view tag at all is not clear to me but maybe somenone here on this forum can explain the technical details >
I believe that your browser is sending en_US in its Accept-Language header.
The Accept-Language is the major precedence information about locales. To use another you need the f:view or programatically change the ViewRoot's locale attribute: