#include <sbStringBundleService.h>
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) |
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 "&" 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 "&".
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.
|
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.
aURI | URI 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.
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.
aKey | String bundle key. |
aParams | Bundle string format parameters. |
aDefault | Default string value. |
Definition at line 246 of file sbStringBundle.cpp.
nsString sbStringBundle::Format | ( | const char * | aKey, |
nsTArray< nsString > & | aParams, | ||
const char * | aDefault = nsnull |
||
) |
nsString sbStringBundle::Format | ( | const nsAString & | aKey, |
const nsAString & | aParam, | ||
const nsAString & | aDefault = SBVoidString() |
||
) |
nsString sbStringBundle::Format | ( | const char * | aKey, |
const nsAString & | aParam, | ||
const char * | aDefault = nsnull |
||
) |
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.
aKey | String bundle key. |
aDefault | Default string value. |
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.
aKey | String bundle key. |
aDefault | Default string value. |
Definition at line 172 of file sbStringBundle.cpp.
nsString sbStringBundle::Get | ( | const char * | aKey, |
const char * | aDefault = nsnull |
||
) |
|
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.
aBaseStringBundle | Base string bundle. |
aStringBundle | Returned created Songbird string bundle. |
Definition at line 569 of file sbStringBundleService.cpp.