You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dmitri Ilyin <dm...@gmx.net> on 2003/04/29 14:24:26 UTC
how to get language from Locale??
Hi,
what is the simplest way to get language from Session Locale???
I could get Locale Object from Session with the Key
"org.apache.struts.action.Action.LOCALE_KEY" and cast it and call
getLanguage().
Are there any better way???
regards
Dmitri
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: how to get language from Locale??
Posted by Patrick Refondini <pa...@pobox.com>.
Dmitri Ilyin wrote:
>Hi,
>
>what is the simplest way to get language from Session Locale???
>
>I could get Locale Object from Session with the Key
>"org.apache.struts.action.Action.LOCALE_KEY" and cast it and call
>getLanguage().
>
>Are there any better way???
>
>regards
>
>Dmitri
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>
One more solution ...provided you are in a org.apache.struts.action.Action
java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)
Docs at:
http://jakarta.apache.org/struts/api/org/apache/struts/action/Action.html
Patrick
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: how to get language from Locale??
Posted by Dmitri Ilyin <dm...@gmx.net>.
I use Struts 1.0.2....
"Kris Schneider" <kr...@dotech.com> schrieb im Newsbeitrag
news:1051620348.3eae73fca4a89@brutus.dotech.com...
> If you're doing this from code that has a handle to a PageContext instance
(e.g.
> in a tag handler), use RequestUtils.retrieveUserLocale. Otherwise, here's
> something that emulates what the retrieveUserLocale method is doing:
>
> Locale locale = request.getLocale();
> HttpSession session = request.getSession(false);
> if (session != null) {
> Locale sessionLocale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
> if (sessionLocale != null) {
> locale = sessionLocale;
> }
> }
>
> Quoting Noureddine Bekrar <nb...@rennes.jouve.fr>:
>
> > yes it's ok,
> >
> > you can do that:
> > String lg = ( (Locale) pageContext.getAttribute( Action.LOCALE_KEY,
> > PageContext.REQUEST_SCOPE)).getLanguage();
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Dmitri Ilyin" <dm...@gmx.net>
> > To: <st...@jakarta.apache.org>
> > Sent: Tuesday, April 29, 2003 2:24 PM
> > Subject: how to get language from Locale??
> >
> >
> > > Hi,
> > >
> > > what is the simplest way to get language from Session Locale???
> > >
> > > I could get Locale Object from Session with the Key
> > > "org.apache.struts.action.Action.LOCALE_KEY" and cast it and call
> > > getLanguage().
> > >
> > > Are there any better way???
> > >
> > > regards
> > >
> > > Dmitri
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
>
>
> --
> Kris Schneider <ma...@dotech.com>
> D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: how to get language from Locale??
Posted by Kris Schneider <kr...@dotech.com>.
If you're doing this from code that has a handle to a PageContext instance (e.g.
in a tag handler), use RequestUtils.retrieveUserLocale. Otherwise, here's
something that emulates what the retrieveUserLocale method is doing:
Locale locale = request.getLocale();
HttpSession session = request.getSession(false);
if (session != null) {
Locale sessionLocale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
if (sessionLocale != null) {
locale = sessionLocale;
}
}
Quoting Noureddine Bekrar <nb...@rennes.jouve.fr>:
> yes it's ok,
>
> you can do that:
> String lg = ( (Locale) pageContext.getAttribute( Action.LOCALE_KEY,
> PageContext.REQUEST_SCOPE)).getLanguage();
>
>
>
>
> ----- Original Message -----
> From: "Dmitri Ilyin" <dm...@gmx.net>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, April 29, 2003 2:24 PM
> Subject: how to get language from Locale??
>
>
> > Hi,
> >
> > what is the simplest way to get language from Session Locale???
> >
> > I could get Locale Object from Session with the Key
> > "org.apache.struts.action.Action.LOCALE_KEY" and cast it and call
> > getLanguage().
> >
> > Are there any better way???
> >
> > regards
> >
> > Dmitri
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
--
Kris Schneider <ma...@dotech.com>
D.O.Tech <http://www.dotech.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: how to get language from Locale??
Posted by Noureddine Bekrar <nb...@rennes.jouve.fr>.
yes it's ok,
you can do that:
String lg = ( (Locale) pageContext.getAttribute( Action.LOCALE_KEY,
PageContext.REQUEST_SCOPE)).getLanguage();
----- Original Message -----
From: "Dmitri Ilyin" <dm...@gmx.net>
To: <st...@jakarta.apache.org>
Sent: Tuesday, April 29, 2003 2:24 PM
Subject: how to get language from Locale??
> Hi,
>
> what is the simplest way to get language from Session Locale???
>
> I could get Locale Object from Session with the Key
> "org.apache.struts.action.Action.LOCALE_KEY" and cast it and call
> getLanguage().
>
> Are there any better way???
>
> regards
>
> Dmitri
>
>
>
>
> ---------------------------------------------------------------------
> 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