Overview of localized messages
Localized messages are dependent upon the language and territory in which they are intended to be used, and on the availability of the characters used to represent their contents. This means that localized messages are associated with a specific locale and character set. Character sets and fonts are closely related, and are described in detail in the latter part of this section.
The following figure shows the relationship between localized messages, locales, and character sets:
Messages, locales and character
The Common Language Data Types (CLDT) subsystem provides the class Locale to help determine the current language and territory. These values can be obtained by evaluating Locale current language and Locale current territory. The language and territory of a localized message determine what message text should be displayed.
The VA Smalltalk Common Widgets subsystem enables you to explicitly specify the font used by a particular widget. If localized text is to be displayed correctly, it is critical that you be aware of the fonts (and their coded character sets) that are used in widgets that display this text.
A coded character set defines a mapping between code points (Characters) and glyphs. A character set, in conjunction with a locale, also defines the semantic value of a Character (for example, whether the Character is uppercase, lowercase, a digit, or so on).
The following figure shows the relationship between fonts, code points, and glyphs.
Fonts, code points and glyphs
In addition to font metrics such as size (for example, 11 point) and style (for example, bold, italic) every font maintains a mapping from character values to graphical representations, called a coded character set. The coded character set associated with a font determines how an character value is translated into its graphical representation.
The translation of code points into their visual representation might necessitate that a single localized message for a particular locale be stored separately for each supported character set. Consider the font '-microsoft-courier new-bold-i-normal-0-0-96-96-m-0-iso8859-1,' whose character set is 'iso8859-1.' In this font, the character with the graphical representation à is associated with the code point 224 (Character value: 224). In character set 'ibm-437' the same visual representation is associated with the code point 133 (Character value: 133). Thus, in order to display the text "à la mode", a distinct localized message is required for each character set. It is the developer's responsibility to ensure that localized messages are appropriate for the font of the widgets in which they are being displayed.
Note:
The Common Widgets subsystem allows you to specify the font used by a particular widget explicitly. To display localized text correctly, you must be aware of the fonts (and their character sets) that are used in widgets that display this text.
The following code fragment demonstrates how to query a widget for the character set used by its font. This code fragment assumes that the variable aWidget refers to the widget whose font is being queried. Note that if the font being queried does not conform to the X Logical Font Description (XLFD) naming convention the CgLogicalFontDescription>>name: message can answer nil.
| aWidget fontName fontDescription |
...
fontName := aWidget fontList fontStruct name.
fontDescription := CgLogicalFontDescription name: fontName.
"If font is unknown, use iso8859-1 by default."
fontDescription isNil ifTrue: ^'iso8859-1'].
^fontDescription characterSet
Last modified date: 12/22/2017