org.browsecode.helpers
Class Translator

java.lang.Object
  extended by org.browsecode.helpers.Translator

public class Translator
extends java.lang.Object

Support for multiple bundles of language translation files -- thus, we can use files from several sources. Vaguely based on Ekit's Translatrix.


Constructor Summary
Translator()
           
 
Method Summary
 void addBundle(java.util.ResourceBundle bundle)
           
 void addBundle(java.lang.String bundleName, java.util.Locale locale)
           
 void automaticallyAddSomeBundles()
          Automatically load as many bundles as possible -- for now, from the SurveyEditor and from Ekit.
static Translator defaultTranslator()
          This intentionally breaks the "get" rule where the method should start with get.
static java.lang.String getTranslated(java.lang.String keyTextString)
          Same as getTranslatedString, but static.
 java.lang.String getTranslatedString(java.lang.String originalText)
           
static boolean hasDefaultTranslator()
           
 void setAsDefaultTranslator()
          Set this instance as the default translator instance, so that anyone using this class statically will get this instance instead of another one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Translator

public Translator()
Method Detail

setAsDefaultTranslator

public void setAsDefaultTranslator()
Set this instance as the default translator instance, so that anyone using this class statically will get this instance instead of another one.


automaticallyAddSomeBundles

public void automaticallyAddSomeBundles()
Automatically load as many bundles as possible -- for now, from the SurveyEditor and from Ekit.


addBundle

public void addBundle(java.lang.String bundleName,
                      java.util.Locale locale)

addBundle

public void addBundle(java.util.ResourceBundle bundle)

getTranslated

public static java.lang.String getTranslated(java.lang.String keyTextString)
Same as getTranslatedString, but static.

Parameters:
originalText -
Returns:

hasDefaultTranslator

public static boolean hasDefaultTranslator()

defaultTranslator

public static Translator defaultTranslator()
This intentionally breaks the "get" rule where the method should start with get. This breaks it because this method is so rarely used, and getTranslated is used very frequently. So, to make tab completion the fastest for so many times, it breaks the rule and becomes an exception intentionally.

Returns:

getTranslatedString

public java.lang.String getTranslatedString(java.lang.String originalText)