| java.lang.Object com.ibm.rbm.Resources
Resources | public class Resources (Code) | | A class not to be instantiated. Provides methods for translating items from a resource bundle. To use this class
make sure you first call initBundle(). Once this is done, calling any of the getTranslation() methods will return
the appropriate String.
author: Jared Jackson See Also: com.ibm.rbm.RBManager |
Method Summary | |
public static String[] | getAvailableLocales() Returns an array of strings containing the locale encoding (e.g. | public static String | getCountry(String encoding) Given a locale encoding, returns the country portion of that encoding.
For instance 'en_US', 'sp_US', both return 'US'
Returns null if no country is specified (e.g. | public static String | getLanguage(String encoding) Given a locale encoding, returns the language portion of that encoding. | public static Locale | getLocale() Returns the currently set Locales object. | public static String | getTranslation(String key) Looks up a translation in the currently set Locale by the NLS lookup key provided. | public static String | getTranslation(String key, String lookup) Gets a translation given the currently set locale, a lookup key, and a single lookup item replacement. | public static String | getTranslation(String key, String[] lookup) Gets a translation given the currently set locale, a lookup key, and zero or more lookup item replacements.
Lookup items are contextual translation material stored in the resource according to the format dictated in
the java.text package. | public static String | getVariant(String encoding) Given a locale encoding, returns the variant portion of that encoding.
For instance 'en_GB_EURO', 'de_DE_EURO', both return 'EURO'
Returns null if no variant is specified (e.g. | public static void | initBundle() Initialize the properties of this resource bundle. | public static void | setLocale(Locale locale) |
getAvailableLocales | public static String[] getAvailableLocales()(Code) | | Returns an array of strings containing the locale encoding (e.g. 'en_US', 'de', etc.)
of the locales defined in the current resource bundle. These are all of the locales for
which unique translation of resource bundle items are possible. If a locale encoding is
used to query on that is not in this array, the base class translation will be returned.
|
getCountry | public static String getCountry(String encoding)(Code) | | Given a locale encoding, returns the country portion of that encoding.
For instance 'en_US', 'sp_US', both return 'US'
Returns null if no country is specified (e.g. 'en' or 'de')
|
getLanguage | public static String getLanguage(String encoding)(Code) | | Given a locale encoding, returns the language portion of that encoding.
For instance 'en', 'en_US', 'en_GB', all return 'en'
|
getLocale | public static Locale getLocale()(Code) | | Returns the currently set Locales object.
|
getTranslation | public static String getTranslation(String key)(Code) | | Looks up a translation in the currently set Locale by the NLS lookup key provided.
If no resource by that key is found, the key itself is returned.
|
getTranslation | public static String getTranslation(String key, String lookup)(Code) | | Gets a translation given the currently set locale, a lookup key, and a single lookup item replacement.
For an understanding of the lookup item replacement see getTranslation(String key, String[] lookup).
|
getTranslation | public static String getTranslation(String key, String[] lookup)(Code) | | Gets a translation given the currently set locale, a lookup key, and zero or more lookup item replacements.
Lookup items are contextual translation material stored in the resource according to the format dictated in
the java.text package. In short, numbered markers are replaced by strings passed in as parameters.
For example, suppose you have the following resource:
myResource = Hello {1}, Isn't this a great {2}?
You want to replace the '{1}' witht the current user name and the '{2}' with the name of the day today.
You can do this by calling:
String lookups[] = { "Joe", "Friday" };
Resources.getTranslation("myResource", lookups);
The result would be:
'Hello Joe, Isn't this a great Friday?'
This method (as well as the getTranslation(String key, String lookup) method) is useful for using nested
lookups from the resource bundle. For instance, the above line could be replaced with:
String lookups[] = { getUserName(), Resources.getTranslation("Friday") };
|
getVariant | public static String getVariant(String encoding)(Code) | | Given a locale encoding, returns the variant portion of that encoding.
For instance 'en_GB_EURO', 'de_DE_EURO', both return 'EURO'
Returns null if no variant is specified (e.g. 'en' or 'en_US')
|
initBundle | public static void initBundle()(Code) | | Initialize the properties of this resource bundle. This method must be called once before any
other method can be called (unless that method performs a check that calls this method). This is
also the method to use in case the resource data on the data store has changed and those changes
need to be reflected in future use of this class.
|
setLocale | public static void setLocale(Locale locale)(Code) | | Set the locale to be used when making a query on the resource
|
|
|