public class I18n extends Object
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
Modifier and Type | Method and 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 exist
|
String |
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.
|
public static I18n getInstance(String serviceName)
serviceName
- name of the service for which messages must be
internationalizedpublic String getString(String key, String locale)
key
- key string in the properties filelocale
- locale in a string formatpublic String getString(String key)
key
- Key string in the properties filepublic String getString(String key, String locale, Object[] params)
key
- key string in the properties filelocale
- locale in a string formatparams
- parameters to be applied to the messagepublic String getString(String key, Object[] params)
key
- Key string in the properties fileparams
- parameters to be applied to the messageCopyright © 2010-2018, ForgeRock All Rights Reserved.