A resource bundle contains a series of strings to be presented
at run time. With resource bundles, you can localize your applications
by including a different resource bundle for each language that you
want to support.
Each resource bundle must define a string for each key that is
used in the application. If a Web page lists a key and the resource
bundle for the current user's language does not define a string for
that key, a fatal error will be generated.
To create a resource bundle:
- In the Project Explorer view, right-click the folder in which
you want to create the resource bundle. This folder must be within
the Java™ Resources folder of an EGL Web project.
- From the menu, click . The New window opens.
- In the New window, expand General and click File.
- Click Next.
- In the File name field, type a name for
the new resource bundle. The file name of the resource bundle must
be in this format:
prefix_locale.properties
- prefix
- The prefix of the resource bundle file name is arbitrary, but
the prefix must be the same for each resource bundle in the application.
- locale
- The locale of the resource bundle, such as en_US.
The locale identifies the language of the strings in the bundle and,
optionally, more specific information about the specialization of
the language, such as the dialect, variety, or geographic location.
For more information on locales, see Locales for resource bundles.
For example, a resource bundle that contains English
as it is spoken in the United States might be named
resourceBundle_en_US.properties.
- Click Finish.
The new file is created
in the folder that you right-clicked, and the new file opens in the
editor.
- Add strings to the new resource bundle in the following format:
keyname=stringtext
- keyname
- The key name of the string. This key is placed in the Web pages
to indicate which text from the resource bundle to insert. For example,
a key named WelcomeText might indicate introductory text to be shown
at the top of a page.
- stringtext
- The text that is associated with the key.
- Save and close the file.
You can create as many resource bundles for your application as
you want, but each resource bundle must have a different locale and
the same prefix.