nsIStringBundle 编辑

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

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

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

发布评论

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

词条统计

浏览:53 次

字数:7411

最后编辑:6 年前

编辑次数:0 次

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