Packageorg.granite.util
Classpublic class InternalBundle
SubclassesValidationMessages

Utility (abstract) class for embedded resources bundles loading and resource lookup.

Bundles loaded by this class must be in the Java XML properties format, ie:

  <properties>
      <entry key="hello.world">Salut tout le monde!</entry>
  </properties>
  



Public Methods
 MethodDefined by
  
InternalBundle(bundleName:String)
Constructs a new InternalBundle instance.
InternalBundle
  
getString(resourceName:String, parameters:Array = null, locale:String = null):String
Look for a resource named resourceName in the loaded Flex application bundles (with the bundle name provided at creation time) and, if it cannot be found, look for it in this internal bundle properties.
InternalBundle
Protected Methods
 MethodDefined by
  
addBundle(locale:String, properties:XML, defaultBundle:Boolean = false):void
Add XML resources properties for the given locale.
InternalBundle
Constructor detail
InternalBundle()constructor
public function InternalBundle(bundleName:String)

Constructs a new InternalBundle instance.

Parameters
bundleName:String — the name of this resources bundle, that will be used for standard Flex ResourceManager looking.

See also

mx.resources.ResourceManager
getString
Method detail
addBundle()method
protected function addBundle(locale:String, properties:XML, defaultBundle:Boolean = false):void

Add XML resources properties for the given locale.

Parameters
locale:String — the locale in which the properties are given (eg: "fr" or "fr_FR").
 
properties:XML — a XML object that contains resources properties for the locale.
 
defaultBundle:Boolean (default = false)true if this bundle should be used as a fallback bundle when a resource for a given locale cannot be found. Default is false.
getString()method 
public function getString(resourceName:String, parameters:Array = null, locale:String = null):String

Look for a resource named resourceName in the loaded Flex application bundles (with the bundle name provided at creation time) and, if it cannot be found, look for it in this internal bundle properties.

Locale resolution with internal bundles is performed by using the usual Java algorithm: if "fr_FR" is passed as the locale (or if it appears in the current locale chain), this class will first try to find a bundle for this exact locale (as passed to the addBundle method); if no such bundle can be found, it will try to find a bundle for the less restrictive "fr" locale; if it fails again, it will try to use the default bundle.

If a parameters array is passed to this method, the parameters in it are converted to Strings and then substituted, in order, for the placeholders "{0}", "{1}", and so on, in the string before it is returned.

If the specified resource is not found, this method returns null.

Parameters
resourceName:String — the name of a resource in the resource bundle.
 
parameters:Array (default = null) — an Array of parameters that are substituted for the placeholders. Each parameter is converted to a String with the toString() method before being substituted.
 
locale:String (default = null) — a specific locale to be used for the lookup, or null to search all locales in the localeChain. This parameter is optional and defaults to null; you should seldom need to specify it.

Returns
String — the resource value, or null if it is not found.