UNPKG

@intlayer/chokidar

Version:

Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.

49 lines 1.93 kB
"use strict"; 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 processPerLocaleDictionary_exports = {}; __export(processPerLocaleDictionary_exports, { processPerLocaleDictionary: () => processPerLocaleDictionary }); module.exports = __toCommonJS(processPerLocaleDictionary_exports); var import_core = require("@intlayer/core"); const processPerLocaleDictionary = (dictionary) => { const isPerLocaleDictionary = typeof dictionary.locale === "string"; if (!isPerLocaleDictionary) { return dictionary; } const transformStringToTranslationPlugin = { id: "transform-string-to-translation-plugin", canHandle: (node) => typeof node === "string" || typeof node === "number", transform: (node) => (0, import_core.t)({ [dictionary.locale]: node }) }; return { ...dictionary, locale: void 0, content: (0, import_core.deepTransformNode)(dictionary.content, { dictionaryKey: dictionary.key, keyPath: [], plugins: [transformStringToTranslationPlugin] }) }; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { processPerLocaleDictionary }); //# sourceMappingURL=processPerLocaleDictionary.cjs.map