Create JRas resource bundles and message files

The WebSphere Application Server message logger provides different methods for setting messages. Applications can use either or both, as appropriate.

The JRas framework described in this task and its sub-tasks is deprecated. However, we can achieve similar results using Java logging.

The mechanism for providing localized messages is the resource bundle support provided by the IBM Developer Kit, Java Technology Edition. See the API documentation for the classes:

The application locates the resource bundle based on the file location relative to any directory in the class path. For instance, if the...

...property resource bundle is in...

...and baseDir is in the class path, the name...

...is passed to the message logger to identify the resource bundle.

The JRas extensions do not support the extended formatting options such as {1, date} or {0, number, integer} provided by the MessageFormat class.

We can forward messages that are written to the internal WAS logs to other processes for display. For example, messages displayed on the dmgr console, which can be running in a different location than the server process, can be localized using the late binding process. Late binding means that WAS does not localize messages when they are logged, but defers localization to the process that displays the message. The displaying process must have access to the resource bundle where the message text is stored.


Create a resource bundle

  1. Create a text properties file that lists message keys and the corresponding messages. The properties file must have the following characteristics:

    • Each property in the file is terminated with a line-termination character.

    • If a line contains only white space, or if the first non-white space character of the line is the number sign symbol (#) or exclamation mark (!), the line is ignored. The # and ! characters can therefore be used to put comments into the file.

    • Each line in the file, unless it is a comment or consists only of white space, denotes a single property. A backslash (\) is treated as the line-continuation character.

    • The syntax for a property file consists of a key, a separator, and an element. Valid separators include the equal sign (=), colon (:), and white space ( ).

    • The key consists of all characters on the line from the first non-white space character to the first separator. Separator characters can be included in the key by escaping them with a backslash (\), but using this approach is not recommended because escaping characters is error prone and confusing. Instead, use a valid separator character that does not display in any keys in the properties file.

    • White space after the key and separator is ignored until the first non-white space character is encountered. All characters that remain before the line-termination character define the element.

    See the Java documentation for the java.util.Properties class for a full description of the syntax and construction of properties files.

  2. Translate the file into localized versions of the file with language-specific file names for example, the DefaultMessages.properties file can be translated into DefaultMessages_de.properties for German and DefaultMessages_ja.properties for Japanese.

  3. When the translated resource bundles are available, write them to a system-managed persistent storage medium. Resource bundles are used to convert the messages into the requested national language and locale.

  4. When a message logger is obtained from the JRas manager, configure the logger to use a particular resource bundle. Messages logged through the message API use this resource bundle when message localization is performed. At run time, the user's locale setting is used to determine the properties file from which to extract the message specified by a message key, ensuring the message is delivered in the correct language.

  5. If the message loggers msg method is called, explicitly identify a resource bundle name.


Subtopics


+

Search Tips   |   Advanced Search