Setting language for URL mapping

The URL mapping can also be used to set language for portal page. Ex. Lets say i have a requirement that whenever set of users go to portal page they should always get German page or other set gets Spanish set.
In order to implement this i created a URL mapping like this

<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" build="wp6101_115_01" type="update" version="6.1.0.1" xsi:noNamespaceSchemaLocation="PortalConfig_6.1.0.xsd">
<portal action="locate">
<content-node action="locate" objectid="homePage" uniquename="ibm.portal.Home" />
<url-mapping-context action="update" domain="rel" label="germanhome" >
<access-control externalized="false" owner="uid=wasadmin,o=defaultwimfilebasedrealm" private="false"/>
<portal-url resourceref="homePage" update="set" locale="de" />
</url-mapping-context>
<url-mapping-context action="update" domain="rel" label="spanishhome" >
<access-control externalized="false" owner="uid=wasadmin,o=defaultwimfilebasedrealm" private="false" />
<portal-url resourceref="homePage" update="set" locale="es" />
</url-mapping-context>
</portal>
</request>

Here i created two URL mappings two home page the first <url-mapping> element has lable germanhome that means create a URL with context equal to german home. The <portal-url> element defines the actual page that you want to map this URL to, in my case i am creating mapping to home page. Setting of locale='de' for <portal-url>, makes sure that user gets this page in german. Once you go to this page, Locale for the user would be set to German and would remain German even when he goes to other page until it is explicitly change.

Import the sample xmlaccess script in your portal and then try accessing http://localhost:10040/wps/portal/germanhome url and you should get all the pages in german. Now if you want set user locale to spanish try accessing http://localhost:10040/wps/portal/spanishhome.

Using the XML configuration interface is the only method for changing the locale of a URL Mapping.

No comments: