I did not mean to imply that you cannot change the locale in the code
itself.  I was simply stating that as a user, changing your locale in your
browser will not change the locale that Struts has assigned your session.


-----Original Message-----
From: Vernon Wu [mailto:vernonw@;gatewaytech.com]
Sent: Friday, October 25, 2002 2:44 PM
To: [EMAIL PROTECTED]; Russ Bonsall
Subject: Re: RE: re. i18n



To my knowledge, there are two ways to set up locale. One is to use the
container's configuration setting for 
application. The other is to have an application itself session locale
attribute. The Struts as well as the PetStore use the 
second approach. The locale setting can be changed inside of the container
by either calling Config.set method for the 
first approach, or reset the locale variable value,

session.setAttribute(org.apache.struts.action.Action.LOCALE_KEY,newLocale);

for the Struts case for the second approach.

The statement, ?locale is unchangeable during a session? is still not true
even in Struts. Does your code also 
demonstrate locale resetting?
 

10/22/2002 8:15:28 AM, Russ Bonsall <[EMAIL PROTECTED]> wrote:

>
>Vernon,
>
>The last time I checked the Pet Store application does not use Struts.  If
>you look at the Struts source code you will find that the user's locale is
>stored in session and is later used when reconciling which message
resources
>to use.  Look at the processLocale() method from the RequestProcessor below
>(very similar to the processLocale() in ActionServlet for 1.0.2).
>
>
>Jeff, 
>
>It appears you are doing everything right.  I think you're right in saying
>there is something small that you're missing.  You shouldn't need to change
>any localization settings through Control Panel.  The browser setting is
>what is sent with your request.  I'm sorry I couldn't be of more help.
>
>Russ
>
>
>protected void processLocale(HttpServletRequest request,
>                                 HttpServletResponse response) {
>
>        // Are we configured to select the Locale automatically?
>        if (!appConfig.getControllerConfig().getLocale()) {
>            return;
>        }
>
>        // Has a Locale already been selected?
>        HttpSession session = request.getSession();
>        if (session.getAttribute(Action.LOCALE_KEY) != null) {
>            return;
>        }
>
>        // Use the Locale returned by the servlet container (if any)
>        Locale locale = request.getLocale();
>        if (locale != null) {
>            if (log.isDebugEnabled()) {
>                log.debug(" Setting user locale '" + locale + "'");
>            }
>            session.setAttribute(Action.LOCALE_KEY, locale);
>        }
>
>    }
>
>-----Original Message-----
>From: Vernon Wu [mailto:vernonw@;gatewaytech.com]
>Sent: Monday, October 21, 2002 4:30 PM
>To: [EMAIL PROTECTED]
>Subject: re. i18n
>
>
>
>I saw the following statement in today mail archive.
>
>       Also keep in mind that the locality is stored in session.  This
>means you
>       cannot switch languages while using the same session.  The best way
>to test
>       is by setting your language, close and reopen your browser.
>
>This statement is not true. The Pet Store allows users change the locale
>anywhere in the middle of session. You can 
>test out yourself by driving a demo version from 
>http://developer.java.sun.com/developer/technicalArticles/J2EE/deployathon3
/
>
>BTW, the locale information management, including changing locale method,
>demonstrated in the latest version PS is 
>not the best way by today's standard. Take a look at JSP/JSTL articales on
>onjava.com by Hans Bergsten.
>
>Hope this helps.
>
>Vernon
>
>
>




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

Reply via email to