"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.i18n = void 0;
const tslib_1 = require("tslib");
const os_locale_1 = tslib_1.__importDefault(require("os-locale"));
let cachedLocale = null;
async function getLocale() {
    if (!cachedLocale) {
        cachedLocale = await (0, os_locale_1.default)({ spawn: true });
    }
    return cachedLocale;
}
async function i18n(locale) {
    locale = locale || (await getLocale()) || 'en';
    const langCode = locale.split('-')[0];
    const localeSet = langCode
        ? await (_a = `@markuplint/i18n/locales/${langCode}`, Promise.resolve().then(() => tslib_1.__importStar(require(_a)))).catch(() => null)
        : null;
    return {
        locale: langCode,
        ...localeSet,
    };
}
exports.i18n = i18n;
