You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Chang <jo...@yahoo.com> on 2001/03/02 18:13:32 UTC
How to implement multiple languages in a web site using struts?
In struts, can I set the language that is to be used
in a querystring, and then the JSP can display in the
designed language? How to write tag of
<bean:message... />? How to set the corresponding
environment, including properties files, tld files,
web.xml?
Thanks a lot!
John
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
Re: How to implement multiple languages in a web site using struts?
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
John Chang wrote:
> In struts, can I set the language that is to be used
> in a querystring, and then the JSP can display in the
> designed language? How to write tag of
> <bean:message... />? How to set the corresponding
> environment, including properties files, tld files,
> web.xml?
>
You can do this, but indirectly.
The Struts <bean:message> tag bases its language choice on a session
attribute that is stored under key "org.apache.struts.action.LOCALE".
(In a program, you would use the symbolic string constant
Action.LOCALE_KEY for this). So, if you want to switch languages, all
you would need to do is
* Create a new Locale for the desired language
Locale loc = new Locale("fr"); // French
* Store the new Locale under this session attribute key:
HttpSession = request.getSession();
session.setAttribute(Action.LOCALE_KEY, loc);