Understanding message catalogs
The SCOadmin internationalization facility builds on top of
XPG/3 message catalogs by adding these features:
-
one-step lookup of messages
-
grouping of messages by modules
-
language-independent message catalog support
-
simple syntax for module ID files and message description files
-
automatic loading of message catalogs corresponding to a given module
-
automatic configuration of default messages
-
ability to format messages in the manner of
sprintf(3S)
XPG/3 message catalogs are created by
gencat(1).
Each message catalog can contain one or more sets of messages.
The message catalogs
can be further grouped by archives (groups of related catalogs) and
installed on the runtime system. A program wishing to look up a message
uses the
catopen(3C)
function to open the desired catalog and the
catgets(3C)
function to look up the desired message within the desired set, as well
as to supply a default message to use if lookup is not successful or
the default locale is in effect. This scheme requires the programmer
to juggle many pieces of information (archive and catalog name, set
number, message number, and default message) and manage the opening and
closing of message catalogs. If the message needs additional
information, it has to be formatted in an extra step, typically using
sprintf(3S).
For example, a message such as:
"Unable to open file %s"
could be used, but it would need to be passed to sprintf
along with the name of the file in order to create the final string.
Overview of message catalogs
SCOadmin uses the XPG/3 framework but allows the programmer
to look up a message with one call, which takes one parameter, a symbolic
message ID, along with any other parameters needed for
sprintf-style formatting.
Each message ID belongs to a module
known to SCOadmin, which corresponds
to a message set within a message catalog. The SCOadmin internationalization
facility divides the message ID
into a module ID and a specific message
ID, and opens the needed message
catalog (if it was not open before) to
get the requested message. If the catalog can't be loaded, or the default
locale is in effect, the default message
associated with the message ID
is returned. If there are any additional
arguments,
sprintf(3S)
is called to format the final message.
The information required by the SCOadmin internationalization facility
to perform message lookup is listed below:
-
definition of modules, including the module name, and the archive, message
catalog, and message set to which each module belongs. This information
goes in a module ID file.
-
definition of messages within each module, which includes the module
name, specific message name, and a default message. This information goes
in a message description file.
This information is compiled by
mkcatdecl(1)
into message declaration files which must
be included in the program that wishes to use the messages from a
particular module. Each file defines the message IDs corresponding
to the messages from one module, so that the program can use these
IDs for message lookup.
Message declaration files
can be generated for C, Tcl. or both languages.
mkcatdecl also generates files that can be used as a
source file for
gencat(1)
to generate a message catalog. This catalog can then
be installed on the target system so that the SCOadmin
internationalization facility can use it to look up messages.
When you use the SCOadmin internationalization facility to
localize software for more than one locale, you will have multiple
message description files for each module. Use the message description
files corresponding to the default locale to generate your message
declaration files, since they will
contain default messages that correspond to your desired default
locale. For non-default locales, generate only message catalogs.
mkcatdecl has an option to compare two message description files for
the same module to ensure that they both contain the same set
of message IDs.
Next topic:
Creating a module ID declaration file
Previous topic:
Using the SCOadmin internationalization facility
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004