Overview of the message localization process
This section illustrates the VA 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'
Step 1: Replace hard-coded strings with pool dictionary variables
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 51. MyNlsMessage (localized for ('english' 'us'))
'MsgCopy'
'Copy'
'MsgCut'
'Cut'
'MsgPaste'
'Paste'
Step 2: Respond appropriately to the localize message
VA 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:
1. The application queries the current locale and detects that messages should be updated for a ('french' 'france') locale.
2. The application determines which font will be used in the widgets to display localized messages using methods in Common Graphics. Once the font has been determined, its coded character set is queried and found to be 'iso8859-1.'
3. The application retrieves messages for #('french' 'france') and coded character set 'iso8859-1' from an external file using an NlsMessageCatalog. The NlsMessageCatalog automatically rebinds the pool dictionary variables in MyNlsMessages.
Step 3: Ensure that messages are successfully localized
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 52. MyNlsMessage--localized for #('french' 'france')
'MsgCopy'
'Copier'
'MsgCut'
'Découper'
'MsgPaste'
'Affichier'
 
Last modified date: 01/29/2015