|
The following are the steps involved in enabling the internationalization support to the applications and applets developed using the high-level API.
The MibBrowser.properties file available in the <MibBrowser> directory has to be used as the template file. This file contains the English strings of all the GUI labels and the messages.
The MibBrowser.properties file has to be copied to the specified locale file. For example, if the application or applet that is being developed is to be displayed in French, the MibBrowser.properties has to be copied as MibBrowser_fr_FR.properties file. The language and country are to be represented by the standard two-letter codes (fr - French and FR - France).
The developer has to write the equivalent strings of the chosen language and country in this file. This enables the application to print the user-written strings instead of the English strings. The default English strings is used for strings for which corresponding locale specific strings are not given.
After the above steps, the code changes related to internationalization has to be done in the application or applet source file. The SnmpUIUtils class present in com.adventnet.utils package has to be used for this purpose.
The field Internationalize of the SnmpUIUtils class should be made to true for internationalizing the API. By default it is false. This should be set to true before instantiation.
|
SnmpUIUtils.INTERNATIONALIZE = true; |
Using the method setLocale(Locale) of the SnmpUIUtils class, the locale should be first set. The properties file should be edited with proper localized strings.
|
SnmpUIUtils.setLocale(new Locale("fr","FR")); |
The UI components (menus, dialogs, etc) display the default font, if it is not supported by the specified locale. Otherwise, the font that supports the specified locale has to be set using the setFont(Font) of the SnmpUIUtils class.
The bundle name can be set using the method setBundleName(String) of the SnmpUIUtils class. The bundle name can be specific to the application and the file name of the properties file should be the same as the bundle name with proper locale extended. For example, you can have the bundle name LineGraphBean for an application using LineGraphBean. If the localization was done for Tamil language of country India (ta_IN), the properties file should be named as LineGraphBean_ta_IN.properties.
|
SnmpUIUtils.setBundleName("LineGraphbean"); |
|
|
Note: If the locale and the bundle name are not set, the default properties file, MibBrowser.properties, is used to implement internationalization. |
The method setSearchPath(String) of the SnmpUIUtils class can be used to get the properties file present in other directories. By default, the properties file is searched in the directory in which the application is executed. The path can be set using the above method. In case of applications, the path can be absolute or relative while with applets the path should be relative to the applet document base.
|
SnmpUIUtils.setSearchPath("< path of the properties file >" ); |
Now we can instantiate the bean. In case of applets, the Applet instance should be passed to the SnmpUIUtils class using the method setApplet(Applet).
|
SnmpTarget target = new SnmpTarget(); |
The source files have to be compiled and regenerated to reflect these changes. Now if the application or applet is executed, it has the user-defined strings instead of the default English strings.
|