UNPKG

markuplint

Version:

A Linter for All Markup Languages.

44 lines (43 loc) 1.74 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.i18n = void 0; const i18n_1 = require("@markuplint/i18n"); const os_locale_1 = __importDefault(require("os-locale")); let cachedLocale = null; async function getLocale() { if (!cachedLocale) { cachedLocale = await os_locale_1.default({ spawn: true }); } return cachedLocale; } async function i18n(locale) { locale = locale || (await getLocale()) || ''; const langCode = locale.split('-')[0]; const localeSet = langCode ? await Promise.resolve().then(() => __importStar(require(`@markuplint/i18n/locales/${langCode}`))).catch(() => null) : null; return i18n_1.I18n.create(localeSet); } exports.i18n = i18n;