I have a JSP app which redirects to a JSF app, and there is a http session attribute setting the language. I need to change the locale of the JSF according to this and not according to the browser, since in mozilla shows up in english and in IE in spanish.
I'm trying to do so by having the faces context change the locale:
Well, it's generally considered rude to override the user's preferences on locale and language as he/she indicated in the browser settings.
But if you must, changing the FacesContext isn't a good place to do it. The FacesContext is created (and destroyed) on each HTTP request/response cycle, so any changes made to it will disappear very fast. You'd need to store your changes in a more durable place - probably a session object.
Beyond that, I can't say, since so far all my JSF apps have been monotonously mono-lingual.
Being persecuted doesn't in any way prove your righteousness or your beliefs. Many people get persecuted because they are repugnant or annoying. Or just because they can be.
I have to ask because you didn't specify. Are you sure your faces-config file is well configured? Do you have your resource files (*.properties) for the language you are setting?
Please confirm this so we can discard it. You can test if it's working by showing in your JSF an object of type date or Timestamp, it will change it's format depending on wich locale you have.
posted 10 years ago
Yeah, the faces-config is in order: locale-config and all. The bundle package has messages and messages_en properties files.
Currently, internet explorer is showing up in spanish, and firefox in english.
The thing is that users can choose the language when logging into the system, and so, the labels should change accordingly.
These preferences are captured by one servlet which sets up an attribute encapsulating user info like username, module, security profile, etc., and language of preference. I tried to change it in the first page redirected by the servlet but is not working.
Maybe if I have the servlet set up the header in respect to the browser language... I don't know.
Martin Lopez Ochoteco
posted 10 years ago
edit: also look at the locale constructor, you can invoke it only with the language information. No need to pass "" as Country.
Look, the code is OK. All I can guess is a matter of configuration. Look at my code:
I have these files to match:
I hope it helps.
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad: