Class I18n


  • @Supported
    public class I18n
    extends Object
    The I18n 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 (see com.iplanet.services.ServiceManager and service registration DTD). The XML file could specify the resource bundle name (the attribute defined in the DTD is i18nFileName) and optionally URL of the jar file which contains the property file (the attribute defined in the DTD is resourceBundleURL). If URL for the jar file is not specified it is assumed that the resource bundle is in the CLASSPATH. 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 static getInstance(String serviceName) method. The parameter serviceName 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 in CLASSPATH

    • 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 file
        locale - 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 file
        locale - locale in a string format
        params - 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 file
        params - parameters to be applied to the message
        Returns:
        Returns value to the specified key