This software and documentation is subject to and made available only pursuant to the terms of the BEA Systems
License Agreement and may be used or copied only in accordance with the terms of that agreement. It is against the
law to copy the software except as specifically allowed in the agreement. This document may not, in whole or in part,
be copied photocopied, reproduced, translated, or reduced to any electronic medium or machine readable form
without prior consent, in writing, from BEA Systems, Inc.
Use, duplication or disclosure by the U.S. Government is subject to restrictions set forth in the BEA Systems License
Agreement and in subparagraph (c)(1) of the Commercial Computer Software-Restricted Rights Clause at FAR
52.227-19; subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS
252.227-7013, subparagraph (d) of the Commercial Computer Software--Licensing clause at NASA FAR
supplement 16-52.227-86; or their equivalent.
Information in this document is subject to change without notice and does not represent a commitment on the part
of BEA Systems. THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT
WARRANTY OF ANY KIND INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. FURTHER, BEA Systems DOES NOT
WARRANT, GUARANTEE, OR MAKE ANY REPRESENTATIONS REGARDING THE USE, OR THE
RESULTS OF THE USE, OF THE SOFTWARE OR WRITTEN MATERIAL IN TERMS OF CORRECTNESS,
ACCURACY, RELIABILITY, OR OTHERWISE.
Trademarks or Service Marks
BEA, Jolt, Tuxedo, and WebLogic are registered trademarks of BEA Systems, Inc. BEA Builder, BEA Campaign
Manager for WebLogic, BEA eLink, BEA Manager, BEA WebLogic Commerce Server, BEA WebLogic
Enterprise, BEA WebLogic Enterprise Platform, BEA WebLogic Express, BEA WebLogic Integration, BEA
WebLogic Personalization Server, BEA WebLogic Platform, BEA WebLogic Portal, BEA WebLogic Server, BEA
WebLogic Workshop and How Business Becomes E-Business are trademarks of BEA Systems, Inc.
All other trademarks are the property of their respective companies.
Internationalization Guide
Part NumberDocument RevisedSoftware Version
N/AAugust 20, 2002BEA WebLogic Server
Version 7.0
Contents
About This Document
Audience............................................................................................................ viii
e-docs Web Site................................................................................................. viii
How to Print the Document............................................................................... viii
Related Information..............................................................................................ix
About Logger Classes .......................................................................................B-1
Example of a Generated Logger Class..............................................................B-2
C. Loggable Object Reference for BEA WebLogic Server
About Loggable Objects....................................................................................C-1
How Loggable Objects Are Used......................................................................C-2
D. TextFormatter Class Reference for BEA WebLogic Server
About TextFormatter Classes............................................................................D-1
Example of an Application Using a TextFormatter Class.................................D-2
Hybrid Templates for FrameMaker 5.5-v
-viHybrid Templates for FrameMaker 5.5
About This Document
This document defines internationalization and localization, and explains how to use
the templates and tools provided with WebLogic Server to create or edit message
catalogs that are locale-specific.
The document is organized as follows:
Chapter 1, “Overview of Internationalization for WebLogic Server,” summarizes
the processes required for internationalization and localization.
Appendix D, “TextFormatter Class Reference for BEA WebLogic Server,”
provides and example of an application that uses a
Localizers.
Logger class.
TextFormatter class.
Internationalization Guidevii
Audience
This document is written for application developers who must internationalize or
localize the message catalogs included in the WebLogic Server distribution for
locale-specific administration and management. It is assumed that readers are familiar
with the WebLogic Server Platform and know Web technologies, object-oriented
programming techniques, and the Java programming language.
e-docs Web Site
BEA product documentation is available on the BEA corporate Web site. From the
BEA Home page, click on Product Documentation.
How to Print the Document
You can print a copy of this document from a Web browser, one main topic at a time,
by using the File
A PDF version of this document is available on the WebLogic Server documentation
Home page on the e-docs Web site (and also on the documentation CD). You can open
the PDF in Adobe Acrobat Reader and print the entire document (or a portion of it) in
book format. To access the PDFs, open the WebLogic Server documentation Home
page, click Download Documentation, and select the document you want to print.
Adobe Acrobat Reader is available at no charge from the Adobe Web site at
http://www.adobe.com.
viiiInternationalization Guide
→Print option on your Web browser.
Related Information
For more information in general about internationalization and localization, refer to the
following sources:
The Java Developer Connection™ at java.sun.com
The Internationalization section of the World Wide Web Consortium (W3C) Web
Site at
http://www.w3.org
Contact Us!
Your feedback on BEA documentation is important to us. Send us e-mail at
docsupport@bea.com if you have questions or comments. Your comments will be
reviewed directly by the BEA professionals who create and update the documentation.
In your e-mail message, please indicate the software name and version you are using,
as well as the title and document date of your documentation. If you have any questions
about this version of BEA WebLogic Server, or if you have problems installing and
running BEA WebLogic Server, contact BEA Customer Support through BEA
WebSupport at http://www.bea.com. You can also contact Customer Support by using
the contact information provided on the Customer Support Card, which is included in
the product package.
When contacting Customer Support, be prepared to provide the following information:
Your name, e-mail address, phone number, and fax number
Your company name and company address
Your machine type and authorization codes
The name and version of the product you are using
A description of the problem and the content of pertinent error messages
Internationalization Guideix
Documentation Conventions
The following documentation conventions are used throughout this document.
ConventionUsage
Ctrl+TabKeys you press simultaneously.
italicsEmphasis and book titles.
monospace
text
monospace
italic
text
UPPERCASE
TEXT
{ }
[ ]
Code samples, commands and their options, Java classes, data types,
directories, and file names and their extensions. Monospace text also
indicates text that you enter from the keyboard.
An argument can be repeated several times in the command line.
The statement omits additional optional arguments.
You can enter additional parameters, values, or other information
Internationalization Guidexi
xiiInternationalization Guide
CHAPTER
1Overview of
Internationalization
for WebLogic Server
The following sections provide an overview of localization and internationalization:
About Internationalization and Localization Standards
Understanding Localization for WebLogic Server
Understanding Message Catalogs
Understanding Java Interfaces for Internationalization
Main Steps for Creating an Internationalized Message
About Internationalization and Localization
Standards
BEA has adopted the World Wide Web Consortium’s (W3C) recommendations for
standard formats and protocols that are usable worldwide in all languages and in all
writing systems. These standards are part of the Java internationalization Application
Program Interfaces (APIs) that are used by WebLogic Server. Internationalization
Internationalization Guide1-1
1Overview of Internationalization for WebLogic Server
(I18N) refers to the preparation of software so that it behaves properly in multiple
locations. Localization (L10N) is the use of locale-specific language and constructs at
run time.
Internationalization of textual data in WebLogic Server is provided through message
catalogs. WebLogic Server supports message catalogs for log messages as well as
simple text. Log messages contain data that is written to the log file. This data is
predominantly dynamic and contains information that is specific to the current state of
the application and system. When merged with text in a localized log message catalog,
this data results in well-formatted, localized messages that describe the error condition
in the language of the user. The output sent to the console is simple text. As with log
messages, simple text can be merged with dynamic data.
The information covered in this guide addresses only the internationalization of textual
data.
Understanding Localization for WebLogic
Server
Localization covers not only language, but collation, date and time formats, monetary
formats, and character encoding. Messages that are logged to the WebLogic Server
error log can be localized to meet your particular requirements.
WebLogic Server internationalization supports localization of two types of data:
Log messages—Log messages are informational messages that are written to the
server log, and may also contain error messages if the appropriate message
arguments are included in the message definition.
Simple text—Simple text is any text other than log messages and exceptions
that the server must display, such as the output from a utility. Examples of
simple text include usage messages, graphical user interface (GUI) labels, and
error messages.
1-2Internationalization Guide
Understanding Message Catalogs
Understanding Message Catalogs
All internationalized text is defined in message catalogs, each of which defines a
collection of log messages or simple text. To create an internationalized message, you
externalize all message strings in a message catalog so that the strings can be easily
converted to multiple locales without changing or recompiling the code. The
application code supplies run-time values to the logging methods. The logging
methods merge the code with the message string in the catalog per the current locale.
And the application code then prints a localized message in the log files.
There are three types of message catalogs:
Log message catalogs—Collections of log messages.
Simple text catalogs—Collections of simple text messages.
Locale message catalogs—Collections of locale-specific messages
corresponding to a top-level log message or simple text catalog.
Message IDs in log message catalogs or locale message catalogs are unique across all
log message or locale message catalogs. Within the message catalog file, each
localized version of the message is assigned a unique message ID and message text
specific to the error. Ideally, a message is logged from only one location within the
system so that a support team can easily find it. Message IDs in simple text catalogs
are unique within each simple text catalog.
Refer to “Using Message Catalogs with BEA WebLogic Server” on page 2-1 for more
detailed information about message catalogs.
Internationalization Guide1-3
1Overview of Internationalization for WebLogic Server
Understanding Java Interfaces for
Internationalization
WebLogic Server uses the Java internationalization interfaces for providing
internationalization and localization. In addition to understanding how WebLogic
Server handles internationalization, users should be familiar with the Java
internationalization interfaces and the following classes included in the Java
Development Kit (JDK):
ClassDescription
java.util.Locale
java.util.ResourceBundle
java.text.MessageFormat
Represents a specific geographical, political, or
cultural region.
Provides containers for locale-specific objects.
Produces concatenated messages in a language-neutral
way.
Main Steps for Creating an Internationalized
Message
The following steps describe how you create an internationalized message for use with
WebLogic Server:
1. Create or edit a top-level log catalog or simple text catalog by defining the
messages in the catalog. For details, see “Using the BEA WebLogic Server
Message Editor” on page 3-1.
In addition to message text, include information about the type and placement of
any run-time values that the message contains.
1-4Internationalization Guide
Main Steps for Creating an Internationalized Message
2. Run i18ngen to validate the catalog you created or edited in Step 1 and generate
runtime classes.
The generated classes contain a method for each message. The method is defined
according to information specified in the message catalog entry. The methods
include
For details, see “18ngen Utility” on page 4-4.
3. Create locale-specific catalogs as required for the message catalog you created in
Step 1.
Logger or TextFormatter methods, depending on the type of catalog.
4. Run
5. Instrument the application to use the
l10ngen to process the locale-specific catalogs.
Logger or TextFormatter methods you
generated in Step 2. When the application logs or returns a message, the message
is written using the localized version of the text according to the
TextFormatter methods used.
Logger or
These steps are described in detail in the following topics. For more detailed
information, including an overview of the logging subsystem and a description of log
message parts, see “Using Log Messages to Manage WebLogic Servers” in the
WebLogic Server Administration Guide.
Internationalization Guide1-5
1Overview of Internationalization for WebLogic Server
1-6Internationalization Guide
CHAPTER
2Using Message
Catalogs with BEA
WebLogic Server
The following sections describe message catalogs and how to use them:
Overview of Message Catalogs
Message Catalog Hierarchy
Choosing Names for Message Catalogs
Using Message Arguments
Message Catalog Formats
Overview of Message Catalogs
Message catalogs are XML files that contain a description of a collection of text
messages, each indexed by a unique idenifier. You compile these XML files into
classes during the
4-4 for more information). The methods of the resulting classes are the objects used to
log messages at runtime.
i18ngen utility build process. (Refer to “18ngen Utility” on page
Internationalization Guide2-1
2Using Message Catalogs with BEA WebLogic Server
Message catalogs support multiple locales or languages. For a specific message
catalog there is exactly one default version, known as the top-level catalog. Then there
are corresponding locale-specific catalogs, one for each additional supported locale.
The top-level catalog includes all the information necessary to define the message. The
locale-specific catalogs contain only the message ID, the date changed, and the
translation of the message for the specific locale.
The message catalog files are defined by an XML document type definition (DTD).
The DTDs are stored in the
may vary, depending upon where you installed WebLogic Server. If you used the
default installation path, the
under
WL_HOME\samples\server\src\examples\i18n\msgcat.
Two DTDs are included in the WebLogic Server distribution:
msgcat.dtd—Describes the syntax of top-level, default catalogs.
l10n_msgcat.dtd—Describes the syntax of locale-specific catalogs.
msgcat directory also contains templates that you can use to create top-level and
The
locale-specific message catalogs.
Users may choose to create a single log message catalog for all their logging
requirements, or create smaller catalogs based on a subsystem or Java package. We
recommend using multiple subsystems because you can focus on specific portions of
the log during viewing.
msgcat directory. The location of the msgcat directory
msgcat directory is located in the BEA_HOME directory
For simple text catalogs, the recommended approach is to create a single catalog for
each utility being internationalized. Developers can create site-specific message
catalogs using the Message Editor as described in “Using the BEA WebLogic Server
Message Editor” on page 3-1.
Message Catalog Hierarchy
All messages and exceptions must be defined in the default, top-level catalog. The
WebLogic Server distribution includes a collection of sample catalogs in the
Note: This directory path may vary, depending on where you chose to install
WebLogic Server.
Catalogs that provide different localizations of the base catalogs are defined in
subdirectories named for the locale (for example,
might have a top-level catalog named
called
..\de\mycat.xml. Typically the top-level catalog is English, but English is
mycat.xml, and a German translation of it
msgcat\de for Germany). You
not required for any catalogs except the installed WebLogic Server catalogs.
Locale designations (for example,
java.util.Locale documentation. A locale can include a language, country, and
de) also have a hierarchy as defined in the
variant. Language is the most common locale designation. Language can be extended
with a country code. For instance,
the associated catalog is
..\en\US\mycat.xml. Variants are vendor or
en\US, indicates American English. The name of
browser-specific and are used to introduce minor differences (for example, collation
sequences) between two or more locales defined by either language or country.
Choosing Names for Message Catalogs
Because the name of a message catalog file (without the .xml extension) is used to
generate runtime class and property names, you should choose the name carefully.
Follow these guidelines for naming message catalogs:
Do not choose a message catalog name that conflicts with any names of existing
classes in the target package.
msgcat
The message catalog name should only contain characters that are allowed in
class names.
Follow class naming standards.
For example, the resulting class names for a catalog named
XyzLogLocalizer and XyzLogger.
Xyz.xml are
The following considerations also apply to message catalog files:
Message IDs are generally six-character strings with leading zeros. Some
interfaces also support integer representations.
Internationalization Guide2-3
2Using Message Catalogs with BEA WebLogic Server
Java allows you to group classes into a collection called a package. A package
name should be consistent with the name of the subsystem in which a particular
catalog resides.
The log Localizer “classes” are actually ResourceBundle property files.
Using Message Arguments
The message body, message detail, cause, and action sections of a log message can
include message arguments, as described by
message body section in a simple message can include arguments. Arguments are
values that can be dynamically set at runtime. These values are passed to routines, such
as printing out a message. A message can support up to 10 arguments, numbered 0-9.
You can include any subset of these arguments in any text section of the message
definition, although the message body should include all of the arguments. You insert
message arguments into a message definition during development, and these
arguments are replaced by the appropriate message content at runtime when the
message is logged.
java.text.MessageFormat. Only the
The following excerpt from an XML log message definition shows how you can use
message arguments. The argument number must correspond to one of the arguments
specified in the
the second, and so on.
Listing 2-1 Example of Message Arguments
<messagebody>Unable to open file, {0}.</messagebody>
<messagedetail>
File, {0} does not exist. The server will restore the file
contents from {1}, resulting in the use of default values
for all future requests.
</messagedetail>
<cause>The file was deleted</cause>
<action>
If this error repeats then investigate unauthorized access to
the file system.
</action>
2-4Internationalization Guide
method attribute. Specifically, {0} with the first argument, {1} with
An example of a method attribute for the above message is as follows:
-method=“logNoFile(String name, String path)”
The message expects two arguments, {0} and {1}:
{0} is used in the message body.
Both are used in the message detail.
Neither is used in the <cause> or <action> section.
In addition, the arguments are expected to be strings, or representable as strings.
Numeric data is represented as
must assign a severity level for log messages. Log messages are generated through the
generated
Logger methods, as defined by the method attribute.
{n,number}. Dates are supported as {n,date}. You
Message Catalog Formats
The catalog format for top-level and locale-specific catalog files is slightly different.
The top-level catalogs define the textual messages for the base locale. Locale-specific
catalogs only provide translations of text defined in the top-level version. Log message
catalogs are defined differently from simple text catalogs.
Message Catalog Formats
Elements of each of these types of catalogs are described in the following sections:
Elements of a Log Message Catalog
Elements of a Simple Text Message Catalog
Elements of a Locale-Specific Catalog
Elements of a Log Message Catalog
This section provides reference information for the following elements of a log
message catalog:
message_catalog
Internationalization Guide2-5
2Using Message Catalogs with BEA WebLogic Server
log_message
Other log_message Catalog Elements
message_catalog
The following table describes the attributes that you can define for the
message_catalog element.
AttributeDefaultRequired/
Optional
i18n_packageweblogic.i18n
l10n_packageweblogic.i18n
subsystem
version
baseid
NoneRequiredAn acronym identifying the subsystem associated
NoneRequiredSpecifies the version of the msgcat.dtd being
OptionalSpecifies the lowest message ID used in this
Description
for this catalog. The classes are named after the
catalog file name. For example, for a catalog using
mycat.xml, a generated logger class called i18n_package.mycatLogger.class.
LogLocalizer properties for this catalog.
Classes are named after the catalog file name. For
example, for a catalog called
properties file called
l10n_package.mycatLogLocalizer.
properties
with this catalog. The name of the subsystem is
included in the error log and is used for message
isolation purposes.
used. The format is
version=”1.0”. Must be at least “1.0”.
catalog. The syntax is one to six decimal units.
is generated.
n.n, for example,
mycat.xml a
2-6Internationalization Guide
Message Catalog Formats
AttributeDefaultRequired/
Optional
endid
499999
WebLogic Server
catalogs
999999 for
user-defined
catalogs
for
OptionalSpecifies the highest message ID used in this
log_message
The following table describes the attributes that you can define for the log_message
element.
AttributeDefaultRequired/
Optional
messageid
datelastchanged
NoneRequiredUnique identifier for this log message. Uniqueness
NoneOptionalDate/time stamp used for managing modifications
Description
catalog. The syntax is one to six decimal units.
Description
should extend across all catalogs. Value must be in
range defined by baseid and endid attributes. This is
a child element of
to this message. The date is supplied by utilities that
run on the catalogs. The syntax is:
Long.toString(new
Date().getTime());
message_catalog.
severity
stacktracetrue
NoneRequiredIndicates the severity of the log message. Must be
one of the following:
notice, error, critical, alert, or
emergency. User catalogs may only use debug,
info, warning, and error.
OptionalIndicates whether to generate a stack trace for
Throwable arguments. Possible values are
false. When the value is true a trace is
generated. The syntax is:
stacktrace="true"
debug, info, warning,
true or
Internationalization Guide2-7
2Using Message Catalogs with BEA WebLogic Server
AttributeDefaultRequired/
Optional
method
loggablesFalse
NoneRequiredMethod signature for logging this message. Two
OptionalIndicates whether to generate methods to return
Description
methods are actually provided: the one specified
here and a similar one with an additional Throwable
argument.
The syntax is the standard Java method signature,
without the qualifiers, semicolon, and extensions.
Argument types can be any Java primitive or class.
Classes must be fully qualified if not in
java.lang. Classes must also conform to
java.text.MessageFormat conventions. In
general, class arguments should have a useful
toString() method.
Arguments can be any valid name, but should
follow the convention of argn where n is 0 thru 9.
There can be no more than ten (10) arguments. For
argn there should be at least one
each
corresponding placeholder in the text elements
described in “Other log_message Catalog
Elements” on page 2-8. Placeholders are of the form
{n}, {n,number} or {n,date}.
Loggable objects for each message. The syntax is:
loggables="true"
Refer to “Loggable Object Reference for BEA
WebLogic Server” on page C-1
Other log_message Catalog Elements
The following table describes the child elements of the log_message element.
2-8Internationalization Guide
Message Catalog Formats
ElementParent
Element
messagebodylog_message
messagedetaillog_message
causelog_message
actionlog_message
Required/
Description
Optional
RequiredA string containing a short description for this
message. This element may contain zero or more
placeholders,
appropriate argument when the log message is
localized.
RequiredA string containing a detailed description of the
event. This element may contain zero or more
placeholders,
appropriate argument when the log message is
localized.
RequiredA string describing the root cause of the problem.
This element may contain zero or more
placeholders, {n} that are replaced by the
appropriate argument when the log message is
localized.
RequiredA string describing the recommended resolution.
This element may contain zero or more
placeholders, {n} that are replaced by the
appropriate argument when the log message is
localized.
{n} that are replaced by the
{n} that are replaced by the
Log Message Catalog Example
The following example shows a log message catalog, MyUtilLog.xml, with one log
message.
Listing 2-2 Example of a Log Message Catalog
<?xml version="1.0"?>
<!DOCTYPE message_catalog PUBLIC "weblogic-message-catalog-dtd"
"