Constructing and using message catalogs

Constructing and using message catalogs

In an effort to better internationalize application software, message catalogs are used in place of hard-coded messages within the actual code. All input, output, and error messages are precompiled and stored in message catalogs that are outside of the code. Using message catalogs, the user need not change an application's hard-coded messages and be forced to recompile when a language change is required. Instead, the program will present all messages in a specified language according to the values of certain environment variables. A language change would involve a simple change to an environment variable at runtime. Needless to say, message catalogs allow greater flexibility to users as well as provide an alternative to the often difficult task of modifying hard-coded applications written for another language.

A message catalog is created by a message source file using the gencat(CP) command. They can be accessed and used within software using the catopen(S), catgets(S), and the catclose(S) routines.

For more background about message catalogs or internationalizing code in general, see the Open Software Foundation's Internationalization Made Easy White Paper.

The following example code gives an example of how to construct a simple message catalog and then how to incorporate it into a program. To understand the example code, you should understand the role of environment variables; particularly the variables LC_MESSAGES, LC_ALL, LANG, and NLSPATH. The precise meanings of these variables are defined in setlocale(S).

Next topic: Creating a message catalog

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003