cancel
Showing results for 
Search instead for 
Did you mean: 

Setting User Locale by adding links in Masthead iview

Former Member
0 Kudos

Hi Guys,

Our client wants portal to be bilingual, English and French. These links has to toggle when pressed. If the current users language is English then French link should appear and onclick of the link it has to set the user locale to French and the link to English. We placed the links in Masthead iview by editing it. The code that puts the links in Masthead and sets the locale are given below. All these functions and code are placed in HeaderiView.jsp

The issue we are facing is when ever a user logs in, the Language Link will be based on his default locale. On page refresh the locale gets changed to French if the order of Javascript function is setEnglish and setFrench, irrespective of the link pressed. But if I change the order of Javascript functions to setFrench and then setEnglish, then on refresh the local of the user gets changed to English.

We are using portal UME. All suggestions are welcome.

<%boolean isFrenchLocale=isFrench(componentRequest);
if(isFrenchLocale)
{ %>
<TD nowrap id="English" name="EnglishName" style="display: inline">
<%} else {%>
<TD nowrap id="English" name="EnglishName" style="display: none">
<% }%>								
<hbj:link id="EnglishLink" linkDesign="FUNCTION" reference="#" text="English" >
<% { EnglishLink.setOnClientClick("javascript:setEnglish();");} %>
</hbj:link>
</TD>
<%if (isFrenchLocale){%>
<TD id="French" name="FrenchName" style="display: none">
<%} else {%>
<TD id="French" name="FrenchName" style="display: inline">
<% }%>
<hbj:link id="FrenchLink" linkDesign="FUNCTION" reference="#" text="Français">
<% { FrenchLink.setOnClientClick("javascript:setFrench();");} %>
</hbj:link>
</TD>

The Java script functions are

function setEnglish()
{
<%setCurrentLocale(componentRequest,"EN");%>
window.top.location.href="https://answers.sap.com/irj/portal";
}
function setFrench()
{
<%setCurrentLocale(componentRequest,"FR");%>
window.top.location.href="https://answers.sap.com/irj/portal";
}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Guys,

This is an update that i got..

Both of my jsp functions within the Javascript are being triggered on every page load since JSP is rendered before any Javascript (and also doesnt take into account any boolean Logic intended for client side). This explains why the last method of the two determines user language. The JSP tags are executed server side before any Javascript is rendered so I am calling the setCurrentLocale method twice.

All JSP has been rendered at the point in time client is viewing it. So call the Javascript function isnt doing anything other than refreshing page and setting the users language 2 times again.

I want a link in the master head which sets/changes the portal language..

Is there any other way of doing this?

Regards

George