Meaningless Drivel is fun!
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "locale setting through code" Watch "locale setting through code" New topic

locale setting through code

Puneetx Gupta

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
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 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 that u should get the locale from the request and update the session varible everytime

This will solve ur problem
I agree. Here's the link:
subject: locale setting through code
It's not a secret anymore!