intl/strres/public/nsIStringBundle.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial