This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 forum!
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
Similar Threads
IBM RMC query
Multilingual web application in struts
locale in Unix
Internationalization with dropdown
ResourceBundle-Can't find bundle for base name