You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcus Biel <Ma...@bmw.de> on 2002/11/13 10:31:32 UTC

user manually changing local

I want to give the user the ability to manually change the language of
the aplication by selecting a local value from a selectbox.

Has someone got an appropiate example to achieve this ?


thx in advance,

marcus

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: user manually changing local

Posted by Andrew Hill <an...@gridnode.com>.
I have the following in my RequestProcessor to adjust the locale based on
what language the user has set in his browser - which saves the need for a
special page for it in your app (IExplorer use tools->internet
options-->languages).
Im still working on 118n in my app so this may need more stuff to be added,
but it seems to work.

protected void processLocale(HttpServletRequest request, HttpServletResponse
response)
  {
    if (!appConfig.getControllerConfig().getLocale())
    {
      return;
    }
    // Use the Locale returned by the servlet container (if any)
    HttpSession session = request.getSession();
    Locale locale = request.getLocale();
    Locale oldLocale = (Locale)session.getAttribute(Action.LOCALE_KEY);
    if (locale != null)
    {
      if(locale.equals(oldLocale))
      {
        return;
      }
      else
      { // Only set locale in session if its changed
        if (log.isDebugEnabled())
        {
            log.debug(" Setting user locale '" + locale + "'");
        }
        session.setAttribute(Action.LOCALE_KEY, locale);
      }
    }

  }

-----Original Message-----
From: Michael Delamere [mailto:home@michael-delamere.de]
Sent: Wednesday, November 13, 2002 17:44
To: 'Struts Users Mailing List'
Subject: RE: user manually changing local


Marcus,

If you are using struts1.1 you can use your own version of the
RequestProcessor by extending it and defining it in your struts-config.

You can then manage the locale stuff manually by overriding the method
processLocale.

In the struts-config you would write something like:

<controller
  contentType="text/html;charset=UTF-8"
  debug="4"
  locale="true"
  nocache="true"
  processorClass="com.morelogs.carlroth.actions.MyRequestProcessor"/>

HTH!

Regards,

Michael



-----Original Message-----
From: Marcus Biel [mailto:Marcus.Biel@bmw.de]
Sent: Mittwoch, 13. November 2002 10:32
To: struts-user@jakarta.apache.org
Subject: user manually changing local

I want to give the user the ability to manually change the language of
the aplication by selecting a local value from a selectbox.

Has someone got an appropiate example to achieve this ?


thx in advance,

marcus

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: user manually changing local

Posted by Michael Delamere <ho...@michael-delamere.de>.
Marcus,

If you are using struts1.1 you can use your own version of the
RequestProcessor by extending it and defining it in your struts-config.

You can then manage the locale stuff manually by overriding the method
processLocale.

In the struts-config you would write something like:

<controller 
  contentType="text/html;charset=UTF-8"
  debug="4"
  locale="true"
  nocache="true"
  processorClass="com.morelogs.carlroth.actions.MyRequestProcessor"/>

HTH!

Regards,

Michael



-----Original Message-----
From: Marcus Biel [mailto:Marcus.Biel@bmw.de] 
Sent: Mittwoch, 13. November 2002 10:32
To: struts-user@jakarta.apache.org
Subject: user manually changing local

I want to give the user the ability to manually change the language of
the aplication by selecting a local value from a selectbox.

Has someone got an appropiate example to achieve this ?


thx in advance,

marcus

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>