monaco-editor-i18n-plugin
Version:
A i18n plugin for the Monaco editor
18 lines (17 loc) • 788 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const nls = require.resolve("../nls");
const replaceNls = function (content) {
const pathRegExp = /monaco-editor[\\\/]esm[\\\/]vs[\\\/]nls\.js$/;
if (!pathRegExp.test(this.resourcePath))
return content;
let _content = fs.readFileSync(nls, { encoding: "utf8" });
if (_content.includes("windowKey") && _content.includes("localStorageKey")) {
const { windowKey, localStorageKey } = this.getOptions() || {};
_content = _content.replace(/const windowKey = \("[^"]*"\);/g, `${windowKey};`);
_content = _content.replace(/const localStorageKey = \("[^"]*"\);/g, `${localStorageKey};`);
}
return _content;
};
module.exports = replaceNls;