Class I18n
- java.lang.Object
-
- com.iplanet.services.util.I18n
-
@Supported public class I18n extends Object
TheI18n
class provides methods for applications and services to internationalize their messages.In order for
I18n
to internationalize messages, it needs to determine the resource bundle name, i.e., properties file name.I18n
supports two techniques by which applications and services can specify their I18N resource bundle name. The recommendation is to specify them during service (or application) registration via SMS using a XML file (seecom.iplanet.services.ServiceManager
and service registration DTD). The XML file could specify the resource bundle name (the attribute defined in the DTD isi18nFileName
) and optionally URL of the jar file which contains the property file (the attribute defined in the DTD isresourceBundleURL
). If URL for the jar file is not specified it is assumed that the resource bundle is in theCLASSPATH
. Using this technique it is possible to customize resource bundle name and URL of the jar file by using SMS APIs, commands (CLI) or GUI. The solution makes internationalization of messages very dynamic and highly customizable.I18n
class be instantiated by calling the staticgetInstance(String serviceName)
method. The parameterserviceName
specifies the name of the service as mentioned in the XML file at the time of service registration.Alternatively services and application can instantiate
I18n
object by specifying the resource bundle name (i.e., properties file name). Using this technique it is not possible to customize at runtime either the resource bundle name or the URL of the jar file that contains the properties file name. It is assumed that the properties file is present inCLASSPATH
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static I18n
getInstance(String serviceName)
Method to get an instance of I18n object that has been either previously created or to obtain a new instance if it does'nt existString
getString(String key)
Method to obtain internationalized message from the resource bundle given the key.String
getString(String key, Object[] params)
Method to obtain internationalized message from the resource bundle given the key and parameters.String
getString(String key, String locale)
Method to obtain internationalized message from the resource bundle given the key and locale.String
getString(String key, String locale, Object[] params)
Method to obtain internationalized message from the resource bundle given the key, locale and parameters.
-
-
-
Method Detail
-
getInstance
@Supported public static I18n getInstance(String serviceName)
Method to get an instance of I18n object that has been either previously created or to obtain a new instance if it does'nt exist- Parameters:
serviceName
- name of the service for which messages must be internationalized- Returns:
- I18n object
-
getString
@Supported public String getString(String key, String locale)
Method to obtain internationalized message from the resource bundle given the key and locale.- Parameters:
key
- key string in the properties filelocale
- locale in a string format- Returns:
- returns internationalized message for the specified key
-
getString
@Supported public String getString(String key)
Method to obtain internationalized message from the resource bundle given the key.- Parameters:
key
- Key string in the properties file- Returns:
- Returns value to the specified key
-
getString
@Supported public String getString(String key, String locale, Object[] params)
Method to obtain internationalized message from the resource bundle given the key, locale and parameters.- Parameters:
key
- key string in the properties filelocale
- locale in a string formatparams
- parameters to be applied to the message- Returns:
- returns internationalized message for the specified key
-
getString
@Supported public String getString(String key, Object[] params)
Method to obtain internationalized message from the resource bundle given the key and parameters.- Parameters:
key
- Key string in the properties fileparams
- parameters to be applied to the message- Returns:
- Returns value to the specified key
-
-