Common Desktop Environment: Internationalization Programmer's Guide

Localized Resources

This section describes which widget and gadget resources are locale-sensitive. The information is organized by related functionality. For example, the first section describes those resources that are locale-sensitive for widgets used to display labels or to provide push-button functionality.

Labels and Buttons

Table 2-2 lists the localized resources that are used as labels. Many of them are of type XmString. The rest are of type color or char*. See the Motif 1.2 Reference Manual for detailed descriptions of these resources. In each case, the application should not hardcode these resources. If resource values need to be specified by the application, it should be done with the app-defaults file, ensuring that the resource can be localized.

Only the widget class resources are listed here; subclasses of these widgets are not listed. For example, the XmDrawnButton widget class does not introduce any new resources that are localized. However, it is a subclass of the XmLabelWidget widget class; therefore, its accelerator resource, acceleratorText resource, and so on, are also localized and should not be hardcoded by an application.

Table 2-2 Localized Resources

Widget Class 

Resource Name 

Core

*background: [The foreground and background colors are not localized due to restrictions in the X protocol that require color names to be limited to the portable character set. Localized color names are left to applications to provide a localized database to map to a name encoded with the portable character set.]

XmCommand

*command:

XmCommand

*promptString:

XmFileSelectionBox

*dirListLabelString:

XmFileSelectionBox

*fileListLabelString:

XmFileSelectionBox

*filterLabelString:

XmFileSelectionBox

*noMatchString:

XmLabel[Gadget]

*accelerator:

XmLabel[Gadget]

*acceleratorText:

XmLabel[Gadget]

*labelString:

XmLabel[Gadget]

*mnemonic:

XmList

*stringDirection:

XmManager

*stringDirection:

XmMessageBox

*cancelLabelString:

XmMessageBox

*helpLabelString:

XmMessageBox

*messageString:

XmMessageBox

*okLabelString:

XmPrimitive

*foreground:1

XmRowColumn

*labelString:

XmRowColumn

*menuAccelerator:

XmRowColumn

*mnemonic:

XmRowColumn(SimpleMenu*)

*buttonAccelerators:

XmRowColumn

*mnemonic:

XmRowColumn

*mnemonic:

XmRowColumn

*mnemonic:

XmRowColumn

*mnemonic:

XmSelectionBox

*applyLabelString:

XmSelectionBox

*cancelLabelString:

XmSelectionBox

*helpLabelString:

XmSelectionBox

*listLabelString:

XmSelectionBox

*okLabelString:

XmSelectionBox

*selectionLabelString:

XmSelectionBox

*textAccelerators:

Note that the XmRowColumn widget has additional string resources that may be localized. These resources are listed in the XmRowColumn man page, under the heading "Simple Menu Creation Resource Set." As the title implies, these resources affect only RowColumn widgets created with the XmCreateSimpleMenu() function. The resources affected are: *buttonAccelerators, *buttonAcceleratorText, *buttonMnemonics,*optionLabel, and *optionMnemonic. These resources are not included in Table 2-2 because they are rarely used and apply to RowColumn only when creating a simple menu.

List Resources

Several widgets allow applications to set or read lists of items in the widget. Table 2-3 shows which widgets allow this and the resources they use to set or read these lists. Because the list items may need to be localized, do not hardcode these lists. Rather, they should be set as resources in app-defaults files, allowing them to be localized. The type for each list is XmStringList.

Table 2-3 Resources Used for Reading Lists

Widget Class 

Resource Name 

XmList

*items:

XmList

*selectedItems:

XmSelectionBox

*listItems:

Title

Table 2-4 lists the resources used for setting titles and icon names. Normally, an application need only set the *title: and *iconName: resources. The encoding of each is automatically detected for clients doing proper locale management. All of these are of type char or XmString.

Table 2-4 Resources Used for Setting Titles and Icon Names

Widget Class 

Resource Name 

TopLevelShell

*iconName:

TopLevelShell

*iconNameEncoding: [This resource should not be set by the application. If the application calls XtSetLanguageProc, the default value (None) of this resource will automatically be set, ensuring that localized text can be used for the title.]

WmShell

*title:

WmShell

*titleEncoding: 1

XmBulletinBoard

*dialogTitle:

XmScale

*titleString:

Text Widget

Table 2-5 lists the Text[Field] resources that are locale-sensitive or about which the developer of an internationalized application should know.

Table 2-5 Locale-Sensitive Text[Field] Resources

Widget Class 

Resource Name 

XmSelectionBox

*textColumns: [The *columns resource specifies the initial width of the Text[Field] widget in terms of the number of characters to be displayed. In the case of a variable width font or in a locale where the size of a character varies significantly, a column is the amount of space required to display the widest character in that locale's character repertoire. For example, a column width of 10 guarantees that at least 10 characters of the current locale can be displayed; it is possible (likely) that more than that number of characters can be displayed in the allocated space.]

XmSelectionBox

*textString:

XmText

*columns:1

XmText

*modifyVerifyCallback:

XmText

*modifyVerifyCallbackWcs:

XmText

*value:

XmText

*valueWcs:

XmTextField

*columns:1

XmTextField

*modifyVerifyCallback:

XmTextField

*modifyVerifyCallbackWcs:

XmTextField

*value:

XmTextField

*valueWcs:

Input Method (Keyboards)

Table 2-6 lists localized resources for customizing the input method. These resources allow the user or the application to control which input method will be used for the specified locale and which preedit style (if applicable and available) will be used.

Table 2-6 Localized Resources for Input Method Customization

Widget Class 

Resource Name 

VendorShell

*inputMethod:

VendorShell

*preeditType:

Pixmap (Icon) Resources

Table 2-7 lists pixmap resources. In some cases, a different pixmap may be needed for a given locale.

Table 2-7 Pixmap Resources

Widget Class 

Resource Name 

Core

*backgroundPixmap:

WMShell

*iconPixmap:

XmDragIcon

*pixmap:

XmDropSite

*animation[Mask|Pixmap]:

XmLabel[Gadget]

*labelInsensitivePixmap:

XmLabel[Gadget]

*labelPixmap:

XmMessageBox

*symbolPixmap:

XmPushButton[Gadget]

*armPixmap:

XmToggleButton[Gadget]

*selectInsensitivePixmap:

XmToggleButton[Gadget]

*selectPixmap:

A pixmap is a screen image that is stored in memory so that it can be recalled and displayed when needed. The desktop has a number of pixmap resources that allow the application to supply pixmaps for backgrounds, borders, shadows, label and button faces, drag icons, and other uses. As with text, some pixmaps may be specific to particular language environments; these pixmaps must be localized.

The desktop maintains caches of pixmaps and images. The XmGetPixmapByDepth() function searches these caches for a requested pixmap. If the requested pixmap is not in the pixmap cache and a corresponding image is not in the image cache, the XmGetPixmapByDepth() function searches for an X bitmap file whose name matches the requested image name. The XmGetPixmapByDepth() function calls the XtResolvePathname() function to search for the file. If the requested image name is an absolute path name, that path name is the search path for the XtResolvePathname() function. Otherwise, the XmGetPixmapByDepth() function constructs a search path in the following way:

These paths may include the %B substitution field. In each call to the XtResolvePathname() function, the XmGetPixmapByDepth() function substitutes the requested image name for %B. The paths may also include other substitution fields accepted by the XtResolvePathname() function. In particular, the XtResolvePathname() function substitutes the display's language string for %L, and it substitutes the components of the display's language string (in a vendor-dependent way) for %l, %t, and %c. The substitution field %T is always mapped to bitmaps, and %S is always mapped to Null.

Because there is no string-to-pixmap converter supplied by default, pixmaps are generally set by the application at creation time by first retrieving the pixmap with a call to XmGetPixmap(). XmGetPixmap() uses the current locale to determine where to locate the pixmap. (See the XmGetPixmap() man page for a description of how locale is used to locate the pixmap.)

Font Resources

Table 2-8 lists the localized font resources. All XmFontList resources are of type XmFontList. In almost all cases, a fontset should be used when specifying a fontlist element. The only exception is when displaying character data that does not appear in the character set of the user (for example, displaying math symbols or dingbats).

Table 2-8 Localized Font Resources

Widget Class 

Resource Name 

VendorShell

*buttonFontList:

VendorShell

*defaultFontList:

VendorShell

*labelFontList:

VendorShell

*textFontList:

XmBulletinBoard

*buttonFontList:

XmBulletinBoard

*defaultFontList:

XmBulletinBoard

*labelFontList:

XmBulletinBoard

*textFontList:

XmLabel[Gadget]

*fontList:

XmList

*fontList:

XmMenuShell

*buttonFontList:

XmMenuShell

*defaultFontList:

XmMenuShell

*labelFontList:

XmText

*fontList:

XmTextField

*fontList: