lucee.Component
    
models.ResourceService
	
	
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com Inspired by Paul Hastings --- This service allows you to work with java/json resource bundles for localization of strings. It also has several convenience methods when working with replacements of localized strings.
| Property Summary | ||||
|---|---|---|---|---|
| type | property | default | serializable | required | 
			struct
		 | 
		
			bundles
			 The bundles loaded into the resource service identifiable by key name. 
  | 
		
			
				true
			
		 | 
		
			
				false
			
		 | 
	|
			any
		 | 
		
			controller
			
  | 
		
			
				true
			
		 | 
		
			
				false
			
		 | 
	|
			any
		 | 
		
			i18n
			
  | 
		
			
				true
			
		 | 
		
			
				false
			
		 | 
	|
			any
		 | 
		
			interceptorService
			
  | 
		
			
				true
			
		 | 
		
			
				false
			
		 | 
	|
			any
		 | 
		
			log
			
  | 
		
			
				true
			
		 | 
		
			
				false
			
		 | 
	|
			any
		 | 
		
			settings
			
  | 
		
			
				true
			
		 | 
		
			
				false
			
		 | 
	|
| Constructor Summary | |
|---|---|
| 
				init()
				 Constructor.  | 
		|
| Method Summary | |
|---|---|
			private any
		 | 
		
			discoverResourcePath(any resourcePath)
			 Locate the resource on disk and check whether it's a Java or JSON bundle.  | 
	
			private any
		 | 
		
			flattenStruct(struct originalStruct, [struct flattenedStruct='[runtime expression]'], [string prefixString=''])
			 flatten a struct, so we can use keys in format 'main.  | 
	
			string
		 | 
		
			formatRBString(any rbString, any values)
			 Performs messageFormat like operation on compound rb string.  | 
	
			string
		 | 
		
			getBundles()
			 | 
	
			string
		 | 
		
			getController()
			 | 
	
			string
		 | 
		
			getI18n()
			 | 
	
			string
		 | 
		
			getInterceptorService()
			 | 
	
			array
		 | 
		
			getLoadedBundles()
			 Get a list of all loaded bundles.  | 
	
			string
		 | 
		
			getLog()
			 | 
	
			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 defaultValue])
			 Returns a given key from a specific resource bundle file and locale.  | 
	
			any
		 | 
		
			getResource(any resource, [any defaultValue], [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.  | 
	
			private any
		 | 
		
			getResourceFileInputStream(string rbFilePath)
			 get Java FileInputStream for resource bundle.  | 
	
			string
		 | 
		
			getSettings()
			 | 
	
			ResourceService
		 | 
		
			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.  | 
	
			private struct
		 | 
		
			loadBundleFromDisk(string resourceBundleFullPath)
			 Load a bundle from disk.  | 
	
			private any
		 | 
		
			loadJavaResource(string resourceBundleFullPath)
			 loads a java resource file from file.  | 
	
			private any
		 | 
		
			loadJsonResource(string resourceBundleFullPath)
			 loads a JSON resource file from file.  | 
	
			string
		 | 
		
			messageFormat(string thisPattern, any args, [any thisLocale=''])
			 performs messageFormat on compound rb string.  | 
	
			any
		 | 
		
			setBundles(struct bundles)
			 | 
	
			any
		 | 
		
			setController(any controller)
			 | 
	
			any
		 | 
		
			setI18n(any i18n)
			 | 
	
			any
		 | 
		
			setInterceptorService(any interceptorService)
			 | 
	
			any
		 | 
		
			setLog(any log)
			 | 
	
			any
		 | 
		
			setSettings(any settings)
			 | 
	
			boolean
		 | 
		
			verifyPattern(string pattern)
			 Performs verification on MessageFormat pattern.  | 
	
| Methods inherited from class lucee.Component | 
|---|
| None | 
| Constructor Detail | 
|---|
Constructor
| Property Detail | 
|---|
The bundles loaded into the resource service identifiable by key name
access - publicrequired - falsereturntype - anyserializable - trueaccess - publicrequired - falsereturntype - anyinject - coldboxserializable - trueaccess - publicrequired - falsereturntype - anyinject - provider:i18n@cbi18nserializable - trueaccess - publicrequired - falsereturntype - anyinject - coldbox:interceptorServiceserializable - trueaccess - publicrequired - falsereturntype - anyinject - logbox:logger:{this}serializable - trueaccess - publicrequired - falsereturntype - anyinject - coldbox:moduleSettings:cbi18nserializable - true| Method Detail | 
|---|
Locate the resource on disk and check whether it's a Java or JSON bundle.
resourcePath - The resource path with no extension includedflatten a struct, so we can use keys in format 'main.sub1.sub2.resource'.
originalStruct - trueflattenedStruct - necessary for recursionprefixStringPerforms 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.
rbString - A localized string with {bnamed|positional} replacementsvalues - Array, Struct or single value to format into the rbStringGet a list of all loaded bundles
Returns an array of keys from a specific resource bundle. NOT FROM MEMORY
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.Returns a given key from a specific resource bundle file and locale. NOT FROM MEMORY
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 retrieverbLocale - The locale of the bundle. Default is en_USdefaultValue - A default value to send back if resource not foundGet a resource from a specific loaded bundle and locale
resource - The resource (key) to retrieve from the main loaded bundle.defaultValue - A default value to send back if the resource (key) not foundlocale - Pass in which locale to take the resource from. By default it uses the user's current set localevalues - An array, struct or simple string of value replacements to use on the resource stringbundle - The bundle alias to use to get the resource from when using multiple resource bundles. By default the bundle name used is 'default'Reads,parses and returns a resource bundle in struct format. It also merges the hierarchical bundles for country and variant if found.
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 bundleget Java FileInputStream for resource bundle
rbFilePath - path + filename for resource, including locale + .propertiesTries to load a resource bundle into ColdBox memory if not loaded already
rBFile - This must be the path + filename UP to but NOT including the locale. We auto-add .properties or .json to the end alongside the localerbLocale - The locale of the bundle to loadforce - Forces the loading of the bundle even if its in memoryrbAlias - 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.Load a bundle from disk
resourceBundleFullPath - full path to a (partial) resourceFileloads a java resource file from file
resourceBundleFullPath - full path to a (partial) resourceFileloads a JSON resource file from file
resourceBundleFullPath - full path to a (partial) resourceFileperforms messageFormat on compound rb string
thisPattern - pattern to use in formattingargs - substitution values, simple or arraythisLocale - locale to use in formatting, defaults to en_USbundlescontrolleri18ninterceptorServicelogsettingsPerforms verification on MessageFormat pattern
pattern - format pattern to test