You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robert Edgar <ro...@hkstar.com> on 2000/07/02 10:46:19 UTC

A suggestion on internationalization

It would be really nice to build in an option to use an algorythm something
like Jason Hunters LocaleNegotiator for determining the Locale rather than a
session attribute ie driven by the accept-languages header.

I know some sites dont do it this way and use cookies or session attributes
instead but some (a few :-(( ) of us do and (IMHO) this is the correct way
to do it, and it would be nice to have the option especially as someone has
already written the code :-) .

Maybe driven by a param in web.xml, also needs a param to allow it to ignore
the charset map and use utf-8 (for those of us who want to use utf-8 instead
of things like BIG5 or GB2312 ).

In the mean time I believe I can subclass the action servlet and pre process
the request and set the session attribute on each call?


Thanks
Rob


Re: A suggestion on internationalization

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

> It would be really nice to build in an option to use an algorythm something
> like Jason Hunters LocaleNegotiator for determining the Locale rather than a
> session attribute ie driven by the accept-languages header.
>
> I know some sites dont do it this way and use cookies or session attributes
> instead but some (a few :-(( ) of us do and (IMHO) this is the correct way
> to do it, and it would be nice to have the option especially as someone has
> already written the code :-) .
>

Thanks for the suggestions -- I will look at this in more detail.

>
> Maybe driven by a param in web.xml, also needs a param to allow it to ignore
> the charset map and use utf-8 (for those of us who want to use utf-8 instead
> of things like BIG5 or GB2312 ).
>

Internationalization is also an issue being discussed for the next version of
the servlet and JSP specifications.  We may end up seeing the servlet container
doing more of this kind of work so that apps don't have to, but it is not yet
clear what the final form will be.

>
> In the mean time I believe I can subclass the action servlet and pre process
> the request and set the session attribute on each call?
>

Yes.  The simplest thing would probably be overriding the
processActionInstance() method to set the session Locale right before the action
method is accessed -- something like this:

    protected void processActionInstance(...) ... {

        HttpSession session = request.getSession();
        ... calculate and store the correct locale ...
        super.processActionInstance(...);

    }

>
> Thanks
> Rob

Craig