You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Stefano Bianchi <st...@softeco.it> on 2007/07/02 16:56:43 UTC
Re: How to get localization programmatically in jsp
FYI, it might seem forced but this works fine:
<%@ page import = "org.apache.jetspeed.services.resources.JetspeedResources,
org.apache.turbine.util.RunData,
org.apache.jetspeed.om.security.JetspeedUser"%>
<%
String locale = "";
RunData rundata = (RunData)request.getAttribute("rundata");
if((((JetspeedUser)rundata.getUser()).getPerm("language").toString())!=null){ locale = ((JetspeedUser)rundata.getUser()).getPerm("language").toString(); } else { locale = request.getLocale().getLanguage(); }%><img src="<jetspeed:contentUri href="<%=bgImageFile.replaceAll(".gif", "_" +locale.toUpperCase() + ".gif")%>"/>">Cheers,Stefano----- Original Message -----From: "Stefano Bianchi" <st...@softeco.it>To: "Jetspeed Users List" <je...@portals.apache.org>Sent: Friday, June 29, 2007 5:21 PMSubject: Re: How to get localization programmatically in jsp> Well, it seems request.getLocale() returns my locale browser setting, soit does not change with J1.6 language selection.>> What I need is that when you change the language with the changelanguageportlet the top image changes (I could do it with localization, but text isembedded in the image ;-) by dynamically changing the image name:>> <% String locale = ???;%>>> <img src="<jetspeed:contentUri href="<%=bgImageF
ile.replaceAll(".gif","_"+ locale + ".gif")%>"/>">>> Then I have to understand where jetspeed stores the information aboutcurrent language selection (as it does it, it changes static text accordingto localization correctly!).>> Any other hint?> Thanks> Stefano>>> ----- Original Message -----> From: "Elif Guner" <el...@gmail.com>> To: "Jetspeed Users List" <je...@portals.apache.org>> Sent: Friday, June 29, 2007 5:08 PM> Subject: Re: How to get localization programmatically in jsp>>>> Have you tried request.getLocale() ?>>>> elif>>>> On 6/29/07, Stefano Bianchi <st...@softeco.it> wrote:>>>>>> Dear all,>>> how can I get the localization programmatically in J1.6 in a jsp page?>>>>>> Suppose I have to load payout_en.gif or payout_it.gif according tocurrent>>> localization (I use the changelanguage portlet) and that I want to>>> generate>>> the _en or _it part dynamically.>>>>>> I can get it once with>>>>>> request.getParameter("js_language")>>>>>> but this
is related to the request, as soon as I click something else I>>> lose>>> it.>>> Is there any Rundata variable I should read from?>>>>>> I think it is simple but I do not know where to look at.>>>>>> Thanks,>>> Stefano>>>>>> Ing. Stefano Bianchi>>> Softeco Sismat S.p.A. - www.softeco.it>>> Via De Marini 1, WTC Tower>>> 16149 GENOA (ITALY)>>> Tel. +39 010 6026 368>>> Fax +39 010 6026 350>>>>>>>>>>>>>>> --------------------------------------------------------------------->>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org>>> For additional commands, e-mail: jetspeed-user-help@portals.apache.org>>>>>>>>>>>>> ---------------------------------------------------------------------> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org> For additional commands, e-mail: jetspeed-user-help@portals.apache.org>>>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org
Re: How to get localization programmatically in jsp
Posted by Stefano Bianchi <st...@softeco.it>.
Sorry guys, the previous one was exceedingly complicated and wrong anyway.
This is definitively simpler:
<%@ page import = "org.apache.jetspeed.services.resources.JetspeedResources,
org.apache.turbine.util.RunData"%>
<%
RunData rundata = (RunData)request.getAttribute("rundata");
String locale = rundata.getUser().getPerm("language",
request.getLocale().getLanguage().toString()).toString();
%>
<img src="<jetspeed:contentUri href="<%=bgImageFile.replaceAll(".gif", "_"
+locale.toUpperCase() + ".gif")%>"/>"
Cheers,
Stefano
----- Original Message -----
From: "Stefano Bianchi" <st...@softeco.it>
To: "Jetspeed Users List" <je...@portals.apache.org>
Sent: Monday, July 02, 2007 4:56 PM
Subject: Re: How to get localization programmatically in jsp
> FYI, it might seem forced but this works fine:
>
> <%@ page import =
> "org.apache.jetspeed.services.resources.JetspeedResources,
> org.apache.turbine.util.RunData,
> org.apache.jetspeed.om.security.JetspeedUser"%>
>
> <%
> String locale = "";
>
> RunData rundata = (RunData)request.getAttribute("rundata");
>
> if((((JetspeedUser)rundata.getUser()).getPerm("language").toString())!=null){
> locale =
> ((JetspeedUser)rundata.getUser()).getPerm("language").toString(); } else
> { locale = request.getLocale().getLanguage(); }%><img
> src="<jetspeed:contentUri href="<%=bgImageFile.replaceAll(".gif", "_"
> +locale.toUpperCase() + ".gif")%>"/>">Cheers,Stefano----- Original
> Message -----From: "Stefano Bianchi" <st...@softeco.it>To:
> "Jetspeed Users List" <je...@portals.apache.org>Sent: Friday, June
> 29, 2007 5:21 PMSubject: Re: How to get localization programmatically in
> jsp> Well, it seems request.getLocale() returns my locale browser setting,
> soit does not change with J1.6 language selection.>> What I need is that
> when you change the language with the changelanguageportlet the top image
> changes (I could do it with localization, but text isembedded in the image
> ;-) by dynamically changing the image name:>> <% String locale = ???;%>>>
> <img src="<jetspeed:contentUri href="<%=bgImageF
> ile.replaceAll(".gif","_"+ locale + ".gif")%>"/>">>> Then I have to
> understand where jetspeed stores the information aboutcurrent language
> selection (as it does it, it changes static text accordingto localization
> correctly!).>> Any other hint?> Thanks> Stefano>>> ----- Original
> Message -----> From: "Elif Guner" <el...@gmail.com>> To: "Jetspeed
> Users List" <je...@portals.apache.org>> Sent: Friday, June 29,
> 2007 5:08 PM> Subject: Re: How to get localization programmatically in
> jsp>>>> Have you tried request.getLocale() ?>>>> elif>>>> On 6/29/07,
> Stefano Bianchi <st...@softeco.it> wrote:>>>>>> Dear all,>>> how
> can I get the localization programmatically in J1.6 in a jsp page?>>>>>>
> Suppose I have to load payout_en.gif or payout_it.gif according
> tocurrent>>> localization (I use the changelanguage portlet) and that I
> want to>>> generate>>> the _en or _it part dynamically.>>>>>> I can get it
> once with>>>>>> request.getParameter("js_language")>>>>>> but this is
> related to the request, as soon as I click something else I>>> lose>>>
> it.>>> Is there any Rundata variable I should read from?>>>>>> I think it
> is simple but I do not know where to look at.>>>>>> Thanks,>>>
> Stefano>>>>>> Ing. Stefano Bianchi>>> Softeco Sismat S.p.A. -
> www.softeco.it>>> Via De Marini 1, WTC Tower>>> 16149 GENOA (ITALY)>>>
> Tel. +39 010 6026 368>>> Fax +39 010 6026
> 350>>>>>>>>>>>>>>> --------------------------------------------------------------------->>>
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org>>>
> For additional commands, e-mail:
> jetspeed-user-help@portals.apache.org>>>>>>>>>>>>> --------------------------------------------------------------------->
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org> For
> additional commands, e-mail: jetspeed-user-help@portals.apache.org>>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org