nsIStringBundleService 编辑
intl/strres/public/nsIStringBundle.idl
Scriptable 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.7Implemented 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
|
|
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
- Code snippets : Miscellaneous : Using string bundles from JavaScript
- How to localize html pages, xul files, and js/jsm files from bootstrapped add-ons. The localizing js/jsm files uses the
nsIStringBundleService
: Bootstrapped Extensions :: Localization (L10n) - nsIStringBundle
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论