1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | 'use strict';
|
23 |
|
24 | Object.defineProperty(exports, "__esModule", {
|
25 | value: true
|
26 | });
|
27 | exports.GenericL10n = undefined;
|
28 |
|
29 | 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; }; }();
|
30 |
|
31 | require('../external/webL10n/l10n');
|
32 |
|
33 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
34 |
|
35 | var webL10n = document.webL10n;
|
36 |
|
37 | var GenericL10n = function () {
|
38 | function GenericL10n(lang) {
|
39 | _classCallCheck(this, GenericL10n);
|
40 |
|
41 | this._lang = lang;
|
42 | this._ready = new Promise(function (resolve, reject) {
|
43 | webL10n.setLanguage(lang, function () {
|
44 | resolve(webL10n);
|
45 | });
|
46 | });
|
47 | }
|
48 |
|
49 | _createClass(GenericL10n, [{
|
50 | key: 'getLanguage',
|
51 | value: function getLanguage() {
|
52 | return this._ready.then(function (l10n) {
|
53 | return l10n.getLanguage();
|
54 | });
|
55 | }
|
56 | }, {
|
57 | key: 'getDirection',
|
58 | value: function getDirection() {
|
59 | return this._ready.then(function (l10n) {
|
60 | return l10n.getDirection();
|
61 | });
|
62 | }
|
63 | }, {
|
64 | key: 'get',
|
65 | value: function get(property, args, fallback) {
|
66 | return this._ready.then(function (l10n) {
|
67 | return l10n.get(property, args, fallback);
|
68 | });
|
69 | }
|
70 | }, {
|
71 | key: 'translate',
|
72 | value: function translate(element) {
|
73 | return this._ready.then(function (l10n) {
|
74 | return l10n.translate(element);
|
75 | });
|
76 | }
|
77 | }]);
|
78 |
|
79 | return GenericL10n;
|
80 | }();
|
81 |
|
82 | exports.GenericL10n = GenericL10n; |
\ | No newline at end of file |