Common Desktop Environment: Internationalization Programmer's Guide

Locales

Most single-display clients operate in a single locale that is determined at run time from the setting of the environment variable, which is usually $LANG or the xnlLanguage resource. Locale environment variables, such as LC_ALL, LC_CTYPE, and LANG, can be used to control the environment. See "Xt Locale Management" for more information.

The LC_CTYPE category of the locale is used by the environment to identify the locale-specific features used at run time. The fonts and input method loaded by the toolkit are determined by the LC_CTYPE category.

Programs that are enabled for internationalization are expected to call the XtSetLanguageProc() function (which calls setlocale() by default) to set the locale desired by the user. None of the libraries call the setlocale() function to set the locale, so it is the responsibility of the application to call XtSetLanguageProc() with either a specific locale or some value loaded at run time. If applications are internationalized and do not use XtSetLanguageProc(), obtain the locale name from one of the following prioritized sources to pass it to the setlocale() function:

The empty string makes the setlocale() function use the $LC_* and $LANG environment variables to determine locale settings. Specifically, setlocale (LC_ALL, "") specifies that the locale should be checked and taken from environment variables in the order shown in Table 1-1 for the various locale categories.

Table 1-1 Locale Categories

Category 

1st Env. Var. 

2nd Env. Var. 

3rd Env. Var. 

LC_CTYPE: 

LC_ALL 

LC_TYPE 

LANG 

LC_COLLATE: 

LC_ALL 

LC_COLLATE 

LANG 

LC_TIME: 

LC_ALL 

LC_TIME 

LANG 

LC_NUMERIC: 

LC_ALL 

LC_NUMERIC 

LANG 

LC_MONETARY: 

LC_ALL 

LC_MONETARY 

LANG 

LC_MESSAGES: 

LC_ALL 

LC_MESSAGES 

LANG 

The toolkit already defines a standard command-line option (-lang) and a resource (xnlLanguage). Also, the resource value can be set in the server RESOURCE_MANAGER, which may affect all clients that connect to that server.