@mr-hope/vuepress-utils
Version:
Utils for vuepress-theme-hope
43 lines • 1.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLocale = exports.path2lang = exports.lang2path = exports.checkLang = exports.i18n = exports.langs = void 0;
const config = require("@mr-hope/vuepress-shared/lib/config/i18n.json");
/** Supported lang codes */
exports.langs = config.langs;
/** Muti language config for plugins */
exports.i18n = config.plugins;
const lang2pathConfig = config.lang2Path;
const path2langConfig = config.path2lang;
const checkLang = (lang) => exports.langs.includes(lang);
exports.checkLang = checkLang;
/** get path from language */
const lang2path = (lang) => {
if (lang2pathConfig[lang])
return lang2pathConfig[lang];
console.error(`${lang} has no path config, and will return '/' instead.
You can contribute to https://github.com/Mister-Hope/vuepress-theme-hope/blob/v1/packages/shared/config/i18n.json`);
return "/";
};
exports.lang2path = lang2path;
/** get language from path */
const path2lang = (path) => {
if (path2langConfig[path])
return path2langConfig[path];
console.error(`${path} isn’t assign with a lang, and will return 'en-US' instead.
You can contribute to https://github.com/Mister-Hope/vuepress-theme-hope/blob/v1/packages/shared/config/i18n.json`);
return "en-US";
};
exports.path2lang = path2lang;
/** Muti language config */
const localesConfig = config.locales;
/** Get locate of certain language */
const getLocale = (lang) => {
if (localesConfig[lang])
return localesConfig[lang];
console.warn(`${lang} locates config is missing, and will return 'en-US' instead.
You can contribute to https://github.com/Mister-Hope/vuepress-theme-hope/blob/v1/packages/shared/config/i18n.json
Note: This warning will be shown only once.`);
return localesConfig["en-US"];
};
exports.getLocale = getLocale;
//# sourceMappingURL=i18n.js.map