nsIStringBundle 编辑
intl/strres/public/nsIStringBundle.idl
Scriptable This interface provides functions for retrieving both formatted and unformatted strings from a properties file Inherits from: nsISupports
Last changed in Gecko 1.7This 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论