wood burning stoves 2.0*
The moose likes JSF and the fly likes locales and jsf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "locales and jsf" Watch "locales and jsf" New topic
Author

locales and jsf

dan volfman
Greenhorn

Joined: Jan 15, 2010
Posts: 6
hi
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?

thanks.

Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
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 >
Jose Berardo
Greenhorn

Joined: Oct 28, 2010
Posts: 9
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:



I'm having a problem closed to yours. If you solve yours, please take a look at mine: http://www.coderanch.com/t/515506/JSF/java/problems-JSF




Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218

Try it without the country specific detail. You're definitely on the right track, perhaps your
browser settings are incorrect (preferred languages).

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: locales and jsf
 
Similar Threads
Using custom resourceBundle that accepts UTF-8: can't find bundle for base name
"Locale en_US" navigation error
dynamic internationalization
Override request headers
language propertis to xml properties