Hi Kosh,

The responses to your question by David Winterfeldt & Peter Alfors are the
correct way to go about this, as the local is already stored in the session
by struts. So to flesh out David's example for you... in your action classes
perform method try something like this:

public ActionForward perform(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws ServletException 
        {
                
                String flag = ((LoginForm) form).getFlag ();
                Local locale = new java.util.Locale (flag);

                request.getSession().setAttribute(
                        org.apache.struts.action.Action.LOCALE_KEY,locale);

                return (mapping.findForward("success"));
        }

In your jsp you would use an html:img tag that added the 'flag' locale
string as a request parameter ie :

<html:img scr="/images/uk.gif" paramId='flag' paramName='en_GB'/>

Then in subsequent jsps you just use a bean:message tag, no need to include
the locale option as we have set the struts locale key in the session and
this is used by the Message tag lib.

Jon.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: 07 June 2001 16:41
To: [EMAIL PROTECTED]
Subject: RE: Can you do this with internationalisation.

I think I understand how this works, but some code examples would be 
handy since the documentation for the bean:message tag's locale 
attribute seems to indicate that a "
session scope bean under which our currently selected Locale object is 
stored" can be used as an alternative to the Action.LOCALE_KEY constant.

Kosh

> -----Original Message-----
> From: Jon.Ridgway 
> Sent: 07 June 2001 15:47
> To: struts-user
> Cc: Jon.Ridgway
> Subject: RE: Can you do this with internationalisation.
> 
> 
> Hi Alex,
> 
> Yes you can do this. When the user clicks on the flag, you 
> set the local in
> their session. Then use the local option to explicitly set 
> the local when
> using the Struts bean:message tag.
>  
> Jon.
> 
> -----Original Message-----
> From: Alex Colic [mailto:[EMAIL PROTECTED]] 
> Sent: 07 June 2001 15:07
> To: Struts
> Subject: Can you do this with internationalisation.
> 
> Hi,
> 
> my boss wants me to set up one of my apps written using 
> struts for a demo.
> He wants to have a web page with a couple of flags. The use 
> clicks on of the
> flags and enters the program using the language they selected.
> 
> Not having gone down this road before any idea what that 
> would entail. I
> know I would have to create multiple localisation files for 
> the languages.
> But how do I specify for each user what file to use and can you have
> multiple users all accessing your program concurrently viewing it in
> different languages.
> 
> Some insight into the above is appreciated.
> 
> Alex
> 


Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

Reply via email to