struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rabih Yazbeck" <rabli...@yahoo.co.uk>
Subject RE: Localisation
Date Wed, 05 Mar 2003 18:06:42 GMT

This what I did:

++++++++++++++ In the homepage page:
<%
pageContext.setAttribute("URLPath", request.getRequestURL());
%>

<html:link  page="/setLocale.do?lg=en" paramId="url" paramName="URLPath">
            <bean:message key="headermenu.jsp.english"/> </html:link>

<html:link  page="/setLocale.do?lg=fr" paramId="url" paramName="URLPath">
            <bean:message key="headermenu.jsp.french"/> </html:link>

++++++++++++++ or

<a href="<c:url value="/setLocale.do?lg=ar" >
<c:param name="url" value="${pageContext.request.requestURL}"/>
</c:url>">
<bean:message key="headermenu.jsp.arabic"/>
</a>


++++++++++++++ In Struts Config:

<action name="setLocale" type="util.SetLocaleAction" validate="false" scope="request" path="/setLocale"
/>




++++++++++++++ In the SetLocaleAction:

    String language = httpServletRequest.getParameter("lg");
    String urlInput = httpServletRequest.getParameter("url");
    Locale locale = (Locale) httpServletRequest.getSession().getAttribute(org.
        apache.struts.Globals.LOCALE_KEY);

    httpServletRequest.getSession(true).setAttribute(
        org.apache.struts.Globals.LOCALE_KEY, new Locale(language));

    Locale newlocale = (Locale) httpServletRequest.getSession().getAttribute(org.
        apache.struts.Globals.LOCALE_KEY);

    int index = urlInput.indexOf(httpServletRequest.getContextPath()) +
        httpServletRequest.getContextPath().length();

    return (new ActionForward( urlInput.substring(index), true));



 -----Original Message-----
> From: James [mailto:JamesPrance@hotmail.com]
> Sent: 05 March 2003 20:28
> To: struts-user@jakarta.apache.org
> Subject: Re: Localisation
> 
> i'm not sure at the moment our current ' work around' is to only display
> the
> flags on the 'home' page which can be accessed via the menu. This way no
> data entry is lost..
> 
> but i would prefer a way of doing it from any page and returning to the
> same
> page, preferably with no data entry loss (or validation)..
> 
> 
> 
> 
> "Konstantina Stamopoulou" <stak@intracom.gr> wrote in message
> news:00ee01c2e30d$b2d579d0$412c7c92@intranet.gr...
> >
> >
> > > You could set a group of forwards up, based on the locale ie
> > >
> > > <forward name="this_en" path="/jsp_pages/out_en-jsp" redirect="true"/>
> > > <forward name="this_de" path="/jsp_pages/out_de-jsp" redirect="true"/>
> > > <forward name="this_ko" path="/jsp_pages/out_ko-jsp" redirect="true"/>
> > >within <action/>
> >
> >
> > Does this mean  that someone has to implement a different .jsp for each
> > language? I need to implement something similar and I'm not sure that I
> > understand the answer. Don't you use the <bean:message> to display text
> in
> > different languages? I'm I missing something here?
> > James what is exactly the solution you are going to follow?
> >
> > > Cheers
> > >
> > > Simon
> >
> > Thank you in advance
> > Konstantina
> >
> >
> > > ----- Original Message -----
> > > From: "James" <JamesPrance@hotmail.com>
> > > To: <struts-user@jakarta.apache.org>
> > > Sent: Wednesday, March 05, 2003 8:11 PM
> > > Subject: Localisation
> > >
> > >
> > > > I have a LocaleActionClass that sets the locale according to which
> wee
> > > flag
> > > > the user clicks, my question is how in the struts-config.xml do i
> > specify
> > > it
> > > > to forward to the page they changed locale on (i.e their original
> page).
> > > >
> > > > James
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --------------------------------------------------------------------
> -
> > > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > > >
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> > >
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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


Mime
View raw message