Skip to Content
author's profile photo Former Member
Former Member

Language Switching Problem(internalization)

Dear Experts,

We are facing the one the major issue in portal 7.4 for internalization.

below are details :

1)We created one custom application for switching languages like English/Hindi

2)By default we gave the English portal then user click on Hindi its going to Hindi portal again user click on English its not redirecting to English portal

3) we implemented the code like below:

.JSP code:

<%

// Get the request

IPortalComponentRequest currentRequest = (IPortalComponentRequest)

pageContext.getAttribute
(javax.servlet.jsp.PageContext.REQUEST);

// Get the Parameter
String language = currentRequest.getParameter("language");
String cURL = currentRequest.getParameter("cURL");

// Invalidate the old session
currentRequest.getServletRequest().getSession(true).invalidate();

// Here we prepare the 2 URL's for English and Hindi
// So that the user can be retained on the same page
// And not directed to the home page
%>

<form action="#" method="post" name="hid">
<input type = "hidden" name="urlhid" value=<%=cURL%>>
<%

// Check the parameter and accordingly re direct
if (language.equalsIgnoreCase("English"))
{
%>
<script language = "JavaScript">
var currentURL=document.hid.urlhid.value;
var targetURLEnglish;

if(currentURL.match("NavigationTarget") == null)
{
if(currentURL.match("guest_user") == null)
{
targetURLEnglish=currentURL+"?guest_user=english"
targetURLEnglish = targetURLEnglish.replace(/_hi/,"_en");
}
else
{
targetURLEnglish=currentURL
targetURLEnglish = targetURLEnglish.replace(/Hindi/,"english");
targetURLEnglish = targetURLEnglish.replace(/_hi/,"_en");
}
}
else
{
targetURLEnglish=currentURL+"&guest_user=english";

}

window.top.location.href=targetURLEnglish;
window.title="My portal"
</script>
<%
}
if (language.equalsIgnoreCase("Hindi"))
{
%>
<script language = "JavaScript">
var currentURL=document.hid.urlhid.value;
var targetURLHindi;

if(currentURL.match("NavigationTarget") == null)
{
if(currentURL.match("guest_user") == null)
{
targetURLHindi=currentURL+"?guest_user=Hindi"
targetURLHindi = targetURLHindi.replace(/_en/,"_hi");
}
else
{
targetURLHindi=currentURL
targetURLHindi = targetURLHindi.replace(/english/,"Hindi");
targetURLHindi = targetURLHindi.replace(/_en/,"_hi");
}

}
else
{
targetURLHindi=currentURL+"&guest_user=Hindi"

}

window.top.location.href=targetURLHindi;
window.title="My portal"
</script>
<%
}

%>

4) we are accessing language from below URL in portal :

//language
function Go(cLang)
{
var currentURL = window.top.location.href;
window.top.location.href="/irj/servlet/prt/portal/prtroot/com.portal.AnonymousLanguageSwitch.ChangeLanguage?language="+cLang+"&cURL="+currentURL;
}

I did the lots of R&D i didn't get any result,Please kindly help me to solve this issue.

Regards

Apps

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Oct 14, 2015 at 01:42 PM

    Hi Apps,

    On a first view, I cannot see any real difference in the switch from Hindi to English (not working) compared with the switch from English to Hindu (working).

    So I would suggest to debug the implementation; first find details about "again user click on English its not redirecting to English portal". What does this mean in detail? Is a request sent at all? If yes, what URL target is coming compared to the expected? You might also debug the JS code (and inspect before if the JS code in the HTML page is the one expected).

    If you would implement the ChangeLanguage component not as JSP but as AbstractPortalComponent (rendering the JS part from within there), you could also debug the Java code so far on server side.

    It's a bit hard to analyze this statically with the code given (maybe I overlooked something), but with some debugging it should be very easy at least to analyze WHAT happens...

    Regards

    Detlev

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2015 at 11:04 AM
    Dear Detlev,

    Thanks for your inputs,

    I tried another way for language switching ,using standard masthead component (com.sap.portal.navigation.masthead) from portal.I modified that component for language drop down ,in that drop down whatever the locales added in server all the languages are displaying,but here my targeting language Hindi is not getting but i checked locales in server level Hindi locale added in source and target languages.

    Kindly suggest and help i missed any steps .
    Regards Apps

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.