Class Index | File Index

Classes


Class CAAT.Module.Locale.ResourceBundle


Defined in: ResourceBundle.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
<private>  
Current set locale.
<private>  
Default locale info.
 
Original file contents.
 
Is this bundle valid ?
Method Summary
Method Attributes Method Name and Description
<private>  
__formatString(string, args)
A formated string is a regular string that has embedded holder for string values.
<private>  
__init(resourceFile, asynch, onSuccess, onError)

Load a bundle file.

 
getString(id, defaultValue, args)
 
loadDoc(resourceFile, asynch, onSuccess, onError)
Class Detail
CAAT.Module.Locale.ResourceBundle()
Field Detail
<private> __currentLocale
Current set locale.

<private> __defaultLocale
Default locale info.

localeInfo
Original file contents.

valid
Is this bundle valid ?
Method Detail
<private> {string} __formatString(string, args)
A formated string is a regular string that has embedded holder for string values. for example a string like: "hi this is a $2 $1" will be after calling __formatString( str, ["string","parameterized"] ); "hi this is a parameterized string" IMPORTANT: Holder values start in 1.
Parameters:
string
{string} a parameterized string
args
{object} object whose keys are used to find holders and replace them in string parameter
Returns:
{string}

<private> {*} __init(resourceFile, asynch, onSuccess, onError)

Load a bundle file. The expected file format is as follows: { "defaultLocale" : "en-US", "en-US" : { "key1", "value1", "key2", "value2", ... }, "en-UK" : { "key1", "value1", "key2", "value2", ... } }

defaultLocale is compulsory.

The function getString solves as follows:

  • a ResouceBundle object will honor browser/system locale by searching for these strings in the navigator object to define the value of currentLocale:
      navigator.language
        navigator.browserLanguage
          navigator.systemLanguage
            navigator.userLanguage
          • the ResouceBundle class will also get defaultLocale value, and set the corresponding key as default Locale.
          • a call to getString(id,defaultValue) will work as follows:
              1)     will get the value associated in currentLocale[id]
              2)     if the value is set, it is returned.
              2.1)       else if it is not set, will get the value from defaultLocale[id] (sort of fallback)
              3)     if the value of defaultLocale is set, it is returned.
              3.1)       else defaultValue is returned.
            
  • Parameters:
    resourceFile
    asynch
    onSuccess
    onError
    Returns:
    {*}

    {string} getString(id, defaultValue, args)
    Parameters:
    id
    {string} a key from the bundle file.
    defaultValue
    {string} default value in case
    args
    {Array.=} optional arguments array in case the returned string is a parameterized string.
    Returns:
    {string}

    loadDoc(resourceFile, asynch, onSuccess, onError)
    Parameters:
    resourceFile
    asynch
    onSuccess
    onError

    Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT)