Resource bundles

 

+

Search Tips   |   Advanced Search

 

Resource bundles are used to store text displayed in JSPs or text used in Java code.

To support a new language to IBM WebSphere Portal...

  1. Add resource bundles
  2. Add JSPs for the new language (Optional)
  3. Configure CreateLanguage.xml
  4. Update the list of available languages by adding the new language to the portal using the XML configuration interface

The new language is then listed in the language selection menu boxes that are available in administration portlets, or for example, in...

Edit My Profile | Preferred language

The new language will be available only to portlets that you add to your portal, if these portlets support the newly added language and if you make the required language files available. None of the WebSphere Portal user interface or messages will be translated to the new language.

Resource bundles are located in...

Resource bundles are also found in the deployed war file under...

nls/wp.theme.customizer.ext

To add new resource bundles for additional languages place them into...

The naming convention for resource bundles is...

[bundle]_[language]_[country]_[variant].properties

Portlets define resource bundles as part of their Java Resources. For example, BookmarkPortletView.jsp contains...

<fmt:setBundle basename="com.ibm.portal.examples.nl.BookmarkPortletJSP"/>

<%
    ResourceBundle myText = ResourceBundle.getBundle("com.ibm.portal.examples.nl.BookmarkPortletJSP", request.getLocale());
%>

<h4><fmt:message key="available_bookmarks"/></h4>

...where file...

com.ibm.portal.examples.nl.BookmarkPortletJSP

...contains...

available_bookmarks = Available bookmarks
no_bookmarks = No bookmaks available. Use edit mode to add bookmaks.
undefined = undefined
name = Name
url = URL
set = Set
reset = reset
back = Back to view mode

The ISO standard ISO-639 is used for the language codes of most languages.

For Hebrew the old language code iw is used.

The ISO standard ISO-3166 is used for the country/region codes. WebSphere Portal supports the use of [variant] although resource bundles supplied with the portal do not use it.

If your portal configuration includes Lotus Collaborative Services, for each additional language, add a new...

portal_server_root/shared/app/nls/CSRes_language.properties

WebSphere Portal uses properties files called by...

java.util.ResourceBundle

...to store text rendered in JSPs. The Java mechanism searches for the resource bundles in the following order:

  1. [bundle]_[language]_[country]_[variant].properties
  2. [bundle]_[language]_[country].properties
  3. [bundle]_[language].properties
  4. [bundle].properties

The default bundles [bundle].properties are in English.

 

Add a resource bundle

To add a resource bundle...

  1. Copy all existing resource bundles into...

    portal_server_root\shared\app\nls

  2. Name it according to the naming convention for resource bundles using locale code for the language(s) installed.

  3. Translate the resource bundle files.

  4. Convert it into Unicode with the Native-to-ASCII converter native2ascii

  5. Restart Portal

 

Add JSPs for a new language

Some JSPs that contain mostly text, such as help JSPs, are translated directly which means that the text is contained in the JSP and not in a resource bundle.

For JSPs that do not use resource bundles, copy and translate an existing JSP and store it in the appropriate location.

The location of JSPs can be, for example...

jsp/[mime-type]/[language]/[country]/[variant]/files.jsp

For instance, existing help JSPs are already translated in WebSphere Portal and placed in the relevant [language]and [country] subdirectories. When deciding where to store new JSPs, consider how the portal locates a JSP for rendering its content.

The following is an example of the order in which directories are searched, where path2 is a user-defined path, ie5 is the markup version (here: Internet Explorer 5), and the locale is en_US:

  1. /html/path2/ie5/en_US/mytemplate.jsp
  2. /html/path2/ie5/en/mytemplate.jsp
  3. /html/path2/ie5/mytemplate.jsp
  4. /html/path2/en_US/mytemplate.jsp
  5. /html/path2/en/mytemplate.jsp
  6. /html/path2/mytemplate.jsp
  7. /html/en_US/mytemplate.jsp
  8. /html/en/mytemplate.jsp
  9. /html/mytemplate.jsp
  10. /mytemplate.jsp

This means that if the user language is not supported, the portal will choose the file in the locale independent location, which in the example is the English file.

 

Parent topic

Language support

 

Related tasks

 

Related reference

Sample XML configuration files