Main steps to implement External-Facing Portal to support the ability for changing the user's language dynamically.
This page based on blog Multilingual External Facing Portal with Different Content.
If you are going to implement Multilingual External Facing Portal with identical contents in each language; luckily you have Portal Content Translation. However, if you have different contents you cannot use Portal Content Translation or swap language with direct links like "/irj/portal/anonymous?guest_user=english".
Lets assume we are going to publish in two languages English and Turkish.
Here is step by step solution :
Step 1 - Grant Anonymous Access to KM
Use following documentation to configure an anonymous access to KM. How To configure an anonymous access to KM
Step 2 - Create Anonymous Users
Create two users in portal "english" and "turkish".
In Config Tool, Enter the user ID of the users in the UME property ume.login.guest_user.uniqueids separated by comma.
Restart servlet engine.
Now we have two anonymous users named turkish and english. We want to use user turkish to publish content in Turkish Language and user english to publish content in English Language. Users can access the portal in anonymous mode via following URLs:
http:<server>:<port>/irj/portal/anonymous?guest_user=turkish
http:<server>:<port>/irj/portal/anonymous?guest_user=english
Step 3 - Create Content for Anonymous Users
Create two roles "Anonymous English Content" and "Anonymous Turkish Content".
Assign user "english" to role "Anonymous English Content" and user "turkish" to role "Anonymous Turkish Content".
Prepare your content and assign them to relevant roles.
Do not forget to set "Authentication Scheme" property of your IViews to anonymous.
Step 4 - Change Portal Desktop to "Light Desktop"
Go to System Administraton - Portal Display - Desktop & Display Rules and configure "Master Rule Collection" to use Light Desktop for group "Anonymous Users".
Now, we have two different anonymous pages with different URLs. However, when you want to go to English Page from Turkish Page you will see that it is not possible just by changing URL or via direct link from any content. Even you change URL, you will see that Portal do not logoff first anonymous user and log on to other anonymous user. Let's see how we can overcome this trouble.
Step 5 - Develop a Portal Component to swap Anonymous Users
Create a new Portal Application Project "Change User"
Create a servlet by extending "AbstractPortalComponent" class
In doContent method write following code :
String guest_user = request.getParameter("guest_user");
String href="/irj/portal/anonymous?guest_user=" +guest_user;
response.write("<script>");
response.write("window.top.location.href=\""href"\"");
response.write("</script>");
In portalapp.xml create a component "ChangeUser" and add property "Authscheme" with value "Anonymous"
Deploy your par file to Portal
Now, we have a component called ChangeUser and we can use this component to swap anonymous users in Portal. In Turkish Page use following link to swap to English Page :
"/irj/servlet/prt/portal/prtroot/ChangeUser.ChangeUser?logout_submit=true&guest_user=english"
and in English page use following link to swap to Turkish Page :
"/irj/servlet/prt/portal/prtroot/ChangeUser.ChangeUser?logout_submit=true&guest_user=turkish"
Notice that there is a "logout_submit=true" in querystring which actually handle logoff job. I changed Masthead and add following lines to swap languages :
<% if (isAnonymous) { %>
<% if (componentRequest.getUser().getUniqueName().equals("english")) { %>
<TD nowrap >
<a href="/irj/servlet/prt/portal/prtroot/ChangeUser.ChangeUser?logout_submit=true&guest_user=turkish" >Turkish</a></TD>
<% } else { %>
<TD nowrap ><a href="/irj/servlet/prt/portal/prtroot/ChangeUser.ChangeUser?logout_submit=true&guest_user=english" >English</a></TD>
<% } %>
<% } %>