sbStringBundle Class Reference

#include <sbStringBundleService.h>

Inheritance diagram for sbStringBundle:
[legend]
Collaboration diagram for sbStringBundle:
[legend]

Public Member Functions

virtual ~sbStringBundle ()
 
 sbStringBundle (const char *aURI=nsnull)
 
 sbStringBundle (nsIStringBundle *aBundle)
 
nsString Get (const nsAString &aKey, const nsAString &aDefault=SBVoidString())
 
nsString Get (const char *aKey, const char *aDefault=nsnull)
 
nsString Format (const nsAString &aKey, nsTArray< nsString > &aParams, const nsAString &aDefault=SBVoidString())
 
nsString Format (const char *aKey, nsTArray< nsString > &aParams, const char *aDefault=nsnull)
 
nsString Format (const nsAString &aKey, const nsAString &aParam, const nsAString &aDefault=SBVoidString())
 
nsString Format (const char *aKey, const nsAString &aParam, const char *aDefault=nsnull)
 

Static Public Member Functions

NS_DECL_ISUPPORTS static
NS_DECL_NSISTRINGBUNDLE
nsresult 
New (nsIStringBundle *aBaseStringBundle, sbStringBundle **aStringBundle)
 

Detailed Description

This class implements the Songbird string bundle.

The Songbird string bundle provides an enhanced set of string bundle services. In particular, this class allows string bundles to include other string bundles and to include bundle strings in other bundle strings. To include one or more string bundles in a top-level string bundle, define the string "include_bundle_list" in the top-level bundle. This string should consist of a comma separated list of included string bundle URI's. When the Songbird string bundle object looks up a string, it will look in the top-level string bundle and all included string bundles. The included string bundles can include additional string bundles too. Note that circular string bundle includes will lead to errors or hangs. To include a bundle string in another bundle string, encapsulate the included bundle string in "&" and ";", much like XML entities. Use "&amp;" for a literal "&".

Example:

include_bundle_list=chrome://bundles1.properties,chrome://bundle2.properties

string1=World string2=Hello & Everyone Else

string2 evaluates to "Hello World & Everyone Else".

This class implements the Songbird string bundle object. This class provides support for including string bundles within string bundles. A string bundle may specify a list of included string bundles by setting the string "include_bundle_list" to a comma separated list of string bundle URI specs. When looking up a string, this class will search the string bundle as well as all of its included string bundles and their included string bundles. This class also provides support for string substitutions. A string may be substituted within another string by specifying its key as "&<key>;". A literal "&" may be specified as "&amp;".

Included string bundle example:

include_bundle_list=chrome://branding/locale/brand.properties,chrome://songbird/locale/other.properties

String substitution example:

brandShortName=Acme rocket_skates.eula= is not responsible for any damage & injury caused by our Rocket Skates.

Definition at line 175 of file sbStringBundleService.h.

Constructor & Destructor Documentation

sbStringBundle::~sbStringBundle ( )
virtual

Destroy a Songbird string bundle instance.

Definition at line 598 of file sbStringBundleService.cpp.

sbStringBundle::sbStringBundle ( const char *  aURI = nsnull)

Construct a Songbird string bundle with the string bundle URI specified by aURI. If aURI is not specified, use the default Songbird string bundle. Upon any failure, ensure that use of the Songbird string bundle is safe.

Parameters
aURIURI of string bundle.

Definition at line 93 of file sbStringBundle.cpp.

sbStringBundle::sbStringBundle ( nsIStringBundle *  aBundle)

Construct a Songbird string bundle with the string bundle specified by aBundle.

Member Function Documentation

nsString sbStringBundle::Format ( const nsAString &  aKey,
nsTArray< nsString > &  aParams,
const nsAString &  aDefault = SBVoidString() 
)

Get and return the formatted string with the bundle key specified by aKey and the parameters specified by aParams. If the string cannot be found, return the string specified by aDefault; if aDefault is not specified, return aKey.

Parameters
aKeyString bundle key.
aParamsBundle string format parameters.
aDefaultDefault string value.
Returns
Bundle string.

Definition at line 246 of file sbStringBundle.cpp.

Here is the caller graph for this function:

nsString sbStringBundle::Format ( const char *  aKey,
nsTArray< nsString > &  aParams,
const char *  aDefault = nsnull 
)

Definition at line 293 of file sbStringBundle.cpp.

Here is the call graph for this function:

nsString sbStringBundle::Format ( const nsAString &  aKey,
const nsAString &  aParam,
const nsAString &  aDefault = SBVoidString() 
)

Definition at line 321 of file sbStringBundle.cpp.

Here is the call graph for this function:

nsString sbStringBundle::Format ( const char *  aKey,
const nsAString &  aParam,
const char *  aDefault = nsnull 
)

Definition at line 338 of file sbStringBundle.cpp.

Here is the call graph for this function:

nsString sbStringBundle::Get ( const nsAString &  aKey,
const nsAString &  aDefault = SBVoidString() 
)

Get and return the string with the bundle key specified by aKey. If the string cannot be found, return the string specified by aDefault; if aDefault is not specified, return aKey. Upon any failure, ensure that use of the Songbird string bundle is safe.

Parameters
aKeyString bundle key.
aDefaultDefault string value.
Returns
Bundle string.

Get and return the string with the bundle key specified by aKey. If the string cannot be found, return the string specified by aDefault; if aDefault is not specified, return aKey.

Parameters
aKeyString bundle key.
aDefaultDefault string value.
Returns
Bundle string.

Definition at line 172 of file sbStringBundle.cpp.

Here is the caller graph for this function:

nsString sbStringBundle::Get ( const char *  aKey,
const char *  aDefault = nsnull 
)

Definition at line 209 of file sbStringBundle.cpp.

Here is the call graph for this function:

nsresult sbStringBundle::New ( nsIStringBundle *  aBaseStringBundle,
sbStringBundle **  aStringBundle 
)
static

Create a new instance of a Songbird string bundle using the base string bundle specified by aBaseStringBundle. Return the Songbird string bundle in aStringBundle.

Parameters
aBaseStringBundleBase string bundle.
aStringBundleReturned created Songbird string bundle.

Definition at line 569 of file sbStringBundleService.cpp.


The documentation for this class was generated from the following files: