A locale is the language environment determined by the application at run time. The
· Code set
These elements are represented by many systems in the following format:
For example, ja_JP.ujis is the representation for Japanese, as used in Japan with the UJIS code set.
As an example of using locales, assume you have an application with two different language versions. You set your XUSERFILESEARCHPATH (see Static output ) to the following (all of which should appear on one line):
This search path allows your application to search from the most specific designation of the locale to the least specific, allowing you a high degree of flexibility in configuring your application. See the explanation of "XtResolvePathname" in Vol. 5 of the O'Reilly & Assoc. X Toolkit Intrinsics Reference Manual for an explanation of the various substitutions and how they relate to the locale designation.
The application must have a way of recognizing the language environment in which it is running. Based on this information, the application can then make adjustments such as allowing the display of strings in the appropriate language. Builder Xcessory provides a code generation option to enable this support in your application.
2. Click the Application tab on the Code Generation Preferences dialog ( Code Generation Preferences Dialog ).
Builder Xcessory inserts code into the main routine to initialize the toolkit I18N features. When the code is compiled and run, the toolkit examines the LANG environment variable to determine the current locale, and then initialize its internal routines to deal with locale-specific issues.
For example, if the user has set the
LANG environment variable to
, the application automatically initializes support for Japanese language character input and display, as well as monetary and date output, and so forth.
If the Initialize Localization Support toggle is not set, you can manually set the locale in your application using the ANSI C function
. The function
sets all locale-specific information to the default (the LANG environment variable). The function
setlocale(LC_COLLATE,"ja_JP.ujis") sets only the collation order to that of the Japanese UJIS code set.
is called from the default language procedure installed by
, described in detail in Asente, Converse, Swick's
also initializes the toolkit internationalization techniques, connects to the input method (if necessary), and sets various defaults for the current locale, as specified by the LANG environment variable.
· Use ANSI C or C++; Kernigan & Ritchie 1 implementations may not support locale-aware string manipulation.
for string comparisons.
routine assumes an ASCII character set when doing string comparisons;
has no such limitation and can deal with locale-specific character encoding and sorting order.
, rather than
as the type for string processing.
type allocates a fixed size (8 or 16 bit, depending on the architecture) for a character. This is not enough to hold the characters of some locales, particularly the idiographic languages. The
type allocates size sufficient to hold the largest character in the current locale. This can be grossly inefficient, so you should only use
for operations that index arrays of characters.
Your application should not explicitly code any language-dependent information. 2 This includes strings, fonts, and language-dependent pixmaps. In order to do this, the Open Group (formerly OSF) suggests that these resources be placed in message catalogs, resource files or UIL files.
Builder Xcessory allows resources to be placed in resource files. Once a resource is set, you can choose (on an individual resource or resource class basis) whether that resource is set in the code or in a resource file.
Individually, this choice is made with the Resource Placement menu, to the right of the text field used to enter the resource value (see Resource Editor Placement Settings ).
Resource values can also be placed in a resource file on a type basis by setting the resource's default resource placement. In the placement window, types can be specified to be put, by default, into Code or App (resource file).
2. Scroll the dialog to find the Compound String and Font types, and set the App toggle for each (see Default Resource Type Settings ).
Builder Xcessory also allows you to generate single or multiple UIL files, providing another language-independent way of specifying resource values that can be used to internationalize an application. To save resources in a UIL file, set the resource to be saved into code and when generating code, generate UIL instead of C or C++.
Once you generate a resource (or UIL) file, you must make copies of the file for each language supported and modify the contents accordingly. Then, using the locale of the machine and the environment variables LANG, UIDPATH, and XUSERFILESEARCHPATH, the different resource or UIL files are read and used by the application at run time.