You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Johannes Plachy <jo...@wave-solutions.com> on 2003/07/28 13:12:36 UTC

how can I switch between different languages

Hi,

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 ?

thx
johannes

Re: how can I switch between different languages

Posted by Ben <jd...@web.de>.
On http://jakarta.apache.org/struts/resources/tutorials.html there's a 
link to "Struts i18n" (=internationalization), to the following article:

http://www.anassina.com/struts/i18n/i18n.html

towards the end of that article there is a section "dynamic language 
selection"

I hope this helps,

Ben.

On Monday, July 28, 2003, at 01:12 PM, Johannes Plachy wrote:

> Hi,
>
> 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 ?
>
> thx
> johannes


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: how can I switch between different languages

Posted by Andrew Hill <an...@gridnode.com>.
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.

<fyi>
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
session
</fyi>




-----Original Message-----
From: Johannes Plachy [mailto:johannes.plachy@wave-solutions.com]
Sent: Monday, 28 July 2003 19:13
To: struts-user@jakarta.apache.org
Subject: how can I switch between different languages


Hi,

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 ?

thx
johannes


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org