This section illustrates the IBM Smalltalk model by demonstrating how messages are localized in response to a change in locale and a particular character set in response to the localize message. The following localization process ensures that the application contains messages appropriate for the current locale.
For purposes of demonstration we define the class MyNlsEnabledClass that is controlled by MyNlsEnableApplication as follows. Further assume that the pool dictionary variables used in MyNlsMessages have initialized (via initialization code) to contain messages for an English U.S. locale and the iso8859-1 character set.
Object subclass: MyNlsEnabledClass instanceVariableNames: 'instvar1 instvar2' classVariableNames: '' poolDictionaries: 'MyNlsMessages'
The programmer has internationalized the
MyNlsEnabledApplication and placed the three messages used by the
class (MsgCut, MsgCopy, MsgPaste) into a
shared pool called MyNlsMessages. The initial
state--localized for ('english' 'us')--of the
MyNlsMessage pool is shown in the following table.
Table 50. MyNlsMessage (localized for ('english' 'us'))
'MsgCopy' | 'Copy' |
'MsgCut' | 'Cut' |
'MsgPaste' | 'Paste' |
IBM Smalltalk initializes the current locale when the Smalltalk image is started, and sends the localize message to all loaded applications. The application that controls MyNlsEnabledClass responds to the localize message as follows:
All references to the pool dictionary variables contained in
MyNlsMessages now contain appropriately localized messages for the
current locale and the desired character set. The final state of the
MyNlsMessages pool is shown in the following table.
Table 51. MyNlsMessage--localized for #('french' 'france')
'MsgCopy' | 'Copier' |
'MsgCut' | 'Découper' |
'MsgPaste' | 'Affichier' |