Common Desktop Environment: Internationalization Programmer's Guide

Locale Management

The term language environment refers to the set of localized data that the application needs to run correctly in the user-specified locale. A language environment supplies the rules associated with a specific language. In addition, the language environment consists of any externally stored data, such as localized strings or text used by the application. For example, the menu items displayed by an application might be stored in separate files for each language supported by the application. This type of data can be stored in resource files, User Interface Definition (UID) files, or message catalogs (on XPG3-compliant systems).

A single language environment is established when an application runs. The language environment in which an application operates is specified by the application user, often either by setting an environment variable (LANG or LC_* on POSIX-based systems) or by setting the xnlLanguage resource. The application then sets the language environment based on the user's specification. The application can do this by using the setlocale() function in a language procedure established by the XtSetLanguageProc() function. This causes Xt to cache a per-display language string that is used by the XtResolvePathname() function to find resource, bitmap, and User Interface Language (UIL) files.

An application that supplies a language procedure can either provide its own procedure or use an Xt default procedure. In either case, the application establishes the language procedure by calling the XtSetLanguageProc() function before initializing the toolkit and before loading the resource databases (such as by calling the XtAppInitialize() function). When a language procedure is installed, Xt calls it in the process of constructing the initial resource database. Xt uses the value returned by the language procedure as its per-display language string.

The default language procedure performs the following tasks:

The application can use the default language procedure by making the call to the XtSetLanguageProc() function in the following manner:

XtSetLanguageProc(NULL, NULL, NULL);
  		.
  		.
toplevel = XtAppInitialize(...);

By default, Xt does not install any language procedure. If the application does not call the XtSetLanguageProc() function, Xt uses as its per-display language string the value of the xnlLanguage resource if it is set. If the xnlLanguage resource is not set, Xt derives the language string from the LANG environment variable.


Note -

The per-display language string that results from this process is implementation-dependent, and Xt provides no public means of examining the language string once it is established.


By supplying its own language procedure, an application can use any procedure it wants for setting the language string.