|
The following are the steps involved in enabling the internationalization support to the applications and applets developed using the low-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 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 will enable 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 SnmpUtils class present in com.adventnet.utils package has to be used for this purpose.
The field Internationalize of the SnmpUtils class should be made to true for internationalizing the API. By default, it is false. This should be set to true before instantiation.
|
SnmpUtils.INTERNATIONALIZE = true; |
Using the method setLocale(Locale) of the SnmpUtils class, the locale should be first set. The properties file should be edited with proper localized strings.
|
SnmpUtils.setLocale("fr","FR"); |
The bundle name can be set using the method setBundleName(String) of the SnmpUtils class. The bundle name can be specific to the application and the file name of the properties file should be same as the bundle name with proper locale extended. For example, you can have the bundle name SnmpSession for an application using SnmpSession. If the localization was done for Tamil language of country India (ta_IN), the properties file should be named as SnmpSession_ta_IN.properties.
|
SnmpUtils.setBundleName("SnmpSession"); |
|
|
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 SnmpUtils 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.
|
SnmpUtils.setSearchPath("< path of the properties file >" ); |
Now, we can instantiate our class. In case of applets, the Applet instance should be passed to the SnmpUtils class using the method setApplet(Applet) of the SnmpUtils class.
|
SnmpSession session = new SnmpSession(); |
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.
|