utils.js 879 B

123456789101112131415161718192021222324252627
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 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. "use strict";
  6. /**
  7. * The default localization just returns the last part of the key
  8. * (all after the last dot).
  9. */
  10. const DefaultL10N = {
  11. getStr: function (key) {
  12. let index = key.lastIndexOf(".");
  13. return key.substr(index + 1);
  14. }
  15. };
  16. /**
  17. * The 'l10n' object is set by main.js in case the DOM panel content
  18. * runs within a scope with chrome privileges.
  19. *
  20. * Note that DOM panel content can also run within a scope with no chrome
  21. * privileges, e.g. in an iframe with type 'content' or in a browser tab,
  22. * which allows using our own tools for development.
  23. */
  24. exports.l10n = window.l10n || DefaultL10N;