Typically, interactive applications make extensive use of labels, menus, and help text, all of which require localization in an international application. An internationalized application that fetches all localized messages at once and stores them within the image using pool dictionary variables should not experience any decrease in user interface response compared to an application that uses hard-coded message strings. An application might also contain descriptive error messages that are used only when an condition arises. By maintaining the localized messages on secondary storage and only loading them as required, the memory requirements of the application are reduced.
The NlsMessageCatalog has been designed to efficiently support these two predominant uses of display text in applications through the following two mechanisms.
External message dictionaries are designed for use when all localized messages are to be retrieved at once and stored in a pool dictionary within Smalltalk. External message dictionaries are identified by locale and character set, and for this reason only one message dictionary can be stored in an NlsMessageCatalog for a given locale and character set.
An external message dictionary is a Dictionary keyed by a message identifier (pool dictionary variable name) containing localized messages. NlsMessageCatalog provides protocols specifically tailored for storing and retrieving pool dictionaries containing localized messages.
Indexed external messages are designed for use when messages are maintained on secondary storage and loaded individually, as needed. Indexed external messages are identified by locale, character set, and a numeric message identifier.
An indexed external message is a single, localized message that is identified numerically and stored for a particular locale and character set. The NlsMessageCatalog provides protocols specifically tailored for storing and retrieving indexed messages. Indexed external message identifiers are integers and should be assigned sequentially starting at 1, because a collection whose size corresponds to the largest indexed message identifier is maintained on secondary storage. The careful numbering of messages can reduce the amount of space needed in secondary storage.
Messages externalized using a NlsMessageCatalog (both external message dictionaries and indexed external messages) typically contain only strings, but can contain any Smalltalk object that can be dumped by the Swapper without special dumping options. (Refer to the IBM Smalltalk User's Guide for a complete description of limitations.)
Although the NlsMessageCatalog is capable of storing Smalltalk objects other than strings, the developer should be aware that platform resource files cannot store arbitrary Smalltalk objects. If the message catalog is to be converted to a platform resource format, it must only contain strings.
Instances of NlsMessageCatalog are associated with a single disk file. NlsMessageCatalog instances are created using NlsMessageCatalog>>#on:, which takes a single String argument that specifies the absolute or relative pathname of the new or existing message catalog file.
"Create an NlsMessageCatalog using an absolute path." NlsMessageCatalog on: 'c:\nls\message.cat' "Windows & OS/2" NlsMessageCatalog on: '/usr/nls/messages.cat' "UNIX" "Create an NlsMessageCatalog in the current directory." NlsMessageCatalog on: 'messages.cat'.