2
0

genericl10n.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2017 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. 'use strict';
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.GenericL10n = undefined;
  27. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  28. require('../external/webL10n/l10n');
  29. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30. var webL10n = document.webL10n;
  31. var GenericL10n = function () {
  32. function GenericL10n(lang) {
  33. _classCallCheck(this, GenericL10n);
  34. this._lang = lang;
  35. this._ready = new Promise(function (resolve, reject) {
  36. webL10n.setLanguage(lang, function () {
  37. resolve(webL10n);
  38. });
  39. });
  40. }
  41. _createClass(GenericL10n, [{
  42. key: 'getDirection',
  43. value: function getDirection() {
  44. return this._ready.then(function (l10n) {
  45. return l10n.getDirection();
  46. });
  47. }
  48. }, {
  49. key: 'get',
  50. value: function get(property, args, fallback) {
  51. return this._ready.then(function (l10n) {
  52. return l10n.get(property, args, fallback);
  53. });
  54. }
  55. }, {
  56. key: 'translate',
  57. value: function translate(element) {
  58. return this._ready.then(function (l10n) {
  59. return l10n.translate(element);
  60. });
  61. }
  62. }]);
  63. return GenericL10n;
  64. }();
  65. exports.GenericL10n = GenericL10n;