com.ca.commons.cbutil
Class CBIntText

java.lang.Object
  |
  +--com.ca.commons.cbutil.CBIntText

public class CBIntText
extends java.lang.Object

This 'International Text' static class acts as a central source of all localised strings. If it cannot find a localised properties file, the default (english) file is used. If that file can not be found, the key used to look up the translation is returned unchanged - hence it is useful if the keys are meaningful in their own right (i.e. use 'File' rather than 'String 42' as a key).

Currently the class is static to provide easy access to i18n text by all classes and plugins, and because it is difficult to see how supporting multiple different-locale languages would be helpful (note that multiple languages can be supported simply by using unicode).


Constructor Summary
CBIntText()
           
 
Method Summary
static void addBundle(java.lang.String bundleLocation, java.lang.ClassLoader customLoader)
          Once init() has been called, this method can be used to add multiple resource bundles to the universal 'CBIntText' list of translations.
static java.lang.String get(java.lang.String key)
          This attempts to get the localised version of a string.
static void init(java.lang.String bundleLocation, java.lang.ClassLoader customLoader)
          This initialises the international text class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CBIntText

public CBIntText()
Method Detail

init

public static void init(java.lang.String bundleLocation,
                        java.lang.ClassLoader customLoader)
This initialises the international text class.

Parameters:
bundleLocation - the name of the i18n bundle (e.g. "language/JX_ja.properties").
customLoader - a custom class loader (may be null). JX uses a custom loader that auto-detects unicode and utf-8 files for ease of configuration by non-expert users.

addBundle

public static void addBundle(java.lang.String bundleLocation,
                             java.lang.ClassLoader customLoader)
Once init() has been called, this method can be used to add multiple resource bundles to the universal 'CBIntText' list of translations. Note that clashes (i.e. translations of identical terms) are resolved with the earliest registered bundle having priority. (i.e. if both JX and a plugin have a translation for 'file', the JX one will be used). If this is a problem, remember that the translated string is arbitrary - e.g. a plugin could translate the string 'pluginFile' instead.


get

public static java.lang.String get(java.lang.String key)
This attempts to get the localised version of a string. If anything goes wrong, it attempts to return the key string it was given - hence using a meaningfull key is a good harm minimization strategy.