|
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 #include "nsISimpleEnumerator.idl" |
|
8 |
|
9 %{C++ |
|
10 |
|
11 // Define Contractid and CID |
|
12 // {D85A17C1-AA7C-11d2-9B8C-00805F8A16D9} |
|
13 #define NS_STRINGBUNDLESERVICE_CID \ |
|
14 { 0xd85a17c1, 0xaa7c, 0x11d2, \ |
|
15 { 0x9b, 0x8c, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } } |
|
16 |
|
17 #define NS_STRINGBUNDLE_CONTRACTID "@mozilla.org/intl/stringbundle;1" |
|
18 |
|
19 /** |
|
20 * observer needs to check if the bundle handle matches |
|
21 */ |
|
22 #define NS_STRBUNDLE_LOADED_TOPIC "strbundle-loaded" |
|
23 |
|
24 %} |
|
25 |
|
26 native nsStrBundleLoadedFunc(nsStrBundleLoadedFunc); |
|
27 |
|
28 [scriptable, uuid(D85A17C2-AA7C-11d2-9B8C-00805F8A16D9)] |
|
29 interface nsIStringBundle : nsISupports |
|
30 { |
|
31 wstring GetStringFromID(in long aID); |
|
32 wstring GetStringFromName(in wstring aName); |
|
33 |
|
34 // this is kind of like smprintf - except that you can |
|
35 // only pass it unicode strings, using the %S formatting character. |
|
36 // the id or name should refer to a string in the bundle that |
|
37 // uses %S.. do NOT try to use any other types. |
|
38 // this uses nsTextFormatter::smprintf to do the dirty work. |
|
39 wstring formatStringFromID(in long aID, |
|
40 [array, size_is(length)] in wstring params, |
|
41 in unsigned long length); |
|
42 wstring formatStringFromName(in wstring aName, |
|
43 [array, size_is(length)] in wstring params, |
|
44 in unsigned long length); |
|
45 /* |
|
46 Implements nsISimpleEnumerator, replaces nsIEnumerator |
|
47 */ |
|
48 nsISimpleEnumerator getSimpleEnumeration(); |
|
49 |
|
50 }; |
|
51 |
|
52 [scriptable, uuid(D85A17C0-AA7C-11d2-9B8C-00805F8A16D9)] |
|
53 interface nsIStringBundleService : nsISupports |
|
54 { |
|
55 nsIStringBundle createBundle(in string aURLSpec); |
|
56 nsIStringBundle createExtensibleBundle(in string aRegistryKey); |
|
57 |
|
58 /** |
|
59 * Formats a message string from a status code and status arguments. |
|
60 * @param aStatus - The status code. This is mapped into a string ID and |
|
61 * and used in the string lookup process (see nsIErrorService). |
|
62 * @param aStatusArg - The status message argument(s). Multiple arguments |
|
63 * can be separated by newline ('\n') characters. |
|
64 * @return the formatted message |
|
65 */ |
|
66 wstring formatStatusMessage(in nsresult aStatus, in wstring aStatusArg); |
|
67 |
|
68 /** |
|
69 * flushes the string bundle cache - useful when the locale changes or |
|
70 * when we need to get some extra memory back |
|
71 * |
|
72 * at some point, we might want to make this flush all the bundles, |
|
73 * because any bundles that are floating around when the locale changes |
|
74 * will suddenly contain bad data |
|
75 * |
|
76 */ |
|
77 void flushBundles(); |
|
78 }; |