michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: #include "nsISimpleEnumerator.idl" michael@0: michael@0: %{C++ michael@0: michael@0: // Define Contractid and CID michael@0: // {D85A17C1-AA7C-11d2-9B8C-00805F8A16D9} michael@0: #define NS_STRINGBUNDLESERVICE_CID \ michael@0: { 0xd85a17c1, 0xaa7c, 0x11d2, \ michael@0: { 0x9b, 0x8c, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } } michael@0: michael@0: #define NS_STRINGBUNDLE_CONTRACTID "@mozilla.org/intl/stringbundle;1" michael@0: michael@0: /** michael@0: * observer needs to check if the bundle handle matches michael@0: */ michael@0: #define NS_STRBUNDLE_LOADED_TOPIC "strbundle-loaded" michael@0: michael@0: %} michael@0: michael@0: native nsStrBundleLoadedFunc(nsStrBundleLoadedFunc); michael@0: michael@0: [scriptable, uuid(D85A17C2-AA7C-11d2-9B8C-00805F8A16D9)] michael@0: interface nsIStringBundle : nsISupports michael@0: { michael@0: wstring GetStringFromID(in long aID); michael@0: wstring GetStringFromName(in wstring aName); michael@0: michael@0: // this is kind of like smprintf - except that you can michael@0: // only pass it unicode strings, using the %S formatting character. michael@0: // the id or name should refer to a string in the bundle that michael@0: // uses %S.. do NOT try to use any other types. michael@0: // this uses nsTextFormatter::smprintf to do the dirty work. michael@0: wstring formatStringFromID(in long aID, michael@0: [array, size_is(length)] in wstring params, michael@0: in unsigned long length); michael@0: wstring formatStringFromName(in wstring aName, michael@0: [array, size_is(length)] in wstring params, michael@0: in unsigned long length); michael@0: /* michael@0: Implements nsISimpleEnumerator, replaces nsIEnumerator michael@0: */ michael@0: nsISimpleEnumerator getSimpleEnumeration(); michael@0: michael@0: }; michael@0: michael@0: [scriptable, uuid(D85A17C0-AA7C-11d2-9B8C-00805F8A16D9)] michael@0: interface nsIStringBundleService : nsISupports michael@0: { michael@0: nsIStringBundle createBundle(in string aURLSpec); michael@0: nsIStringBundle createExtensibleBundle(in string aRegistryKey); michael@0: michael@0: /** michael@0: * Formats a message string from a status code and status arguments. michael@0: * @param aStatus - The status code. This is mapped into a string ID and michael@0: * and used in the string lookup process (see nsIErrorService). michael@0: * @param aStatusArg - The status message argument(s). Multiple arguments michael@0: * can be separated by newline ('\n') characters. michael@0: * @return the formatted message michael@0: */ michael@0: wstring formatStatusMessage(in nsresult aStatus, in wstring aStatusArg); michael@0: michael@0: /** michael@0: * flushes the string bundle cache - useful when the locale changes or michael@0: * when we need to get some extra memory back michael@0: * michael@0: * at some point, we might want to make this flush all the bundles, michael@0: * because any bundles that are floating around when the locale changes michael@0: * will suddenly contain bad data michael@0: * michael@0: */ michael@0: void flushBundles(); michael@0: };