This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes locale setting through code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "locale setting through code" Watch "locale setting through code" New topic
Author

locale setting through code

Puneetx Gupta
Greenhorn

Joined: Nov 23, 2004
Posts: 1
I am in process of developing a multilingual website.
Struts support multilingual developement with different resource file. I am able to implement that successfully.
But the above implementation reads the locale setting from the browser setting.
I need to change the language of the website on the click of a link.
to implement this i should be able to change the locale setting through code.
Kindly guide me to achieve the same?
Is it possible that i extend some class and set the locale variable thorugh there? or through some configuration setting in struts framework will get the value of locale variable from some user defined variable?

Any help is appreciated.
Puneet Gupta
puneetjunk@rediffmail.com
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi puneet

See the struts stores the locale in session when the session is created ..........and it wont update the same for every request ....it will update only when the new session is created tgatswhy if uc lose the browser and opena new browser the language change will get effected ...

so if u want that to be changed immedaitely u want to over ride the RequestProcessor provided by struts and especailly u should override the processLocale method ....in that u should get the locale from the request and update the session varible everytime


This will solve ur problem
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: locale setting through code