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 = void 0;
|
28 |
|
29 | require("../external/webL10n/l10n.js");
|
30 |
|
31 | var _l10n_utils = require("./l10n_utils.js");
|
32 |
|
33 | const webL10n = document.webL10n;
|
34 |
|
35 | class GenericL10n {
|
36 | constructor(lang) {
|
37 | this._lang = lang;
|
38 | this._ready = new Promise((resolve, reject) => {
|
39 | webL10n.setLanguage((0, _l10n_utils.fixupLangCode)(lang), () => {
|
40 | resolve(webL10n);
|
41 | });
|
42 | });
|
43 | }
|
44 |
|
45 | async getLanguage() {
|
46 | const l10n = await this._ready;
|
47 | return l10n.getLanguage();
|
48 | }
|
49 |
|
50 | async getDirection() {
|
51 | const l10n = await this._ready;
|
52 | return l10n.getDirection();
|
53 | }
|
54 |
|
55 | async get(key, args = null, fallback = (0, _l10n_utils.getL10nFallback)(key, args)) {
|
56 | const l10n = await this._ready;
|
57 | return l10n.get(key, args, fallback);
|
58 | }
|
59 |
|
60 | async translate(element) {
|
61 | const l10n = await this._ready;
|
62 | return l10n.translate(element);
|
63 | }
|
64 |
|
65 | }
|
66 |
|
67 | exports.GenericL10n = GenericL10n; |
\ | No newline at end of file |