public static class BBTranslator
BBTranslator The BBTranslator utility is a BBj CustomObject that utilizes a translation bundle for localization support
Modifier and Type | Field and Description |
---|---|
static BBjNumber | BUFFER_SIZE=10240 A field variable that defines the buffer size |
BBjNumber | Debug A field variable that turns on and off debug capability |
BBjString | DebugFileName! A field variable that contains the location of the debug file. It defaults to 'TranslatorDebug.txt' in the current directory. |
static BBjNumber | MAX_FILE_SIZE=10240000 A field variable that defines the maximum file size |
Modifier and Type | Method and Description |
---|---|
void | clearCache() Clears the namespace cache used by the BBTranslator |
static Locale | createLocale(BBjString p_localeString!) Creates a java Locale object from the passed string If the string is null then null is returned. The string should be in one of the following formats: LANGUAGE LANGUAGE_COUNTRY LANGUAGE_COUNTRY_VARIANT |
static Locale | getClientLocale() Returns the locale used by the client |
static BBjString | getClientLocaleString() Returns the locale string used by the client |
static BBTranslator | getInstance(BBjString p_translationBundleName!) Returns an instance of the BBTranslator given a translation bundle name |
static BBTranslator | getInstance(BBjString p_translationBundleName!, BBjString p_locale!, BBjString p_localeOfOrigin!, BBjString p_translationBundleDir!) Returns an instance of the BBTranslator given a translation bundle name, language, language of origin, and translation bundle directory |
static BBTranslator | getInstance(BBTranslationBundle.html">BBTranslationBundle p_translationBundle!) Returns an instance of the BBTranslator given a translation bundle |
static BBTranslator | getInstance(BBTranslationBundle.html">BBTranslationBundle p_translationBundle!, Locale p_locale!) Returns an instance of the BBTranslator so that there is only one instance per translation bundle and locale |
BBjString | getTranslation(BBjString p_key$) Returns the translated string given a key If the translation is not found, then the passed in key is returned |
BBjString | getTranslation(BBjString p_key$, BBjString p_defaultValue!) Returns the translated string given a key If the translation is not found, then the passed in default value is returned |
BBjString | getTranslation(BBjString p_key$, BBjString p_defaultValue!, BBjNumber p_addIfNotFound) Returns the translated string given a key If the translation is not found, then the passed in default value is returned. The key/value can be added if not found. |
BBjString | getTranslation(BBjString p_key$, BBjString p_defaultValue!, BBjNumber p_addIfNotFound, BBjNumber p_forceAdd) Returns the translated string given a key If the translation is not found, then the passed in default value is returned. The key/value can be added forcefully or if not found. |
BBjString | getTranslation(BBjString p_key$, BBjString p_defaultValue!, BBjNumber p_addIfNotFound, BBjNumber p_forceAdd, BBjNumber p_skipParentLocale) Returns the translated string given a key If the translation is not found, then the passed in default value is returned. The key/value can be added forcefully or if not found. The parent locale translations can be optionally skipped. |
BBTranslationBundle | getTranslationBundle() Returns the translation Bundle |
BBTranslations | getTranslations() Returns all translations for the current locale |
public static BBjNumber BUFFER_SIZE=10240
A field variable that defines the buffer size
public BBjNumber Debug
A field variable that turns on and off debug capability
public BBjString DebugFileName!
A field variable that contains the location of the debug file. It defaults to 'TranslatorDebug.txt' in the current directory.
public static BBjNumber MAX_FILE_SIZE=10240000
A field variable that defines the maximum file size
public void clearCache()
Clears the namespace cache used by the BBTranslator
public static Locale createLocale(BBjString p_localeString!)
Creates a java Locale object from the passed string
If the string is null then null is returned. The string should be in one of the following formats: LANGUAGE LANGUAGE_COUNTRY LANGUAGE_COUNTRY_VARIANT
p_localeString!
A string that specifies local to createpublic static Locale getClientLocale()
Returns the locale used by the client
public static BBjString getClientLocaleString()
Returns the locale string used by the client
public static BBTranslator getInstance(BBjString p_translationBundleName!)
Returns an instance of the BBTranslator given a translation bundle name
p_translationBundleName!
A string that specifies the name of the desired translation bundlepublic static BBTranslator getInstance(BBjString p_translationBundleName!, BBjString p_locale!, BBjString p_localeOfOrigin!, BBjString p_translationBundleDir!)
Returns an instance of the BBTranslator given a translation bundle name, language, language of origin, and translation bundle directory
p_translationBundleName!
A string that specifies the name of the desired translation bundlep_locale!
A string that specifies the Java locale for the current translations in the format 'lang_COUNTRY_VARIANT', where COUNTRY and VARIANT are optionalp_localeOfOrigin!
A string that specifies the locale string for the default translations in the format 'lang_COUNTRY_VARIANT', where COUNTRY and VARIANT are optionalp_translationBundleDir!
A string that specifies the directory in which the translation bundle is locatedpublic static BBTranslator getInstance(BBTranslationBundle.html">BBTranslationBundle p_translationBundle!)
Returns an instance of the BBTranslator given a translation bundle
p_translationBundle!
A BBTranslationBundle object for the translator to usepublic static BBTranslator getInstance(BBTranslationBundle.html">BBTranslationBundle p_translationBundle!, Locale p_locale!)
Returns an instance of the BBTranslator so that there is only one instance per translation bundle and locale
p_translationBundle!
A BBTranslationBundle object for the translator to usep_locale!
A Java Locale object for the current translationspublic BBjString getTranslation(BBjString p_key$)
Returns the translated string given a key
If the translation is not found, then the passed in key is returned
p_key$
A string that specifies the key to translatepublic BBjString getTranslation(BBjString p_key$, BBjString p_defaultValue!)
Returns the translated string given a key
If the translation is not found, then the passed in default value is returned
p_key$
A string that specifies the key to translatep_defaultValue!
A string that specifies the return value if the key is not found; by default the key will be returned when not foundpublic BBjString getTranslation(BBjString p_key$, BBjString p_defaultValue!, BBjNumber p_addIfNotFound)
Returns the translated string given a key
If the translation is not found, then the passed in default value is returned. The key/value can be added if not found.
p_key$
A string that specifies the key to translatep_defaultValue!
A string that specifies the return value if the key is not found; by default the key will be returned when not foundp_addIfNotFound
A number that specifies if the key should be added if not found. 0=the key with the defaultValue should not be added if not found. 1=the key with the defaultValue should be added when not found.public BBjString getTranslation(BBjString p_key$, BBjString p_defaultValue!, BBjNumber p_addIfNotFound, BBjNumber p_forceAdd)
Returns the translated string given a key
If the translation is not found, then the passed in default value is returned. The key/value can be added forcefully or if not found.
p_key$
A string that specifies the key to translatep_defaultValue!
A string that specifies the return value if the key is not found; by default the key will be returned when not foundp_addIfNotFound
A number that specifies if the key should be added if not found. 0=the key with the defaultValue should not be added if not found. 1=the key with the defaultValue should be added when not found.p_forceAdd
A number that specifies if the key should be forcefully added if not found. 0=the key with the defaultValue should not be added if not found. 1=the key with the defaultValue should be added when not found.public BBjString getTranslation(BBjString p_key$, BBjString p_defaultValue!, BBjNumber p_addIfNotFound, BBjNumber p_forceAdd, BBjNumber p_skipParentLocale)
Returns the translated string given a key
If the translation is not found, then the passed in default value is returned. The key/value can be added forcefully or if not found. The parent locale translations can be optionally skipped.
p_key$
A string that specifies the key to translatep_defaultValue!
A string that specifies the return value if the key is not found; by default the key will be returned when not foundp_addIfNotFound
A number that specifies if the key should be added if not found. 0=the key with the defaultValue should not be added if not found. 1=the key with the defaultValue should be added when not found.p_forceAdd
A number that specifies if the key should be forcefully added if not found. 0=the key with the defaultValue should not be added if not found. 1=the key with the defaultValue should be added when not found.p_skipParentLocale
A number that specifies if the parent locale translations should be skipped. 0=skip, 1=do not skippublic BBTranslationBundle getTranslationBundle()
Returns the translation Bundle
public BBTranslations getTranslations()
Returns all translations for the current locale