1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/strres/public/nsIStringBundle.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 +#include "nsISimpleEnumerator.idl" 1.11 + 1.12 +%{C++ 1.13 + 1.14 +// Define Contractid and CID 1.15 +// {D85A17C1-AA7C-11d2-9B8C-00805F8A16D9} 1.16 +#define NS_STRINGBUNDLESERVICE_CID \ 1.17 +{ 0xd85a17c1, 0xaa7c, 0x11d2, \ 1.18 + { 0x9b, 0x8c, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } } 1.19 + 1.20 +#define NS_STRINGBUNDLE_CONTRACTID "@mozilla.org/intl/stringbundle;1" 1.21 + 1.22 +/** 1.23 + * observer needs to check if the bundle handle matches 1.24 + */ 1.25 +#define NS_STRBUNDLE_LOADED_TOPIC "strbundle-loaded" 1.26 + 1.27 +%} 1.28 + 1.29 +native nsStrBundleLoadedFunc(nsStrBundleLoadedFunc); 1.30 + 1.31 +[scriptable, uuid(D85A17C2-AA7C-11d2-9B8C-00805F8A16D9)] 1.32 +interface nsIStringBundle : nsISupports 1.33 +{ 1.34 + wstring GetStringFromID(in long aID); 1.35 + wstring GetStringFromName(in wstring aName); 1.36 + 1.37 + // this is kind of like smprintf - except that you can 1.38 + // only pass it unicode strings, using the %S formatting character. 1.39 + // the id or name should refer to a string in the bundle that 1.40 + // uses %S.. do NOT try to use any other types. 1.41 + // this uses nsTextFormatter::smprintf to do the dirty work. 1.42 + wstring formatStringFromID(in long aID, 1.43 + [array, size_is(length)] in wstring params, 1.44 + in unsigned long length); 1.45 + wstring formatStringFromName(in wstring aName, 1.46 + [array, size_is(length)] in wstring params, 1.47 + in unsigned long length); 1.48 + /* 1.49 + Implements nsISimpleEnumerator, replaces nsIEnumerator 1.50 + */ 1.51 + nsISimpleEnumerator getSimpleEnumeration(); 1.52 + 1.53 +}; 1.54 + 1.55 +[scriptable, uuid(D85A17C0-AA7C-11d2-9B8C-00805F8A16D9)] 1.56 +interface nsIStringBundleService : nsISupports 1.57 +{ 1.58 + nsIStringBundle createBundle(in string aURLSpec); 1.59 + nsIStringBundle createExtensibleBundle(in string aRegistryKey); 1.60 + 1.61 + /** 1.62 + * Formats a message string from a status code and status arguments. 1.63 + * @param aStatus - The status code. This is mapped into a string ID and 1.64 + * and used in the string lookup process (see nsIErrorService). 1.65 + * @param aStatusArg - The status message argument(s). Multiple arguments 1.66 + * can be separated by newline ('\n') characters. 1.67 + * @return the formatted message 1.68 + */ 1.69 + wstring formatStatusMessage(in nsresult aStatus, in wstring aStatusArg); 1.70 + 1.71 + /** 1.72 + * flushes the string bundle cache - useful when the locale changes or 1.73 + * when we need to get some extra memory back 1.74 + * 1.75 + * at some point, we might want to make this flush all the bundles, 1.76 + * because any bundles that are floating around when the locale changes 1.77 + * will suddenly contain bad data 1.78 + * 1.79 + */ 1.80 + void flushBundles(); 1.81 +};