Internationalizing the Command with File I/O Template

Isight supports internationalizing your component so that strings used in GUI labels and in log messages can appear in the language of the currently used locale. The Command with File I/O template includes two of the primary mechanisms used to support internationalization: ResMgr and IString. If you want to internationalize your component, the following descriptions will help you understand how to use these classes.

ResMgr. This class contains several utility methods to provide a consistent way of handling i18n internationalization (i18n) by encapsulating the Class.getResource() method. The Command with File I/O template uses the getMessage method to internationalize strings that are displayed. The following is the typical usage of this method:

ResMgr.getMessage(CLASS, 0, "Some message!");

You should replace 0 with a unique number for each message and you should put all the numbers and corresponding messages in a messages.properties file as key value pairs (e.g., 23=Some message). If you want to localize your component to, for example, the French language then create a messages_fr.properties file and put the translated messages in the file with the corresponding keys (e.g., 23=<French "Some message">. Depending on the locale of the user, Isight automatically picks up the appropriate messages. If there is no particular localization, the third argument of the getMessage() method is used as the default message. The two-letter language codes for each language used for the message file names (messages_<two letter code>.properties) are defined by the ISO-639 standard (refer to the java.util.Locale class).

IString. This class represents an i18n string. It is used similarly to the ResMgr.getMessage() method. However, it is more powerful because the IString object can be persisted to the database in a locale-neutral, component-aware form. You should use IString in messages that will be written to the log (both at design time and at run time).

For more details about these APIs, refer to the Isight javadocs.The following figure shows the Command with File I/O interface: