You can use the current Language Locale in the Portal to drive the localization of a portlet.
The WPS User object allows you to get the language preference of users from their user profile.
The Locale Selection Handler is used to select a profile by matching a user's locale to a profile within a specified profile set. This handler determines the user's locale by using the HttpServletRequest.getLocale()
method on the Locale object to get the locale name as a string.
The locale value is built up with the language, country, and variant separated by underscores ("en_US_WIN
" or "de_DE
"). The language is always lower case (such as "en
" for English) and the country is always upper case (such as "GB
"). If the language is missing, the string will begin with an underscore (for example, "_GB
The Locale Selection Handler can also be used with a standalone web application.
To profile a portlet based on the user's locale:
- In IBM® WebSphere® Portal Admin: Create the users for your portal application.
- In IBM WebSphere Portlet Factory Designer's Profile Manager:
- Create a Locale profile set (with language-specific profiles).
- Use the Select Handler editor to set the selection handler for the profile set to Locale Selection Handler.
- In WebSphere Portlet Factory Designer: Profile the builder call inputs that will drive the variability of your portlet.
- In WebSphere Portlet Factory Designer's Profile Manager: In the Manage Profiles editor, edit the profiles and for each profile use the Add External button to associate one or more locale names for the profile segment.
For example, if you created a profile named "English", you should associate en and en_US with that profile.
- In WebSphere Portal Admin: Set permissions for each of your portlets for each IBM WebSphere Application Server language locale.
- In WebSphere Portal Admin: Test your profiling by logging in as one of the users and accessing the profiled portlets.
Parent topic: Profiling a portlet