nsIStringBundleService

我们的志愿者还没有将这篇文章翻译为 中文 (简体) 。加入我们帮助完成翻译!

Provides the string bundle service, which provides a way to fetch localized strings from a property file.
Inherits from: nsISupports Last changed in Gecko 1.7

Implemented by: @mozilla.org/intl/stringbundle;1. To access this service, use:

var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
                                    .getService(Components.interfaces.nsIStringBundleService);

Method overview

nsIStringBundle createBundle(in string aURLSpec);
nsIStringBundle createExtensibleBundle(in string aRegistryKey);
void flushBundles();
wstring formatStatusMessage(in nsresult aStatus, in wstring aStatusArg);

Methods

createBundle()

nsIStringBundle createBundle(
  in string aURLSpec
);
Parameters
aURLSpec
The URL of the properties file to load. This is typically a locale URL, e.g. chrome://global/locale/global.properties
Return value

A string bundle corresponding to the properties file. This string bundle has functions available on it.

On the return value object on you can call functions like GetStringFromName and formatStringFromName see nsIStringBundle.

 

createExtensibleBundle()

nsIStringBundle createExtensibleBundle(
  in string aRegistryKey
);
Parameters
aRegistryKey
The name of the category under which the properties file(s) have been registered.
Return value

An extensible bundle corresponding to the properties file(s).

flushBundles()

Flushes the string bundle cache - useful when the locale changes or when we need to get some extra memory back. (Automatically called for the memory-pressure and chrome-flush-caches global observer topics.)

void flushBundles();
Parameters

None.

formatStatusMessage()

Formats a message string from a status code and status arguments. Typically used to format a message received by a nsIProgressEventSink's onStatus method.

wstring formatStatusMessage(
  in nsresult aStatus,
  in wstring aStatusArg
);
Parameters
aStatus
The status code. This is mapped into a string ID and and used in the string lookup process (see nsIErrorService).
aStatusArg
The status message argument(s). Multiple arguments can be separated by newline ('\n') characters.
Return value

The formatted message.

See also

文档标签和贡献者

向此页面作出贡献: Noitidart, Sheppy, Neil, Wjjohnst, trevorh
最后编辑者: Noitidart,