1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | var __importStar = (this && this.__importStar) || function (mod) {
|
6 | if (mod && mod.__esModule) return mod;
|
7 | var result = {};
|
8 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
9 | result["default"] = mod;
|
10 | return result;
|
11 | };
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | const i18n_1 = require("@markuplint/i18n");
|
14 | const os_locale_1 = __importDefault(require("os-locale"));
|
15 | let cachedLocale = null;
|
16 | async function getLocale() {
|
17 | if (!cachedLocale) {
|
18 | cachedLocale = await os_locale_1.default({ spawn: true });
|
19 | }
|
20 | return cachedLocale;
|
21 | }
|
22 | async function getMessenger(locale) {
|
23 | locale = locale || (await getLocale());
|
24 | const localeSet = locale
|
25 | ? await Promise.resolve().then(() => __importStar(require(`@markuplint/i18n/locales/${locale}`))).catch(() => null)
|
26 | : null;
|
27 | return i18n_1.Messenger.create(localeSet);
|
28 | }
|
29 | exports.getMessenger = getMessenger;
|