Portlet Factory, Version 6.1.2


 

Localized Resource builder

The Localized Resource builder imports the contents of a resource bundle into a variable in the model.

Use this builder to make your column names easier to read. For example, rather than displaying CUSTOMER_NAME, you want to just display the word Customer.

The Localized Resource builder can also be used to change column and field labels, and it can support multiple languages. It lets you pick a resource bundle, which it imports into a variable in your model. You can then use the values from that variable to localize text strings in your model, such as button or column labels. After you add the Localized Resource builder to your model, open up the builder that created the fields (View & Form builder or some other builder based on Data Page), and scroll down to find the Label Translation section. From there, select the locale data or resource bundle you are using.

A resource bundle is a text file (with a .properties file extension) that contains property name and value pairs or a Java class that sets the property values. You can then use the values specified for the properties in the resource bundle to localize text strings in your model, such as button labels, and other builder call inputs. The Localized Resource builder also allows you to set a Locale Key that can be used to specify the path (or portion of the path) to a page you want to import into a model.

Note: The Localized Resource builder must appear before (above) any other builders that perform or incorporate localization tasks. This is because builder calls are executed in the order in which they appear in the builder call list.

The LocaleAware interface

If you use a Java class as a resource bundle instead of a property file, you can use a Java class to implement the following interface in the Factory API.
com.bowstreet.util.locale.LocaleAware

The Java resource bundle interfaces do not tell your resource bundle class which locale is being requested. You can use one generic class that can fetch resources for multiple locales and that uses the LocaleAware interface to determine which locale to request. You can also implement one resource bundle class for each locale (for example, MyResources_en.java and MyResources_fr.java).

For the resource bundle Java class that implements the LocaleAware interface, the IBM® WebSphere Portlet Factory runtime passes the locale to the object so that the object can issue the appropriate locale-specific queries to return the resource bundle data.

The LocaleData variable contains all the localized resources

You can set button labels and other language-specific builder call inputs to values defined in the resource bundle by using the Reference Chooser to select values from the LocaleData variable.

Use Multiple Localized Resource builder calls

If you have more than one resource bundle in a model, enable the Custom Variable Names input. This allows you to incorporate the name of this Localized Resource builder call into the name assigned to the variables created by the builder. Thus, you avoid namespace collisions when multiple resource bundles and Localized Resource builders are located in the same model.

Localize XML structures

You can localize XML structures by including an entry similar to the following in your resource bundle:
ColorOptions=<?xml version="1.0"?> <OptionList><option>Blue</option><option>Red</option></OptionList>

In this case, each property bundle specifies the appropriate values for Red and Blue.

Parent topic: Builder help


Library | Support |