nsIStringBundle

This interface provides functions for retrieving both formatted and unformatted strings from a properties file.
Inherits from: nsISupports Last changed in Gecko 1.7

This interface is used by XUL:stringbundle to retrieve strings. It is recommended that you use the methods of XUL:stringbundle to access these functions unless necessary. Alternatively, a string bundle can be created within a javascript context with nsIStringBundleService.

Method overview

wstring formatStringFromID(in long aID, [array, size_is(length)] in wstring params, in unsigned long length);
wstring formatStringFromName(in wstring aName, [array, size_is(length)] in wstring params, in unsigned long length);
nsISimpleEnumerator getSimpleEnumeration();
wstring GetStringFromID(in long aID);
wstring GetStringFromName(in wstring aName);

Methods

formatStringFromID()

Returns a formatted string with the given ID from the string bundle, where each occurrence of %S (uppercase) is replaced by each successive element in the supplied array. You may also use other formatting codes. You can only pass Unicode strings in. The ID should refer to a string in the bundle that uses %S, and the number of strings you pass MUST be the same here and in the properties file (That is you can't omit %1 and use only %2). Do NOT try to use any other types. This uses nsTextFormatter::smprintf.

wstring formatStringFromID(
  in long aID,
  [array, size_is(length)] in wstring params,
  in unsigned long length
);
Parameters
aID
The ID of the string to retrieve.
params
Parameters to pass in to the string.
length
The length of the parameter list.
Return value

Returns the formatted string.

formatStringFromName()

Returns a formatted string with the given key name from the string bundle, where each occurrence of %S (uppercase) is replaced by each successive element in the supplied array. You may also use other formatting codes, but can only pass Unicode strings in. The name should refer to a string in the bundle that uses %S, and the number of strings you pass MUST be the same here and in the properties file (That is you can't omit %1 and use only %2). Do NOT try to use any other types. This uses nsTextFormatter::smprintf to do the dirty work.

wstring formatStringFromName(
  in wstring aName,
  [array, size_is(length)] in wstring params,
  in unsigned long length
);
Parameters
aName
The name of the string to retrieve.
params
Parameters to pass in to the string.
length
The length of the parameter list.
Return value

Returns the formatted string.

getSimpleEnumeration()

nsISimpleEnumerator getSimpleEnumeration();
Parameters

None.

Return value

Returns a nsISimpleEnumerator of all nsIPropertyElement entries in the string bundle.

GetStringFromID()

Retrieves a string from the bundle by its ID.

wstring GetStringFromID(
  in long aID
);
Parameters
aID
The ID of the string to retrieve. String ID's are assigned by the order in which they are stored in the properties file.
Return value

Returns the requested string.

GetStringFromName()

Retrieves a string from the bundle by its name.

wstring GetStringFromName(
  in wstring aName
);
Parameters
aName
The name of the string to retrieve. String name are designated in the properties file.
Return value

Returns the requested string.

See also

Document Tags and Contributors

 Last updated by: gfritzsche,