Common Desktop Environment: Internationalization Programmer's Guide

Programming for Internationalized User Interface Language

The UIL compiler parses nonstandard charsets as locale text. This requires the UIL compiler to be run in the same locale as any locale text.

If the locale text of a widget requires a font set (more than one font), the font set must be specified within the resource file. The font parameter does not support font sets.

To use a specific language with UIL, a UIL file is written according to characteristics of the target language and compiled into a UID file. The UIL file that contains localized text needs to be compiled in the locale in which it is to run.

String Literals

The following shows examples of literal strings. The cur_charset value is always set to the default_charset value, which allows the string literal to contain locale text.

To set locale text in the string literal with the default_charset value, enter the following:

XmNlabelString = 'XXXXXX';

OR

XmNlabelString = #default_charset"XXXXXX";

Compile the UIL file with the LANG environment variable matching the encoding of the locale text. Otherwise, the string literal is not compiled properly.

Font Sets

The font set cannot be set through UIL source programming. Whenever the font set is required, you must set it in the resource file as the following example shows:

*fontList: -*-r-*-20-*:

Font Lists

UIL has three functions that are used to create font lists: FONT, FONTSET, and FONT_TABLE. The FONT and FONTSET functions create font list entries. The FONT_TABLE function creates a font list from these font list entries.

The FONT function creates a font list entry containing a font specification. The argument is a string representing an XLFD font name. The FONTSET function creates a font list entry containing a font set specification. The argument is a comma-separated list of XLFD font names representing a base name font list.

Both FONT and FONTSET have optional CHARACTER_SET declaration parameters that specify the font list element tag for the font list entry. In both cases, if no CHARACTER_SET declaration parameter is specified, UIL determines the font list element tag as follows:

The FONT_TABLE function creates a font list from a comma-separated list of font list entries created by FONT or FONTSET. The resulting font list can be used as the value of a font list resource. If a single font list entry is supplied as the value for such a resource, UIL converts the entry to a font list.

Creating Resource Files

If necessary, set the input method-related resources in the resource file as shown in the following example:

*preeditType:				OverTheSpot, OffTheSpot, Root, or None

Setting the Environment

For a locale-sensitive application, set the UID file to the appropriate directory. Set the UIDPATH or XAPPLRESDIR environment variable to the appropriate value.

For example, to run the uil_sample program with an English environment (LANG environment variable is en_US), set uil_sample.uid with Latin characters at the $HOME/en_US directory, or set uil_sample.uid to a directory and set the UIDPATH environment variable to the full path name of the uil_sample.uid file.

To run the uil_sample program with a Japanese environment (LANG environment variable is ja_JP), create a uil_sample.uid file with Japanese (multibyte) characters at the $HOME/ja_JP directory, or place uil_sample.uid to a unique directory and set the UIDPATH environment variable to the full path name of the uil_sample.uid file. The following list specifies the possible variables:

%U

Specifies the UID file string.

%N

Specifies the class name of the application.

%L

Specifies the value of the xnlLanguage resource or LC_CTYPE category.

%l

Specifies the language component of the xnlLanguage resource or the LC_CTYPE category.

If the XAPPLRESDIR environment variable is set, the MrmOpenHierarchy() function searches the UID file in the following order:

  1. UID file path name

  2. $UIDPATH

  3. %U

  4. $XAPPLRESDIR/%L/uid/%N/%U

  5. $XAPPLRESDIR/%l/uid/%N/%U

  6. $XAPPLRESDIR/uid/%N/%U

  7. $XAPPLRESDIR/%L/uid/%U

  8. $XAPPLRESDIR/%l/uid/%U

  9. $XAPPLRESDIR/uid/%U

  10. $HOME/uid/%U

  11. $HOME/%U

  12. /usr/lib/X11/%L/uid/%N/%U

  13. /usr/lib/X11/%l/uid/%N/%U

  14. /usr/lib/X11/uid/%N/%U

  15. /usr/lib/X11/%L/uid/%U

  16. /usr/lib/X11/%l/uid/%U

  17. /usr/lib/X11/uid/%U

  18. /usr/include/X11/uid/%U

    If the XAPPLRESDIR environment variable is not set, the MrmOpenHierarchy() function uses $HOME instead of the XAPPLRESDIR environment variable.