ColdBox Platform v3.8.0

coldbox.system.plugins
Class ResourceBundle

WEB-INF.cftags.component
        extended by coldbox.system.FrameworkSupertype
            extended by coldbox.system.Plugin
                extended by coldbox.system.plugins.ResourceBundle

public class ResourceBundle
extends Plugin

Reads and parses java resource bundles with a nice integration for replacement and MVC usage

Constructor Summary
init(any controller)
          Constructor
 
Method Summary
 string formatRBString(string rbString, any substituteValues)
          performs messageFormat like operation on compound rb string
 struct getBundles()
          Reference to loaded bundles
 string getDefaultLocale()
          Reference to the default application locale
 string getDefaultResourceBundle()
          Reference to the default application resource bundle location
 array getLoadedBundles()
          Get a list of all loaded bundles
 array getRBKeys(any rbFile, [any rbLocale=''])
          Returns an array of keys from a specific resource bundle
 any getRBString(any rbFile, any rbKey, [any rbLocale='en_US'], [any default])
          Returns a given key from a specific resource bundle file and locale
 any getResource(any resource, [any default], [any locale='[runtime expression]'], [any values], [any bundle='default'])
          Get a resource from a specific loaded bundle and locale
 struct getResourceBundle(any rbFile, [any rbLocale='en_US'])
          Reads,parses and returns a resource bundle in struct format
 string getUnknownTranslation()
          Reference to the default application unknown translation string
 struct getVersion()
          Returns version of this CFC and java library it uses
 any loadBundle(string rbFile, [string rbLocale='en_US'], [boolean force='false'], [string rbAlias='default'])
          Tries to load a resource bundle into ColdBox memory if not loaded already
 string messageFormat(string thisPattern, any args, [any thisLocale=''])
          performs messageFormat on compound rb string
 boolean verifyPattern(string pattern)
          Performs verification on MessageFormat pattern
 
Methods inherited from class coldbox.system.Plugin
getPluginDescription, getPluginName, getPluginVersion, getRequestCollection, getRequestContext, getpluginAuthor, getpluginAuthorURL, getpluginPath, setPluginDescription, setPluginName, setPluginVersion, setpluginAuthor, setpluginAuthorURL
 
Methods inherited from class coldbox.system.FrameworkSupertype
$abort, $dump, $htmlhead, $include, $rethrow, $throw, addAsset, announceInterception, getColdboxOCM, getController, getDatasource, getDebugMode, getInterceptor, getMailService, getMailSettings, getMemento, getModel, getModuleSettings, getMyPlugin, getNewMail, getPlugin, getSetting, getSettingStructure, getSettingsBean, getValidationManager, getfwLocale, includeUDF, loadGlobalUDFLibraries, locateDirectoryPath, locateFilePath, persistVariables, populateModel, relocate, renderExternalView, renderLayout, renderView, runEvent, setDebugMode, setNextEvent, setNextRoute, setSetting, setfwLocale, settingExists, validateModel
 
Methods inherited from class WEB-INF.cftags.component
None
 

Constructor Detail

init

public init(any controller)
Constructor

Parameters:
controller
Method Detail

formatRBString

public string formatRBString(string rbString, any substituteValues)
performs messageFormat like operation on compound rb string. So if you have a string with {1} it will replace it. You can also have multiple and send in an array to do replacements.

Parameters:
rbString
substituteValues - Array, Struct or single value to format.

getBundles

public struct getBundles()
Reference to loaded bundles


getDefaultLocale

public string getDefaultLocale()
Reference to the default application locale


getDefaultResourceBundle

public string getDefaultResourceBundle()
Reference to the default application resource bundle location


getLoadedBundles

public array getLoadedBundles()
Get a list of all loaded bundles


getRBKeys

public array getRBKeys(any rbFile, [any rbLocale=''])
Returns an array of keys from a specific resource bundle

Parameters:
rbFile - This must be the path + filename UP to but NOT including the locale. We auto-add the local and .properties to the end.
rbLocale - The locale to use, if not passed, defaults to default locale.

getRBString

public any getRBString(any rbFile, any rbKey, [any rbLocale='en_US'], [any default])
Returns a given key from a specific resource bundle file and locale. NOT FROM MEMORY

Parameters:
rbFile - This must be the path + filename UP to but NOT including the locale. We auto-add the local and .properties to the end.
rbKey - The key to retrieve
rbLocale - The locale of the bundle. Default is en_US
default - A default value to send back if resource not found

getResource

public any getResource(any resource, [any default], [any locale='[runtime expression]'], [any values], [any bundle='default'])
Get a resource from a specific loaded bundle and locale

Overrides:
getResource in class FrameworkSupertype
Parameters:
resource - The resource (key) to retrieve from the main loaded bundle.
default - A default value to send back if the resource (key) not found
locale - Pass in which locale to take the resource from. By default it uses the user's current set locale
values - An array, struct or simple string of value replacements to use on the resource string
bundle - The bundle alias to use to get the resource from when using multiple resource bundles. By default the bundle name used is 'default'

getResourceBundle

public struct getResourceBundle(any rbFile, [any rbLocale='en_US'])
Reads,parses and returns a resource bundle in struct format

Parameters:
rbFile - This must be the path + filename UP to but NOT including the locale. We auto-add the local and .properties to the end.
rbLocale - The locale of the resource bundle

getUnknownTranslation

public string getUnknownTranslation()
Reference to the default application unknown translation string


getVersion

public struct getVersion()
Returns version of this CFC and java library it uses.


loadBundle

public any loadBundle(string rbFile, [string rbLocale='en_US'], [boolean force='false'], [string rbAlias='default'])
Tries to load a resource bundle into ColdBox memory if not loaded already

Parameters:
rbFile - This must be the path + filename UP to but NOT including the locale. We auto-add .properties to the end alongside the locale
rbLocale - The locale of the bundle to load
force - Forces the loading of the bundle even if its in memory
rbAlias - The unique alias name used to store this resource bundle in memory. The default name is the name of the rbFile passed if not passed.

messageFormat

public string messageFormat(string thisPattern, any args, [any thisLocale=''])
performs messageFormat on compound rb string

Parameters:
thisPattern - pattern to use in formatting
args - substitution values, simple or array
thisLocale - locale to use in formatting, defaults to en_US

verifyPattern

public boolean verifyPattern(string pattern)
Performs verification on MessageFormat pattern

Parameters:
pattern - format pattern to test

ColdBox Platform v3.8.0