nsIStringBundle.idl 2.8 KB

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