In this topic ...Related Topics ...Internationalization: Localization with Resource Bundles. (by Sun Microsystems, Inc.) |
The Localized Resource builder imports the contents of a resource bundle into a variable in the model. A resource bundle is a text file (with a .properties file extension) that contains property name/value pairs or a Java class that sets the property values.
We 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.
For more information about each of these localization techniques, see "Localizing Content ."
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 LocaleData variable contains all the localized resources -- We 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 check box. 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 avoiding name-space collisions when multiple resource bundles and Localized Resource Builders are located in the same model.
Localize XML structures -- We 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.
The Localized Resource builder takes the inputs described in the table below. For help on inputs common to many or all builders such as those in the Properties and HTML Attributes input groups, see "Using the Builder Call Editor."
Input name | Description |
---|---|
Name | Enter a name for this builder call. The designer tool displays this name in the builder call list. |
Resource Bundle Name | Enter the fully-qualified name of the property file
or Java class that serves as the default Resource Bundle. Properties files
or ResourceBundle Java classes must be on the Factory's class path. During
development, store your resource bundles in the Factory's WEB-INF/work/source
directory.
For example, enter com.acme.LabelResources for the property file stored as, WEB-INF/work/source/com/acme/LabelResources.properties |
Ensure Element Validity | Use this input to determine how the Builder handles
invalid XML characters in key names (such as numbers). You
can:
|
Language | Select the ISO language code for the default language.
The Country and Language inputs determine the resource bundle to use based first on the language code (for example, _fr) followed by the country (for example, _CA). Navigate to the following link to see a list of ISO language codes. When the application runs, the JVM loads the resource bundle according to the client's locale and language settings. We can also profile this value to override the resource bundle that gets automatically loaded at execution time. |
Country | Select an ISO country code for the default country.
The Country and Language inputs determine the resource bundle to use based first on the language code (for example, _fr) followed by the country (for example, _CA). Navigate to the following link to see a list of ISO country codes. When the application runs, the JVM loads the resource bundle according to the client's locale and language settings. We can also profile this value to override the resource bundle that gets automatically loaded at execution time. |
Custom Variable Names | Enable this input when you have more than one Localized
Resource builder in a model to allow the two variables created by each
Localized Resource builder to have different names.
When enabled, this check box forces variables created by this builder to use the builder's name as part of the names assigned to the variables created by the builder. For example, the builder call name is used as the variable name (instead of "LocaleData") for the variable that holds the localized text. The builder call name plus an "Info" suffix is used as the variable name for the variable that holds information about the resource bundle. |
Create Lookup Table | Enable this box to add to
the model a lookup table containing localized resource data.
This table will be named <Localized Resource Builder Name>LookupTable and all the correct settings to make a lookup table out of this data will be established. Data in this table can then be access as in any lookup table for use elsewhere in the model. |
When you set up your property files, keep the following in mind:
In order to display a Euro character (or any other character not contained in the ISO 8859-1 set) correctly in the Designer, use the appropriate Unicode escape sequence in the properties file. (In the case of the Euro, that sequence is "\u20AC".) Click here for more information about Unicode values in general.
For more information about creating and using resource bundles, see Internationalization: Localization with Resource Bundles. (by Sun Microsystems, Inc.)