struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <>
Subject RE: how can I switch between different languages
Date Mon, 28 Jul 2003 11:31:07 GMT
Switch off struts default locale handling (if I recall correctly this is the
'locale' attribute in the 'controller' element in struts-config.xml - set it
to "false") and provide the locale yourself stored in the same attribute in
the session that struts stores it (the Action class provides a setLocale()
method for this - but the attribute has the key defined in the constant
Globals.LOCALE_KEY if you need to play with outside an Action).

Since your not using the normal method of specifying it by browser settings
its up to you to provide a screen (or whatever) where the user can choose
one, and in the action it submits to (or if its something on every screen
you would be better off subclassing the RequestProcessor and overridding
processLocale()) you can create an appropriate Locale object to pass to
setLocale(), or store in the session under the aforementioned key.

The struts tags use the locale stored under that key to work out which
resouce bundle to use.

Struts handling of locale setting is to be found in the processLocale()
method of the RequestProcessor (you may override this if you wish). What
this method does is as follows:
1. Checks the config to see if locale is to be determined automatically and
if so:
2. Checks to see if a Locale is already set in the session and if not:
3. Gets the locale using the request.getLocale() method (which takes browser
settings (as passed in request header) into account) and stores it in the

-----Original Message-----
From: Johannes Plachy []
Sent: Monday, 28 July 2003 19:13
Subject: how can I switch between different languages


how can I switch between different languages ( independent of the
browser-settings ?) at runtime easily ?
this setting should be valid if possible for the further session.

any ideas ?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message