UpPreviousNext

Text Output

An internationalized application displays all text in the user's chosen language. This includes prompts, error messages, and text on buttons, menus, and other widgets. The simplest approach to this requirement is to remove all strings that are to be displayed from the source code of the application and store them in a file that will be read when the application starts up. That file can then be translated into various languages, with the appropriate version being read at start-up.

In addition, an internationalized application must display times, dates, numbers, and so on, in the format that the user expects. For example, Americans expect dates in the form month/day/year, English expect day/month/year, and Germans expect day.month.year.

Setting Up Localized Output

Most languages use words from different languages and some require the word's native character set to be used. For example, a Japanese application might require error messages with a mix of Hirigana, Katakana, and Kanji characters, as well as some technical terms that require a Latin character set. This means that in one string there could be 5 words using Kanji characters and one word using Latin characters, requiring 2 different fonts.


Note: It is possible to display characters of multiple character sets within the same output string using compound strings and font lists.

Compound Strings

A compound string is a byte stream in ASN.1 encoding, consisting of tag-length-value segments.

Motif uses compound strings in many widgets. A compound string is used to set labels on label and button widgets as well as the contents of lists in Motif. These compound strings hold all information related to a string, including the text, direction and font used to display the string.

Compound string components

A compound string can contain the following components:

· Text of the string

· Separators (or line breaks)

· Font list tags

· Direction identifiers

Compound String Editor

The Compound String Editor allows strings to have multiple fonts and direction, and allows for a connection to an X input method. For more information on the Compound String Editor, refer to Compound String Editor .

Motif does not supply a String-to- XmString converter that understands font list tags or direction information. Builder Xcessory provides a String-to-XmString converter in the bxutils file, which supports Builder Xcessory style ASCII representations of compound strings.

Template code

The template code for the converter is in the file:

{BX}/xcessory/gen/common/bxutils.c

ASCII compound string format

The ASCII compound string format is:

:: [#tag][:t][:r]["xxxxx"]

where:

tag is font tag (or charset).

:t is set when a separator is requested.

:r is set when the string is displayed from right to left.

"xxxxx" is the text portion of the string.

Creating Multifont and Multidirectional Strings

A font list is a resource type that can be a single font or a font set. Font sets were introduced in X11R5 and Motif 1.2 (as the XFontSet). A font set is treated as a single entry in a font list, but contains all the fonts required to display all the characters of a locale. Internal X, Motif, and C routines are used to encode the font information for displaying a given string.

Font List Editor

The Font List Editor in Builder Xcessory supports the specification of font sets as well as regular Fonts (see Font List Editor ). For more information on the Font List Editor, refer to Font List Editor .

 

Font List Editor

You create the different font sets and tag them, so that they can be used in defining multifont strings.


Note: A font set is defined by the locale in which the program is running. For example, a font set that works in a Korean locale will not work in a Japanese locale.

Each font set member can use a different encoding, family, size, and so forth, and there are no limits on how many fonts can be defined for a given font set.

Once a font set has been added to a font list, it can be used like any other entry in the list. Motif and X control how to use the various fonts in the font set.

bxutils file

Although Motif 1.2 supports multiple entry font lists containing both fonts and font sets, Motif does not supply a String-to- XmString converter that understands font list tags or direction information. Builder Xcessory provides such a converter in the bxutils file. This converter is installed in your application by a call to RegisterBxConverters(). The converter supports a special textual representation of all the information encoded in a compound string: font tag, direction, etc. This allows you to quickly create multifont and multidirectional strings and use them with the Motif widget set, even though they are not supported in Motif 1.2. This code is completely portable and OS independent.

UpPreviousNext