lynx-intlayer
Version:
A Lynx plugin for seamless internationalization (i18n) and localization (l10n) of your mobile app.
79 lines • 3.2 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var pluginIntlayerLynx_exports = {};
__export(pluginIntlayerLynx_exports, {
pluginIntlayerLynx: () => pluginIntlayerLynx
});
module.exports = __toCommonJS(pluginIntlayerLynx_exports);
var import_chokidar = require("@intlayer/chokidar");
var import_config = require("@intlayer/config");
var import_path = require("path");
const pluginIntlayerLynx = () => {
return {
name: "plugin-intlayer-lynx",
async setup(api) {
const intlayerConfig = (0, import_config.getConfiguration)();
await (0, import_chokidar.prepareIntlayer)(intlayerConfig);
const { mainDir, configDir, baseDir } = intlayerConfig.content;
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
const unmergedDictionariesPath = (0, import_path.join)(
mainDir,
"unmerged_dictionaries.mjs"
);
const relativeUnmergedDictionariesPath = (0, import_path.relative)(
baseDir,
unmergedDictionariesPath
);
const configurationPath = (0, import_path.join)(configDir, "configuration.json");
const relativeConfigurationPath = (0, import_path.relative)(baseDir, configurationPath);
if (intlayerConfig.content.watch) {
(0, import_chokidar.watch)(intlayerConfig);
}
api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => {
return mergeRsbuildConfig(config, {
source: {
alias: {
"@intlayer/dictionaries-entry": relativeDictionariesPath,
"@intlayer/unmerged-dictionaries-entry": relativeUnmergedDictionariesPath,
"@intlayer/config/built": relativeConfigurationPath,
react: import_config.ESMxCJSRequire.resolve("@lynx-js/react")
}
}
});
});
if (intlayerConfig.editor.hotReload) {
api.onBeforeEnvironmentCompile(async () => {
try {
await (0, import_chokidar.checkDictionaryChanges)();
} catch (error) {
(0, import_config.logger)(`Error checking dictionary changes: ${error}`, {
level: "error"
});
}
});
}
}
};
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
pluginIntlayerLynx
});
//# sourceMappingURL=pluginIntlayerLynx.cjs.map