Internationalization - Cooperative Portlets

 

+

Search Tips   |   Advanced Search

 

Portlets that support translation of the captions and descriptions associated with shared properties must provide resource bundles in the appropriate location in the WAR file. For IBM portlets, the resource file name to be used can be specified using a configuration parameter in the portlet.xml, c2a-nls-file.

  • The value should be the file name, including the package but omitting the.properties suffix. For example, com.foo.bar.Resource will refer to the file...

    com/foo/bar/Resource.properties

    ...or the appropriate locale suffixed version, for example,...

    com/foo/bar/Resource_en.properties

    For more information about resource bundles, see Accessing Resources in a Location-Independent Manner in the JDK documentation.

  • If this parameter is not specified, the default value of nls.c2a is assumed. This means the that portlet container will look for nls/c2a.properties (or the appropriate locale-suffixed version). There is an example of the use of this parameter in the portlet.xml of pbshipexample.war.

For standard portlets, the resource file is specified using the resource-bundle parameter like this:

<resource-bundle> com.myCo.myApp.myResourceBundle</resource-bundle>

The Java Portlet Specification requires each portlet to provide its own resource bundle.

Translation of the parameter, property, and action captions and descriptions is supported by specifying, for the caption and description attributes of the <portlet:action> element, the name of the key in the resource bundle where the value of these attributes is to be retrieved. For example, from the WSDL file

   <portlet:action name="orderDetails" caption="Order.Details" 
                   description="Get.details.for.specified.order.id"/>

The values for these attributes are obtained from the appropriate resource bundle in the properties file:

    Order.Details=Order Details     Get.details.for.specified.order.id=Get details for specified order id    

A parameter and property pair pick up the caption and description from the same element, <portlet:param>.

For IBM portlets using the programmatic approach for registration, caption and description keys can be set using setTitleKey() and setDescriptionKey(), respectively. These two methods work for the action, parameter, and property elements. Portlets can also support the translation of captions and descriptions using the setLocalizationInfo() method. Captions for actions are displayed in Click-to-Action menus. The actions, parameters, and properties are displayed in the Portlet Wiring Tool.

We can support translation of the caption and description attributes values of the encodeProperties tag. To achieve this, these values must be entered as a key in the appropriate c2a_xx.properties file with the string to be displayed on the right hand side. For example:

    Send.to.all=Send to all 

 

Related information