nsIStringBundleService 编辑

intl/strres/public/nsIStringBundle.idlScriptable 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:33 次

字数:5560

最后编辑:6年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文