UNPKG

1.12 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5var __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};
12Object.defineProperty(exports, "__esModule", { value: true });
13const i18n_1 = require("@markuplint/i18n");
14const os_locale_1 = __importDefault(require("os-locale"));
15let cachedLocale = null;
16async function getLocale() {
17 if (!cachedLocale) {
18 cachedLocale = await os_locale_1.default({ spawn: true });
19 }
20 return cachedLocale;
21}
22async 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}
29exports.getMessenger = getMessenger;