You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sean Giles <Se...@trx.com> on 2001/02/10 19:48:07 UTC

I18n

How can I set the locale for each individual user session before the first
page displays?

I've tried putting the session.setAtttribute(Action.Locale_key,<locale>) but
it always displays in the default locale of the machine?  Changing the
machine locale causes the correct properties file to be used so I know that
is not the problem.

Thanks
Sean Giles

Re: I18n

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Sean Giles wrote:

> How can I set the locale for each individual user session before the first
> page displays?
>
> I've tried putting the session.setAtttribute(Action.Locale_key,<locale>) but
> it always displays in the default locale of the machine?  Changing the
> machine locale causes the correct properties file to be used so I know that
> is not the problem.
>

In the Struts example app, this is done by including the following tag on the
index.jsp page (actually, on every page):

    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html locale="true">
    ... page content ...
    </html:html>

This causes that <html:html> tag to consult the "Accept-Language" header sent by
the browser, and set up a Locale in the user's session if it is not already
there -- exactly the same way that the controller servlet does this if you
configure it to.

NOTE:  There are currently problems with this on servlet containers that do not
correctly implement the JSP 1.1 requirements for converting custom tag attribute
values.  I have heard problem reports about JRun 3.0 and ATG in this regard.

>
> Thanks
> Sean Giles

Craig