UNPKG

sassdoc-plugin-localization

Version:

SassDoc plugin for Ignite UI SassDoc Theme to help with localization.

35 lines (34 loc) 1.48 kB
import path from "path"; import { convert } from "./converter/convert.js"; import { render } from "./renderer/render.js"; export default function (options) { return { beforeProcess: (ctx) => { var _a; const mode = options.mode || "both"; const dir = options.dir; const languages = options.languages || ["en"]; if (mode === "export" || mode === "both") { console.info(`[↓] Exporting localization data to ${dir}`); for (const lang of languages) { const langDir = path.join(dir, lang); convert(ctx.data, langDir); } if (mode === "export") { console.info("[x] Terminating after export to allow for string modification"); return true; } } if (mode === "import" || mode === "both") { if (!ctx.language || !((_a = options.languages) === null || _a === void 0 ? void 0 : _a.includes(ctx.language))) { console.warn("[!] No valid language specified. Falling back to the default theme language."); return false; } const langDir = path.join(dir, ctx.language); console.info(`[↑] Importing localization data from ${langDir}`); render(ctx.data, langDir); } return false; }, }; }