UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

29 lines (27 loc) 790 B
const require_interpreter_getIntlayer = require('./getIntlayer.cjs'); //#region src/interpreter/getNesting.ts /** * Allow to extract the content of another dictionary. * * Usage: * ```ts * const content = getNesting("dictionaryKey", "path.to.content"); * // 'Example content' * ``` */ const getNesting = (dictionaryKey, path, props) => { const dictionary = require_interpreter_getIntlayer.getIntlayer(dictionaryKey, props?.locale, props?.plugins); if (typeof path === "string") { const pathArray = path.split("."); let current = dictionary; for (const key of pathArray) { current = current?.[key]; if (current === void 0) return dictionary; } return current; } return dictionary; }; //#endregion exports.getNesting = getNesting; //# sourceMappingURL=getNesting.cjs.map