@intlayer/core 7.0.2-canary.0 → 7.0.3-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +123 -0
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -0
- package/dist/cjs/deepTransformPlugins/index.cjs +3 -0
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +7 -4
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getUnmergedDictionaryByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getUnmergedDictionaryByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/index.cjs +1 -3
- package/dist/cjs/index.cjs +4 -3
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +120 -0
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -0
- package/dist/esm/deepTransformPlugins/index.mjs +2 -1
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +7 -4
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getUnmergedDictionaryByKeyPath.mjs +1 -1
- package/dist/esm/dictionaryManipulator/getUnmergedDictionaryByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/index.mjs +2 -3
- package/dist/esm/index.mjs +3 -3
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +4 -4
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +4 -4
- package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +42 -0
- package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +1 -0
- package/dist/types/deepTransformPlugins/index.d.ts +2 -1
- package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +2 -2
- package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/getUnmergedDictionaryByKeyPath.d.ts +2 -2
- package/dist/types/dictionaryManipulator/index.d.ts +1 -2
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +2 -2
- package/dist/types/getStorageAttributes.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/transpiler/translation/translation.d.ts +1 -1
- package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __intlayer_types = require("@intlayer/types");
|
|
3
|
+
__intlayer_types = require_rolldown_runtime.__toESM(__intlayer_types);
|
|
4
|
+
|
|
5
|
+
//#region src/deepTransformPlugins/getSplittedContent.ts
|
|
6
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
const hasNodeType = (value) => isObject(value) && typeof value.nodeType === "string";
|
|
8
|
+
const mergeValues = (a, b) => {
|
|
9
|
+
if (a === void 0) return b;
|
|
10
|
+
if (b === void 0) return a;
|
|
11
|
+
if (Array.isArray(a) && Array.isArray(b)) return [...a, ...b];
|
|
12
|
+
if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {
|
|
13
|
+
const result = { ...a };
|
|
14
|
+
for (const key of Object.keys(b)) result[key] = mergeValues(result[key], b[key]);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
return b;
|
|
18
|
+
};
|
|
19
|
+
const mergeSplitResults = (base, addition) => {
|
|
20
|
+
const result = { ...base };
|
|
21
|
+
result.common = mergeValues(base.common, addition.common);
|
|
22
|
+
const localeKeys = new Set([...Object.keys(base).filter((k) => k !== "common"), ...Object.keys(addition).filter((k) => k !== "common")]);
|
|
23
|
+
for (const key of localeKeys) result[key] = mergeValues(base[key], addition[key]);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
const splitNode = (node) => {
|
|
27
|
+
if (isObject(node) && node?.nodeType === __intlayer_types.NodeType.Translation) {
|
|
28
|
+
const translations = node[__intlayer_types.NodeType.Translation];
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const locale of Object.keys(translations)) {
|
|
31
|
+
const child = translations[locale];
|
|
32
|
+
const childSplit = splitNode(child);
|
|
33
|
+
const mergedForLocale = mergeValues(childSplit.common, void 0);
|
|
34
|
+
let recomposed;
|
|
35
|
+
for (const key of Object.keys(childSplit)) {
|
|
36
|
+
if (key === "common") continue;
|
|
37
|
+
recomposed = mergeValues(recomposed, childSplit[key]);
|
|
38
|
+
}
|
|
39
|
+
const finalLocaleNode = mergeValues(mergedForLocale, recomposed);
|
|
40
|
+
if (finalLocaleNode !== void 0) result[locale] = finalLocaleNode;
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(node)) {
|
|
45
|
+
const commonArray = [];
|
|
46
|
+
const perLocaleArrays = {};
|
|
47
|
+
node.forEach((child) => {
|
|
48
|
+
const childSplit = splitNode(child);
|
|
49
|
+
if (childSplit.common !== void 0) commonArray.push(childSplit.common);
|
|
50
|
+
for (const key of Object.keys(childSplit)) {
|
|
51
|
+
if (key === "common") continue;
|
|
52
|
+
if (!perLocaleArrays[key]) perLocaleArrays[key] = [];
|
|
53
|
+
const value = childSplit[key];
|
|
54
|
+
if (value !== void 0) perLocaleArrays[key].push(value);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const result = {};
|
|
58
|
+
if (commonArray.length > 0) result.common = commonArray;
|
|
59
|
+
for (const key of Object.keys(perLocaleArrays)) result[key] = perLocaleArrays[key];
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
if (isObject(node) && !hasNodeType(node)) {
|
|
63
|
+
let accumulated = {};
|
|
64
|
+
for (const key of Object.keys(node)) {
|
|
65
|
+
const childSplit = splitNode(node[key]);
|
|
66
|
+
if (childSplit.common !== void 0) accumulated = mergeSplitResults(accumulated, { common: { [key]: childSplit.common } });
|
|
67
|
+
for (const locale of Object.keys(childSplit)) {
|
|
68
|
+
if (locale === "common") continue;
|
|
69
|
+
accumulated = mergeSplitResults(accumulated, { [locale]: { [key]: childSplit[locale] } });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return accumulated;
|
|
73
|
+
}
|
|
74
|
+
return { common: node };
|
|
75
|
+
};
|
|
76
|
+
const getSplittedContent = (content) => {
|
|
77
|
+
const split = splitNode(content);
|
|
78
|
+
const output = {};
|
|
79
|
+
if (split.common !== void 0) output.common = split.common;
|
|
80
|
+
for (const key of Object.keys(split)) {
|
|
81
|
+
if (key === "common") continue;
|
|
82
|
+
const value = split[key];
|
|
83
|
+
if (value !== void 0) output[key] = value;
|
|
84
|
+
}
|
|
85
|
+
return output;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Splits the `content` field of a Dictionary into "common" and per-locale buckets.
|
|
89
|
+
*
|
|
90
|
+
* Given a dictionary like:
|
|
91
|
+
* ```js
|
|
92
|
+
* {
|
|
93
|
+
* key: "my-key",
|
|
94
|
+
* content: {
|
|
95
|
+
* commonContent: "common content",
|
|
96
|
+
* multilingualContent: t({
|
|
97
|
+
* en: "english content",
|
|
98
|
+
* fr: "french content",
|
|
99
|
+
* de: "german content",
|
|
100
|
+
* }),
|
|
101
|
+
* },
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* It produces:
|
|
106
|
+
* ```js
|
|
107
|
+
* {
|
|
108
|
+
* common: { commonContent: "common content" },
|
|
109
|
+
* en: { multilingualContent: "english content" },
|
|
110
|
+
* fr: { multilingualContent: "french content" },
|
|
111
|
+
* de: { multilingualContent: "german content" },
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @param dictionary - The input dictionary object with possible multilingual or common content.
|
|
116
|
+
* @returns An object mapping "common" and each locale to their corresponding content subtrees.
|
|
117
|
+
*/
|
|
118
|
+
const getSplittedDictionaryContent = (dictionary) => getSplittedContent(dictionary.content);
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
exports.getSplittedContent = getSplittedContent;
|
|
122
|
+
exports.getSplittedDictionaryContent = getSplittedDictionaryContent;
|
|
123
|
+
//# sourceMappingURL=getSplittedContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSplittedContent.cjs","names":["result: Record<string, any>","result: SplitResult","NodeType","recomposed: ContentNode | undefined","commonArray: any[]","perLocaleArrays: Record<string, any[]>","accumulated: SplitResult","output: Record<string, ContentNode>"],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":["import {\n type ContentNode,\n type DeclaredLocales,\n type Dictionary,\n NodeType,\n} from '@intlayer/types';\n\ntype SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {\n common: T;\n};\n\ntype SplitResult = Record<string, ContentNode | undefined> & {\n common?: ContentNode;\n};\n\nconst isObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst hasNodeType = (value: unknown): value is { nodeType: string } =>\n isObject(value) && typeof (value as any).nodeType === 'string';\n\nconst mergeValues = (\n a: ContentNode | undefined,\n b: ContentNode | undefined\n): ContentNode | undefined => {\n if (a === undefined) return b;\n if (b === undefined) return a;\n\n if (Array.isArray(a) && Array.isArray(b)) {\n // Concatenate arrays when merging sibling results\n return [...a, ...b] as unknown as ContentNode;\n }\n\n if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {\n const result: Record<string, any> = { ...a };\n for (const key of Object.keys(b)) {\n result[key] = mergeValues(\n result[key] as unknown as ContentNode | undefined,\n (b as Record<string, any>)[key] as unknown as ContentNode | undefined\n );\n }\n return result as ContentNode;\n }\n\n // For primitives or differing structures, prefer b (more recent)\n return b;\n};\n\nconst mergeSplitResults = (\n base: SplitResult,\n addition: SplitResult\n): SplitResult => {\n const result: SplitResult = { ...base };\n\n // Merge common\n result.common = mergeValues(base.common, addition.common);\n\n // Merge each locale key present in either side\n const localeKeys = new Set<string>([\n ...Object.keys(base).filter((k) => k !== 'common'),\n ...Object.keys(addition).filter((k) => k !== 'common'),\n ]);\n\n for (const key of localeKeys) {\n // @ts-ignore: dynamic keys for locales\n result[key] = mergeValues(\n base[key] as ContentNode | undefined,\n addition[key] as ContentNode | undefined\n );\n }\n\n return result;\n};\n\nconst splitNode = (node: ContentNode): SplitResult => {\n // Translation node: allocate entirely to per-locale buckets\n if (isObject(node) && (node as any)?.nodeType === NodeType.Translation) {\n const translations = (node as any)[NodeType.Translation] as Record<\n string,\n ContentNode\n >;\n\n const result: SplitResult = {};\n for (const locale of Object.keys(translations)) {\n const child = translations[locale];\n const childSplit = splitNode(child);\n\n // The content under a translation belongs to the locale, not common\n // Merge common portion of the child (if any) into the locale as well\n const mergedForLocale = mergeValues(childSplit.common, undefined);\n\n // Compose locale content: prefer the fully rebuilt child by resolving deeper translations recursively\n // which are already split inside childSplit. We need to recompose a single node for this locale.\n // Recompose by merging all keys in childSplit except 'common' into a single node, then merge child's common.\n let recomposed: ContentNode | undefined;\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n recomposed = mergeValues(\n recomposed,\n childSplit[key] as ContentNode | undefined\n );\n }\n const finalLocaleNode = mergeValues(mergedForLocale, recomposed);\n\n if (finalLocaleNode !== undefined) {\n // @ts-ignore dynamic locale key\n result[locale] = finalLocaleNode;\n }\n }\n\n return result;\n }\n\n // Arrays: split each element and merge results index-wise\n if (Array.isArray(node)) {\n const commonArray: any[] = [];\n const perLocaleArrays: Record<string, any[]> = {};\n\n node.forEach((child) => {\n const childSplit = splitNode(child as ContentNode);\n\n if (childSplit.common !== undefined) {\n commonArray.push(childSplit.common);\n }\n\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n if (!perLocaleArrays[key]) perLocaleArrays[key] = [];\n const value = childSplit[key];\n if (value !== undefined) perLocaleArrays[key].push(value);\n }\n });\n\n const result: SplitResult = {};\n if (commonArray.length > 0)\n result.common = commonArray as unknown as ContentNode;\n for (const key of Object.keys(perLocaleArrays)) {\n // @ts-ignore dynamic locale key\n result[key] = perLocaleArrays[key] as unknown as ContentNode;\n }\n return result;\n }\n\n // Objects (non-typed): recursively split properties\n if (isObject(node) && !hasNodeType(node)) {\n let accumulated: SplitResult = {};\n\n for (const key of Object.keys(node)) {\n const childSplit = splitNode((node as any)[key] as ContentNode);\n\n // Assign property into common\n if (childSplit.common !== undefined) {\n accumulated = mergeSplitResults(accumulated, {\n common: { [key]: childSplit.common } as unknown as ContentNode,\n });\n }\n\n // Assign property into each locale bucket\n for (const locale of Object.keys(childSplit)) {\n if (locale === 'common') continue;\n accumulated = mergeSplitResults(accumulated, {\n // @ts-ignore dynamic locale key\n [locale]: { [key]: childSplit[locale] } as unknown as ContentNode,\n });\n }\n }\n\n return accumulated;\n }\n\n // Primitives or typed nodes (non-translation): entirely common\n return { common: node } as SplitResult;\n};\n\nexport const getSplittedContent = (\n content: ContentNode\n): SplittedContentOutput => {\n const split = splitNode(content);\n\n // Build final output with only defined sections\n const output: Record<string, ContentNode> = {};\n if (split.common !== undefined) {\n output.common = split.common;\n }\n for (const key of Object.keys(split)) {\n if (key === 'common') continue;\n const value = split[key] as ContentNode | undefined;\n if (value !== undefined) {\n output[key] = value;\n }\n }\n\n return output as unknown as SplittedContentOutput;\n};\n\n/**\n * Splits the `content` field of a Dictionary into \"common\" and per-locale buckets.\n *\n * Given a dictionary like:\n * ```js\n * {\n * key: \"my-key\",\n * content: {\n * commonContent: \"common content\",\n * multilingualContent: t({\n * en: \"english content\",\n * fr: \"french content\",\n * de: \"german content\",\n * }),\n * },\n * }\n * ```\n *\n * It produces:\n * ```js\n * {\n * common: { commonContent: \"common content\" },\n * en: { multilingualContent: \"english content\" },\n * fr: { multilingualContent: \"french content\" },\n * de: { multilingualContent: \"german content\" },\n * }\n * ```\n *\n * @param dictionary - The input dictionary object with possible multilingual or common content.\n * @returns An object mapping \"common\" and each locale to their corresponding content subtrees.\n */\nexport const getSplittedDictionaryContent = (\n dictionary: Dictionary\n): SplittedContentOutput<Dictionary['content']> =>\n getSplittedContent(dictionary.content);\n"],"mappings":"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"}
|
|
@@ -5,6 +5,7 @@ const require_deepTransformPlugins_getLocalizedContent = require('./getLocalized
|
|
|
5
5
|
const require_deepTransformPlugins_getMaskContent = require('./getMaskContent.cjs');
|
|
6
6
|
const require_deepTransformPlugins_getMissingLocalesContent = require('./getMissingLocalesContent.cjs');
|
|
7
7
|
const require_deepTransformPlugins_getReplacedValuesContent = require('./getReplacedValuesContent.cjs');
|
|
8
|
+
const require_deepTransformPlugins_getSplittedContent = require('./getSplittedContent.cjs');
|
|
8
9
|
const require_deepTransformPlugins_insertContentInDictionary = require('./insertContentInDictionary.cjs');
|
|
9
10
|
|
|
10
11
|
exports.buildMaskPlugin = require_deepTransformPlugins_getMaskContent.buildMaskPlugin;
|
|
@@ -22,4 +23,6 @@ exports.getMaskContent = require_deepTransformPlugins_getMaskContent.getMaskCont
|
|
|
22
23
|
exports.getMissingLocalesContent = require_deepTransformPlugins_getMissingLocalesContent.getMissingLocalesContent;
|
|
23
24
|
exports.getPerLocaleDictionary = require_deepTransformPlugins_getLocalizedContent.getPerLocaleDictionary;
|
|
24
25
|
exports.getReplacedValuesContent = require_deepTransformPlugins_getReplacedValuesContent.getReplacedValuesContent;
|
|
26
|
+
exports.getSplittedContent = require_deepTransformPlugins_getSplittedContent.getSplittedContent;
|
|
27
|
+
exports.getSplittedDictionaryContent = require_deepTransformPlugins_getSplittedContent.getSplittedDictionaryContent;
|
|
25
28
|
exports.insertContentInDictionary = require_deepTransformPlugins_insertContentInDictionary.insertContentInDictionary;
|
|
@@ -3,11 +3,14 @@ let __intlayer_types = require("@intlayer/types");
|
|
|
3
3
|
__intlayer_types = require_rolldown_runtime.__toESM(__intlayer_types);
|
|
4
4
|
|
|
5
5
|
//#region src/dictionaryManipulator/getContentNodeByKeyPath.ts
|
|
6
|
-
const getContentNodeByKeyPath = (dictionaryContent, keyPath) => {
|
|
6
|
+
const getContentNodeByKeyPath = (dictionaryContent, keyPath, fallbackLocale) => {
|
|
7
7
|
let currentValue = structuredClone(dictionaryContent);
|
|
8
|
-
for (const keyObj of keyPath)
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
for (const keyObj of keyPath) {
|
|
9
|
+
if (fallbackLocale && currentValue?.nodeType === __intlayer_types.NodeType.Translation) currentValue = currentValue?.[__intlayer_types.NodeType.Translation]?.[fallbackLocale];
|
|
10
|
+
if (keyObj.type === __intlayer_types.NodeType.Object || keyObj.type === __intlayer_types.NodeType.Array) currentValue = currentValue?.[keyObj.key];
|
|
11
|
+
if (keyObj.type === __intlayer_types.NodeType.Translation || keyObj.type === __intlayer_types.NodeType.Condition || keyObj.type === __intlayer_types.NodeType.Enumeration) currentValue = currentValue?.[keyObj.type]?.[keyObj.key];
|
|
12
|
+
if (keyObj.type === __intlayer_types.NodeType.Markdown || keyObj.type === __intlayer_types.NodeType.Insertion || keyObj.type === __intlayer_types.NodeType.File) currentValue = currentValue?.[keyObj.type];
|
|
13
|
+
}
|
|
11
14
|
return currentValue;
|
|
12
15
|
};
|
|
13
16
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getContentNodeByKeyPath.cjs","names":["currentValue: any","NodeType"],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getContentNodeByKeyPath.cjs","names":["currentValue: any","NodeType"],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import {\n type ContentNode,\n type KeyPath,\n type Locale,\n NodeType,\n} from '@intlayer/types';\n\nexport const getContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n fallbackLocale?: Locale\n): ContentNode => {\n let currentValue: any = structuredClone(dictionaryContent);\n\n for (const keyObj of keyPath) {\n // Auto-resolve translation nodes when fallbackLocale is provided\n if (fallbackLocale && currentValue?.nodeType === NodeType.Translation) {\n currentValue = currentValue?.[NodeType.Translation]?.[fallbackLocale];\n }\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n currentValue = currentValue?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Condition ||\n keyObj.type === NodeType.Enumeration\n ) {\n currentValue = currentValue?.[keyObj.type]?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n currentValue = currentValue?.[keyObj.type];\n }\n }\n\n return currentValue as ContentNode;\n};\n"],"mappings":";;;;;AAOA,MAAa,2BACX,mBACA,SACA,mBACgB;CAChB,IAAIA,eAAoB,gBAAgB,kBAAkB;AAE1D,MAAK,MAAM,UAAU,SAAS;AAE5B,MAAI,kBAAkB,cAAc,aAAaC,0BAAS,YACxD,gBAAe,eAAeA,0BAAS,eAAe;AAGxD,MAAI,OAAO,SAASA,0BAAS,UAAU,OAAO,SAASA,0BAAS,MAC9D,gBAAe,eAAe,OAAO;AAGvC,MACE,OAAO,SAASA,0BAAS,eACzB,OAAO,SAASA,0BAAS,aACzB,OAAO,SAASA,0BAAS,YAEzB,gBAAe,eAAe,OAAO,QAAQ,OAAO;AAGtD,MACE,OAAO,SAASA,0BAAS,YACzB,OAAO,SAASA,0BAAS,aACzB,OAAO,SAASA,0BAAS,KAEzB,gBAAe,eAAe,OAAO;;AAIzC,QAAO"}
|
|
@@ -11,7 +11,7 @@ const getUnmergedDictionaryByKeyPath = (dictionaryKey, keyPath, dictionariesReco
|
|
|
11
11
|
const unmergedEntries = (dictionariesRecord ?? (0, __intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration))?.[dictionaryKey];
|
|
12
12
|
if (!unmergedEntries) return null;
|
|
13
13
|
const normalizedUnmergedEntries = require_dictionaryManipulator_normalizeDictionary.normalizeDictionaries(unmergedEntries, configuration);
|
|
14
|
-
for (const dictionary of normalizedUnmergedEntries) if (require_dictionaryManipulator_getContentNodeByKeyPath.getContentNodeByKeyPath(dictionary.content, keyPath)) return dictionary;
|
|
14
|
+
for (const dictionary of normalizedUnmergedEntries) if (require_dictionaryManipulator_getContentNodeByKeyPath.getContentNodeByKeyPath(dictionary.content, keyPath)) return unmergedEntries.find((entry) => entry.localId === dictionary.localId);
|
|
15
15
|
for (const dictionary of unmergedEntries) if (require_dictionaryManipulator_getContentNodeByKeyPath.getContentNodeByKeyPath(dictionary.content, keyPath)) return dictionary;
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUnmergedDictionaryByKeyPath.cjs","names":["intlayerConfiguration","normalizeDictionaries","getContentNodeByKeyPath"],"sources":["../../../src/dictionaryManipulator/getUnmergedDictionaryByKeyPath.ts"],"sourcesContent":["import intlayerConfiguration from '@intlayer/config/built';\nimport type { IntlayerConfig, KeyPath } from '@intlayer/types';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { getContentNodeByKeyPath } from './getContentNodeByKeyPath';\nimport { normalizeDictionaries } from './normalizeDictionary';\n\nexport const getUnmergedDictionaryByKeyPath = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n dictionariesRecord?: UnmergedDictionaries,\n configuration: IntlayerConfig = intlayerConfiguration\n) => {\n const unmergedEntries = (dictionariesRecord ??\n getUnmergedDictionaries(configuration))?.[dictionaryKey];\n\n if (!unmergedEntries) {\n return null;\n }\n\n const normalizedUnmergedEntries = normalizeDictionaries(\n unmergedEntries,\n configuration\n );\n\n for (const dictionary of normalizedUnmergedEntries) {\n const content = getContentNodeByKeyPath(dictionary.content, keyPath);\n\n if (content) {\n return dictionary;\n }\n }\n\n for (const dictionary of unmergedEntries) {\n const content = getContentNodeByKeyPath(dictionary.content, keyPath);\n\n if (content) {\n return dictionary;\n }\n }\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,kCACX,eACA,SACA,oBACA,gBAAgCA,oCAC7B;CACH,MAAM,mBAAmB,0FACC,cAAc,IAAI;AAE5C,KAAI,CAAC,gBACH,QAAO;
|
|
1
|
+
{"version":3,"file":"getUnmergedDictionaryByKeyPath.cjs","names":["intlayerConfiguration","normalizeDictionaries","getContentNodeByKeyPath"],"sources":["../../../src/dictionaryManipulator/getUnmergedDictionaryByKeyPath.ts"],"sourcesContent":["import intlayerConfiguration from '@intlayer/config/built';\nimport type { IntlayerConfig, KeyPath } from '@intlayer/types';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { getContentNodeByKeyPath } from './getContentNodeByKeyPath';\nimport { normalizeDictionaries } from './normalizeDictionary';\n\nexport const getUnmergedDictionaryByKeyPath = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n dictionariesRecord?: UnmergedDictionaries,\n configuration: IntlayerConfig = intlayerConfiguration\n) => {\n const unmergedEntries = (dictionariesRecord ??\n getUnmergedDictionaries(configuration))?.[dictionaryKey];\n\n if (!unmergedEntries) {\n return null;\n }\n\n // First search for the dictionary in the normalized dictionaries as it's what see the client editor selector\n // Then return the original unmerged dictionary if not found in the normalized dictionaries\n\n const normalizedUnmergedEntries = normalizeDictionaries(\n unmergedEntries,\n configuration\n );\n\n for (const dictionary of normalizedUnmergedEntries) {\n const content = getContentNodeByKeyPath(dictionary.content, keyPath);\n\n if (content) {\n return unmergedEntries.find(\n (entry) => entry.localId === dictionary.localId\n );\n }\n }\n\n // If not found in the normalized dictionaries, search in the original unmerged dictionaries directly\n\n for (const dictionary of unmergedEntries) {\n const content = getContentNodeByKeyPath(dictionary.content, keyPath);\n\n if (content) {\n return dictionary;\n }\n }\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,kCACX,eACA,SACA,oBACA,gBAAgCA,oCAC7B;CACH,MAAM,mBAAmB,0FACC,cAAc,IAAI;AAE5C,KAAI,CAAC,gBACH,QAAO;CAMT,MAAM,4BAA4BC,wEAChC,iBACA,cACD;AAED,MAAK,MAAM,cAAc,0BAGvB,KAFgBC,8EAAwB,WAAW,SAAS,QAAQ,CAGlE,QAAO,gBAAgB,MACpB,UAAU,MAAM,YAAY,WAAW,QACzC;AAML,MAAK,MAAM,cAAc,gBAGvB,KAFgBA,8EAAwB,WAAW,SAAS,QAAQ,CAGlE,QAAO"}
|
|
@@ -4,10 +4,9 @@ const require_dictionaryManipulator_getDefaultNode = require('./getDefaultNode.c
|
|
|
4
4
|
const require_dictionaryManipulator_getEmptyNode = require('./getEmptyNode.cjs');
|
|
5
5
|
const require_dictionaryManipulator_getNodeChildren = require('./getNodeChildren.cjs');
|
|
6
6
|
const require_dictionaryManipulator_getNodeType = require('./getNodeType.cjs');
|
|
7
|
+
const require_dictionaryManipulator_mergeDictionaries = require('./mergeDictionaries.cjs');
|
|
7
8
|
const require_dictionaryManipulator_orderDictionaries = require('./orderDictionaries.cjs');
|
|
8
9
|
const require_dictionaryManipulator_normalizeDictionary = require('./normalizeDictionary.cjs');
|
|
9
|
-
const require_dictionaryManipulator_getUnmergedDictionaryByKeyPath = require('./getUnmergedDictionaryByKeyPath.cjs');
|
|
10
|
-
const require_dictionaryManipulator_mergeDictionaries = require('./mergeDictionaries.cjs');
|
|
11
10
|
const require_dictionaryManipulator_removeContentNodeByKeyPath = require('./removeContentNodeByKeyPath.cjs');
|
|
12
11
|
const require_dictionaryManipulator_renameContentNodeByKeyPath = require('./renameContentNodeByKeyPath.cjs');
|
|
13
12
|
const require_dictionaryManipulator_updateNodeChildren = require('./updateNodeChildren.cjs');
|
|
@@ -18,7 +17,6 @@ exports.getDefaultNode = require_dictionaryManipulator_getDefaultNode.getDefault
|
|
|
18
17
|
exports.getEmptyNode = require_dictionaryManipulator_getEmptyNode.getEmptyNode;
|
|
19
18
|
exports.getNodeChildren = require_dictionaryManipulator_getNodeChildren.getNodeChildren;
|
|
20
19
|
exports.getNodeType = require_dictionaryManipulator_getNodeType.getNodeType;
|
|
21
|
-
exports.getUnmergedDictionaryByKeyPath = require_dictionaryManipulator_getUnmergedDictionaryByKeyPath.getUnmergedDictionaryByKeyPath;
|
|
22
20
|
exports.mergeDictionaries = require_dictionaryManipulator_mergeDictionaries.mergeDictionaries;
|
|
23
21
|
exports.normalizeDictionaries = require_dictionaryManipulator_normalizeDictionary.normalizeDictionaries;
|
|
24
22
|
exports.normalizeDictionary = require_dictionaryManipulator_normalizeDictionary.normalizeDictionary;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ const require_deepTransformPlugins_getLocalizedContent = require('./deepTransfor
|
|
|
25
25
|
const require_deepTransformPlugins_getMaskContent = require('./deepTransformPlugins/getMaskContent.cjs');
|
|
26
26
|
const require_deepTransformPlugins_getMissingLocalesContent = require('./deepTransformPlugins/getMissingLocalesContent.cjs');
|
|
27
27
|
const require_deepTransformPlugins_getReplacedValuesContent = require('./deepTransformPlugins/getReplacedValuesContent.cjs');
|
|
28
|
+
const require_deepTransformPlugins_getSplittedContent = require('./deepTransformPlugins/getSplittedContent.cjs');
|
|
28
29
|
const require_deepTransformPlugins_insertContentInDictionary = require('./deepTransformPlugins/insertContentInDictionary.cjs');
|
|
29
30
|
const require_dictionaryManipulator_editDictionaryByKeyPath = require('./dictionaryManipulator/editDictionaryByKeyPath.cjs');
|
|
30
31
|
const require_dictionaryManipulator_getContentNodeByKeyPath = require('./dictionaryManipulator/getContentNodeByKeyPath.cjs');
|
|
@@ -33,10 +34,9 @@ const require_dictionaryManipulator_getEmptyNode = require('./dictionaryManipula
|
|
|
33
34
|
const require_dictionaryManipulator_getNodeChildren = require('./dictionaryManipulator/getNodeChildren.cjs');
|
|
34
35
|
const require_utils_isValidReactElement = require('./utils/isValidReactElement.cjs');
|
|
35
36
|
const require_dictionaryManipulator_getNodeType = require('./dictionaryManipulator/getNodeType.cjs');
|
|
37
|
+
const require_dictionaryManipulator_mergeDictionaries = require('./dictionaryManipulator/mergeDictionaries.cjs');
|
|
36
38
|
const require_dictionaryManipulator_orderDictionaries = require('./dictionaryManipulator/orderDictionaries.cjs');
|
|
37
39
|
const require_dictionaryManipulator_normalizeDictionary = require('./dictionaryManipulator/normalizeDictionary.cjs');
|
|
38
|
-
const require_dictionaryManipulator_getUnmergedDictionaryByKeyPath = require('./dictionaryManipulator/getUnmergedDictionaryByKeyPath.cjs');
|
|
39
|
-
const require_dictionaryManipulator_mergeDictionaries = require('./dictionaryManipulator/mergeDictionaries.cjs');
|
|
40
40
|
const require_dictionaryManipulator_removeContentNodeByKeyPath = require('./dictionaryManipulator/removeContentNodeByKeyPath.cjs');
|
|
41
41
|
const require_dictionaryManipulator_renameContentNodeByKeyPath = require('./dictionaryManipulator/renameContentNodeByKeyPath.cjs');
|
|
42
42
|
const require_dictionaryManipulator_updateNodeChildren = require('./dictionaryManipulator/updateNodeChildren.cjs');
|
|
@@ -119,9 +119,10 @@ exports.getNodeType = require_dictionaryManipulator_getNodeType.getNodeType;
|
|
|
119
119
|
exports.getPathWithoutLocale = require_localization_getPathWithoutLocale.getPathWithoutLocale;
|
|
120
120
|
exports.getPerLocaleDictionary = require_deepTransformPlugins_getLocalizedContent.getPerLocaleDictionary;
|
|
121
121
|
exports.getReplacedValuesContent = require_deepTransformPlugins_getReplacedValuesContent.getReplacedValuesContent;
|
|
122
|
+
exports.getSplittedContent = require_deepTransformPlugins_getSplittedContent.getSplittedContent;
|
|
123
|
+
exports.getSplittedDictionaryContent = require_deepTransformPlugins_getSplittedContent.getSplittedDictionaryContent;
|
|
122
124
|
exports.getStorageAttributes = require_getStorageAttributes.getStorageAttributes;
|
|
123
125
|
exports.getTranslation = require_interpreter_getTranslation.getTranslation;
|
|
124
|
-
exports.getUnmergedDictionaryByKeyPath = require_dictionaryManipulator_getUnmergedDictionaryByKeyPath.getUnmergedDictionaryByKeyPath;
|
|
125
126
|
exports.insert = require_transpiler_insertion_insertion.insert;
|
|
126
127
|
exports.insertContentInDictionary = require_deepTransformPlugins_insertContentInDictionary.insertContentInDictionary;
|
|
127
128
|
exports.insertionPlugin = require_interpreter_getContent_plugins.insertionPlugin;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { NodeType } from "@intlayer/types";
|
|
2
|
+
|
|
3
|
+
//#region src/deepTransformPlugins/getSplittedContent.ts
|
|
4
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
const hasNodeType = (value) => isObject(value) && typeof value.nodeType === "string";
|
|
6
|
+
const mergeValues = (a, b) => {
|
|
7
|
+
if (a === void 0) return b;
|
|
8
|
+
if (b === void 0) return a;
|
|
9
|
+
if (Array.isArray(a) && Array.isArray(b)) return [...a, ...b];
|
|
10
|
+
if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {
|
|
11
|
+
const result = { ...a };
|
|
12
|
+
for (const key of Object.keys(b)) result[key] = mergeValues(result[key], b[key]);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
return b;
|
|
16
|
+
};
|
|
17
|
+
const mergeSplitResults = (base, addition) => {
|
|
18
|
+
const result = { ...base };
|
|
19
|
+
result.common = mergeValues(base.common, addition.common);
|
|
20
|
+
const localeKeys = new Set([...Object.keys(base).filter((k) => k !== "common"), ...Object.keys(addition).filter((k) => k !== "common")]);
|
|
21
|
+
for (const key of localeKeys) result[key] = mergeValues(base[key], addition[key]);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
const splitNode = (node) => {
|
|
25
|
+
if (isObject(node) && node?.nodeType === NodeType.Translation) {
|
|
26
|
+
const translations = node[NodeType.Translation];
|
|
27
|
+
const result = {};
|
|
28
|
+
for (const locale of Object.keys(translations)) {
|
|
29
|
+
const child = translations[locale];
|
|
30
|
+
const childSplit = splitNode(child);
|
|
31
|
+
const mergedForLocale = mergeValues(childSplit.common, void 0);
|
|
32
|
+
let recomposed;
|
|
33
|
+
for (const key of Object.keys(childSplit)) {
|
|
34
|
+
if (key === "common") continue;
|
|
35
|
+
recomposed = mergeValues(recomposed, childSplit[key]);
|
|
36
|
+
}
|
|
37
|
+
const finalLocaleNode = mergeValues(mergedForLocale, recomposed);
|
|
38
|
+
if (finalLocaleNode !== void 0) result[locale] = finalLocaleNode;
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(node)) {
|
|
43
|
+
const commonArray = [];
|
|
44
|
+
const perLocaleArrays = {};
|
|
45
|
+
node.forEach((child) => {
|
|
46
|
+
const childSplit = splitNode(child);
|
|
47
|
+
if (childSplit.common !== void 0) commonArray.push(childSplit.common);
|
|
48
|
+
for (const key of Object.keys(childSplit)) {
|
|
49
|
+
if (key === "common") continue;
|
|
50
|
+
if (!perLocaleArrays[key]) perLocaleArrays[key] = [];
|
|
51
|
+
const value = childSplit[key];
|
|
52
|
+
if (value !== void 0) perLocaleArrays[key].push(value);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const result = {};
|
|
56
|
+
if (commonArray.length > 0) result.common = commonArray;
|
|
57
|
+
for (const key of Object.keys(perLocaleArrays)) result[key] = perLocaleArrays[key];
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
if (isObject(node) && !hasNodeType(node)) {
|
|
61
|
+
let accumulated = {};
|
|
62
|
+
for (const key of Object.keys(node)) {
|
|
63
|
+
const childSplit = splitNode(node[key]);
|
|
64
|
+
if (childSplit.common !== void 0) accumulated = mergeSplitResults(accumulated, { common: { [key]: childSplit.common } });
|
|
65
|
+
for (const locale of Object.keys(childSplit)) {
|
|
66
|
+
if (locale === "common") continue;
|
|
67
|
+
accumulated = mergeSplitResults(accumulated, { [locale]: { [key]: childSplit[locale] } });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return accumulated;
|
|
71
|
+
}
|
|
72
|
+
return { common: node };
|
|
73
|
+
};
|
|
74
|
+
const getSplittedContent = (content) => {
|
|
75
|
+
const split = splitNode(content);
|
|
76
|
+
const output = {};
|
|
77
|
+
if (split.common !== void 0) output.common = split.common;
|
|
78
|
+
for (const key of Object.keys(split)) {
|
|
79
|
+
if (key === "common") continue;
|
|
80
|
+
const value = split[key];
|
|
81
|
+
if (value !== void 0) output[key] = value;
|
|
82
|
+
}
|
|
83
|
+
return output;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Splits the `content` field of a Dictionary into "common" and per-locale buckets.
|
|
87
|
+
*
|
|
88
|
+
* Given a dictionary like:
|
|
89
|
+
* ```js
|
|
90
|
+
* {
|
|
91
|
+
* key: "my-key",
|
|
92
|
+
* content: {
|
|
93
|
+
* commonContent: "common content",
|
|
94
|
+
* multilingualContent: t({
|
|
95
|
+
* en: "english content",
|
|
96
|
+
* fr: "french content",
|
|
97
|
+
* de: "german content",
|
|
98
|
+
* }),
|
|
99
|
+
* },
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* It produces:
|
|
104
|
+
* ```js
|
|
105
|
+
* {
|
|
106
|
+
* common: { commonContent: "common content" },
|
|
107
|
+
* en: { multilingualContent: "english content" },
|
|
108
|
+
* fr: { multilingualContent: "french content" },
|
|
109
|
+
* de: { multilingualContent: "german content" },
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @param dictionary - The input dictionary object with possible multilingual or common content.
|
|
114
|
+
* @returns An object mapping "common" and each locale to their corresponding content subtrees.
|
|
115
|
+
*/
|
|
116
|
+
const getSplittedDictionaryContent = (dictionary) => getSplittedContent(dictionary.content);
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { getSplittedContent, getSplittedDictionaryContent };
|
|
120
|
+
//# sourceMappingURL=getSplittedContent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSplittedContent.mjs","names":["result: Record<string, any>","result: SplitResult","recomposed: ContentNode | undefined","commonArray: any[]","perLocaleArrays: Record<string, any[]>","accumulated: SplitResult","output: Record<string, ContentNode>"],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":["import {\n type ContentNode,\n type DeclaredLocales,\n type Dictionary,\n NodeType,\n} from '@intlayer/types';\n\ntype SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {\n common: T;\n};\n\ntype SplitResult = Record<string, ContentNode | undefined> & {\n common?: ContentNode;\n};\n\nconst isObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst hasNodeType = (value: unknown): value is { nodeType: string } =>\n isObject(value) && typeof (value as any).nodeType === 'string';\n\nconst mergeValues = (\n a: ContentNode | undefined,\n b: ContentNode | undefined\n): ContentNode | undefined => {\n if (a === undefined) return b;\n if (b === undefined) return a;\n\n if (Array.isArray(a) && Array.isArray(b)) {\n // Concatenate arrays when merging sibling results\n return [...a, ...b] as unknown as ContentNode;\n }\n\n if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {\n const result: Record<string, any> = { ...a };\n for (const key of Object.keys(b)) {\n result[key] = mergeValues(\n result[key] as unknown as ContentNode | undefined,\n (b as Record<string, any>)[key] as unknown as ContentNode | undefined\n );\n }\n return result as ContentNode;\n }\n\n // For primitives or differing structures, prefer b (more recent)\n return b;\n};\n\nconst mergeSplitResults = (\n base: SplitResult,\n addition: SplitResult\n): SplitResult => {\n const result: SplitResult = { ...base };\n\n // Merge common\n result.common = mergeValues(base.common, addition.common);\n\n // Merge each locale key present in either side\n const localeKeys = new Set<string>([\n ...Object.keys(base).filter((k) => k !== 'common'),\n ...Object.keys(addition).filter((k) => k !== 'common'),\n ]);\n\n for (const key of localeKeys) {\n // @ts-ignore: dynamic keys for locales\n result[key] = mergeValues(\n base[key] as ContentNode | undefined,\n addition[key] as ContentNode | undefined\n );\n }\n\n return result;\n};\n\nconst splitNode = (node: ContentNode): SplitResult => {\n // Translation node: allocate entirely to per-locale buckets\n if (isObject(node) && (node as any)?.nodeType === NodeType.Translation) {\n const translations = (node as any)[NodeType.Translation] as Record<\n string,\n ContentNode\n >;\n\n const result: SplitResult = {};\n for (const locale of Object.keys(translations)) {\n const child = translations[locale];\n const childSplit = splitNode(child);\n\n // The content under a translation belongs to the locale, not common\n // Merge common portion of the child (if any) into the locale as well\n const mergedForLocale = mergeValues(childSplit.common, undefined);\n\n // Compose locale content: prefer the fully rebuilt child by resolving deeper translations recursively\n // which are already split inside childSplit. We need to recompose a single node for this locale.\n // Recompose by merging all keys in childSplit except 'common' into a single node, then merge child's common.\n let recomposed: ContentNode | undefined;\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n recomposed = mergeValues(\n recomposed,\n childSplit[key] as ContentNode | undefined\n );\n }\n const finalLocaleNode = mergeValues(mergedForLocale, recomposed);\n\n if (finalLocaleNode !== undefined) {\n // @ts-ignore dynamic locale key\n result[locale] = finalLocaleNode;\n }\n }\n\n return result;\n }\n\n // Arrays: split each element and merge results index-wise\n if (Array.isArray(node)) {\n const commonArray: any[] = [];\n const perLocaleArrays: Record<string, any[]> = {};\n\n node.forEach((child) => {\n const childSplit = splitNode(child as ContentNode);\n\n if (childSplit.common !== undefined) {\n commonArray.push(childSplit.common);\n }\n\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n if (!perLocaleArrays[key]) perLocaleArrays[key] = [];\n const value = childSplit[key];\n if (value !== undefined) perLocaleArrays[key].push(value);\n }\n });\n\n const result: SplitResult = {};\n if (commonArray.length > 0)\n result.common = commonArray as unknown as ContentNode;\n for (const key of Object.keys(perLocaleArrays)) {\n // @ts-ignore dynamic locale key\n result[key] = perLocaleArrays[key] as unknown as ContentNode;\n }\n return result;\n }\n\n // Objects (non-typed): recursively split properties\n if (isObject(node) && !hasNodeType(node)) {\n let accumulated: SplitResult = {};\n\n for (const key of Object.keys(node)) {\n const childSplit = splitNode((node as any)[key] as ContentNode);\n\n // Assign property into common\n if (childSplit.common !== undefined) {\n accumulated = mergeSplitResults(accumulated, {\n common: { [key]: childSplit.common } as unknown as ContentNode,\n });\n }\n\n // Assign property into each locale bucket\n for (const locale of Object.keys(childSplit)) {\n if (locale === 'common') continue;\n accumulated = mergeSplitResults(accumulated, {\n // @ts-ignore dynamic locale key\n [locale]: { [key]: childSplit[locale] } as unknown as ContentNode,\n });\n }\n }\n\n return accumulated;\n }\n\n // Primitives or typed nodes (non-translation): entirely common\n return { common: node } as SplitResult;\n};\n\nexport const getSplittedContent = (\n content: ContentNode\n): SplittedContentOutput => {\n const split = splitNode(content);\n\n // Build final output with only defined sections\n const output: Record<string, ContentNode> = {};\n if (split.common !== undefined) {\n output.common = split.common;\n }\n for (const key of Object.keys(split)) {\n if (key === 'common') continue;\n const value = split[key] as ContentNode | undefined;\n if (value !== undefined) {\n output[key] = value;\n }\n }\n\n return output as unknown as SplittedContentOutput;\n};\n\n/**\n * Splits the `content` field of a Dictionary into \"common\" and per-locale buckets.\n *\n * Given a dictionary like:\n * ```js\n * {\n * key: \"my-key\",\n * content: {\n * commonContent: \"common content\",\n * multilingualContent: t({\n * en: \"english content\",\n * fr: \"french content\",\n * de: \"german content\",\n * }),\n * },\n * }\n * ```\n *\n * It produces:\n * ```js\n * {\n * common: { commonContent: \"common content\" },\n * en: { multilingualContent: \"english content\" },\n * fr: { multilingualContent: \"french content\" },\n * de: { multilingualContent: \"german content\" },\n * }\n * ```\n *\n * @param dictionary - The input dictionary object with possible multilingual or common content.\n * @returns An object mapping \"common\" and each locale to their corresponding content subtrees.\n */\nexport const getSplittedDictionaryContent = (\n dictionary: Dictionary\n): SplittedContentOutput<Dictionary['content']> =>\n getSplittedContent(dictionary.content);\n"],"mappings":"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"}
|
|
@@ -5,6 +5,7 @@ import { getLocalizedContent, getPerLocaleDictionary } from "./getLocalizedConte
|
|
|
5
5
|
import { buildMaskPlugin, getMaskContent } from "./getMaskContent.mjs";
|
|
6
6
|
import { checkMissingLocalesPlugin, getMissingLocalesContent } from "./getMissingLocalesContent.mjs";
|
|
7
7
|
import { getReplacedValuesContent } from "./getReplacedValuesContent.mjs";
|
|
8
|
+
import { getSplittedContent, getSplittedDictionaryContent } from "./getSplittedContent.mjs";
|
|
8
9
|
import { insertContentInDictionary } from "./insertContentInDictionary.mjs";
|
|
9
10
|
|
|
10
|
-
export { buildMaskPlugin, checkMissingLocalesPlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getLocalizedContent, getMaskContent, getMissingLocalesContent, getPerLocaleDictionary, getReplacedValuesContent, insertContentInDictionary };
|
|
11
|
+
export { buildMaskPlugin, checkMissingLocalesPlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getLocalizedContent, getMaskContent, getMissingLocalesContent, getPerLocaleDictionary, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, insertContentInDictionary };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { NodeType } from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/dictionaryManipulator/getContentNodeByKeyPath.ts
|
|
4
|
-
const getContentNodeByKeyPath = (dictionaryContent, keyPath) => {
|
|
4
|
+
const getContentNodeByKeyPath = (dictionaryContent, keyPath, fallbackLocale) => {
|
|
5
5
|
let currentValue = structuredClone(dictionaryContent);
|
|
6
|
-
for (const keyObj of keyPath)
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
for (const keyObj of keyPath) {
|
|
7
|
+
if (fallbackLocale && currentValue?.nodeType === NodeType.Translation) currentValue = currentValue?.[NodeType.Translation]?.[fallbackLocale];
|
|
8
|
+
if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) currentValue = currentValue?.[keyObj.key];
|
|
9
|
+
if (keyObj.type === NodeType.Translation || keyObj.type === NodeType.Condition || keyObj.type === NodeType.Enumeration) currentValue = currentValue?.[keyObj.type]?.[keyObj.key];
|
|
10
|
+
if (keyObj.type === NodeType.Markdown || keyObj.type === NodeType.Insertion || keyObj.type === NodeType.File) currentValue = currentValue?.[keyObj.type];
|
|
11
|
+
}
|
|
9
12
|
return currentValue;
|
|
10
13
|
};
|
|
11
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getContentNodeByKeyPath.mjs","names":["currentValue: any"],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getContentNodeByKeyPath.mjs","names":["currentValue: any"],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import {\n type ContentNode,\n type KeyPath,\n type Locale,\n NodeType,\n} from '@intlayer/types';\n\nexport const getContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n fallbackLocale?: Locale\n): ContentNode => {\n let currentValue: any = structuredClone(dictionaryContent);\n\n for (const keyObj of keyPath) {\n // Auto-resolve translation nodes when fallbackLocale is provided\n if (fallbackLocale && currentValue?.nodeType === NodeType.Translation) {\n currentValue = currentValue?.[NodeType.Translation]?.[fallbackLocale];\n }\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n currentValue = currentValue?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Condition ||\n keyObj.type === NodeType.Enumeration\n ) {\n currentValue = currentValue?.[keyObj.type]?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n currentValue = currentValue?.[keyObj.type];\n }\n }\n\n return currentValue as ContentNode;\n};\n"],"mappings":";;;AAOA,MAAa,2BACX,mBACA,SACA,mBACgB;CAChB,IAAIA,eAAoB,gBAAgB,kBAAkB;AAE1D,MAAK,MAAM,UAAU,SAAS;AAE5B,MAAI,kBAAkB,cAAc,aAAa,SAAS,YACxD,gBAAe,eAAe,SAAS,eAAe;AAGxD,MAAI,OAAO,SAAS,SAAS,UAAU,OAAO,SAAS,SAAS,MAC9D,gBAAe,eAAe,OAAO;AAGvC,MACE,OAAO,SAAS,SAAS,eACzB,OAAO,SAAS,SAAS,aACzB,OAAO,SAAS,SAAS,YAEzB,gBAAe,eAAe,OAAO,QAAQ,OAAO;AAGtD,MACE,OAAO,SAAS,SAAS,YACzB,OAAO,SAAS,SAAS,aACzB,OAAO,SAAS,SAAS,KAEzB,gBAAe,eAAe,OAAO;;AAIzC,QAAO"}
|
|
@@ -8,7 +8,7 @@ const getUnmergedDictionaryByKeyPath = (dictionaryKey, keyPath, dictionariesReco
|
|
|
8
8
|
const unmergedEntries = (dictionariesRecord ?? getUnmergedDictionaries(configuration$1))?.[dictionaryKey];
|
|
9
9
|
if (!unmergedEntries) return null;
|
|
10
10
|
const normalizedUnmergedEntries = normalizeDictionaries(unmergedEntries, configuration$1);
|
|
11
|
-
for (const dictionary of normalizedUnmergedEntries) if (getContentNodeByKeyPath(dictionary.content, keyPath)) return dictionary;
|
|
11
|
+
for (const dictionary of normalizedUnmergedEntries) if (getContentNodeByKeyPath(dictionary.content, keyPath)) return unmergedEntries.find((entry) => entry.localId === dictionary.localId);
|
|
12
12
|
for (const dictionary of unmergedEntries) if (getContentNodeByKeyPath(dictionary.content, keyPath)) return dictionary;
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUnmergedDictionaryByKeyPath.mjs","names":["intlayerConfiguration","configuration"],"sources":["../../../src/dictionaryManipulator/getUnmergedDictionaryByKeyPath.ts"],"sourcesContent":["import intlayerConfiguration from '@intlayer/config/built';\nimport type { IntlayerConfig, KeyPath } from '@intlayer/types';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { getContentNodeByKeyPath } from './getContentNodeByKeyPath';\nimport { normalizeDictionaries } from './normalizeDictionary';\n\nexport const getUnmergedDictionaryByKeyPath = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n dictionariesRecord?: UnmergedDictionaries,\n configuration: IntlayerConfig = intlayerConfiguration\n) => {\n const unmergedEntries = (dictionariesRecord ??\n getUnmergedDictionaries(configuration))?.[dictionaryKey];\n\n if (!unmergedEntries) {\n return null;\n }\n\n const normalizedUnmergedEntries = normalizeDictionaries(\n unmergedEntries,\n configuration\n );\n\n for (const dictionary of normalizedUnmergedEntries) {\n const content = getContentNodeByKeyPath(dictionary.content, keyPath);\n\n if (content) {\n return dictionary;\n }\n }\n\n for (const dictionary of unmergedEntries) {\n const content = getContentNodeByKeyPath(dictionary.content, keyPath);\n\n if (content) {\n return dictionary;\n }\n }\n};\n"],"mappings":";;;;;;AASA,MAAa,kCACX,eACA,SACA,oBACA,kBAAgCA,kBAC7B;CACH,MAAM,mBAAmB,sBACvB,wBAAwBC,gBAAc,IAAI;AAE5C,KAAI,CAAC,gBACH,QAAO;
|
|
1
|
+
{"version":3,"file":"getUnmergedDictionaryByKeyPath.mjs","names":["intlayerConfiguration","configuration"],"sources":["../../../src/dictionaryManipulator/getUnmergedDictionaryByKeyPath.ts"],"sourcesContent":["import intlayerConfiguration from '@intlayer/config/built';\nimport type { IntlayerConfig, KeyPath } from '@intlayer/types';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { getContentNodeByKeyPath } from './getContentNodeByKeyPath';\nimport { normalizeDictionaries } from './normalizeDictionary';\n\nexport const getUnmergedDictionaryByKeyPath = (\n dictionaryKey: string,\n keyPath: KeyPath[],\n dictionariesRecord?: UnmergedDictionaries,\n configuration: IntlayerConfig = intlayerConfiguration\n) => {\n const unmergedEntries = (dictionariesRecord ??\n getUnmergedDictionaries(configuration))?.[dictionaryKey];\n\n if (!unmergedEntries) {\n return null;\n }\n\n // First search for the dictionary in the normalized dictionaries as it's what see the client editor selector\n // Then return the original unmerged dictionary if not found in the normalized dictionaries\n\n const normalizedUnmergedEntries = normalizeDictionaries(\n unmergedEntries,\n configuration\n );\n\n for (const dictionary of normalizedUnmergedEntries) {\n const content = getContentNodeByKeyPath(dictionary.content, keyPath);\n\n if (content) {\n return unmergedEntries.find(\n (entry) => entry.localId === dictionary.localId\n );\n }\n }\n\n // If not found in the normalized dictionaries, search in the original unmerged dictionaries directly\n\n for (const dictionary of unmergedEntries) {\n const content = getContentNodeByKeyPath(dictionary.content, keyPath);\n\n if (content) {\n return dictionary;\n }\n }\n};\n"],"mappings":";;;;;;AASA,MAAa,kCACX,eACA,SACA,oBACA,kBAAgCA,kBAC7B;CACH,MAAM,mBAAmB,sBACvB,wBAAwBC,gBAAc,IAAI;AAE5C,KAAI,CAAC,gBACH,QAAO;CAMT,MAAM,4BAA4B,sBAChC,iBACAA,gBACD;AAED,MAAK,MAAM,cAAc,0BAGvB,KAFgB,wBAAwB,WAAW,SAAS,QAAQ,CAGlE,QAAO,gBAAgB,MACpB,UAAU,MAAM,YAAY,WAAW,QACzC;AAML,MAAK,MAAM,cAAc,gBAGvB,KAFgB,wBAAwB,WAAW,SAAS,QAAQ,CAGlE,QAAO"}
|
|
@@ -4,12 +4,11 @@ import { getDefaultNode } from "./getDefaultNode.mjs";
|
|
|
4
4
|
import { getEmptyNode } from "./getEmptyNode.mjs";
|
|
5
5
|
import { getNodeChildren } from "./getNodeChildren.mjs";
|
|
6
6
|
import { getNodeType } from "./getNodeType.mjs";
|
|
7
|
+
import { mergeDictionaries } from "./mergeDictionaries.mjs";
|
|
7
8
|
import { orderDictionaries } from "./orderDictionaries.mjs";
|
|
8
9
|
import { normalizeDictionaries, normalizeDictionary } from "./normalizeDictionary.mjs";
|
|
9
|
-
import { getUnmergedDictionaryByKeyPath } from "./getUnmergedDictionaryByKeyPath.mjs";
|
|
10
|
-
import { mergeDictionaries } from "./mergeDictionaries.mjs";
|
|
11
10
|
import { removeContentNodeByKeyPath } from "./removeContentNodeByKeyPath.mjs";
|
|
12
11
|
import { renameContentNodeByKeyPath } from "./renameContentNodeByKeyPath.mjs";
|
|
13
12
|
import { updateNodeChildren } from "./updateNodeChildren.mjs";
|
|
14
13
|
|
|
15
|
-
export { editDictionaryByKeyPath, getContentNodeByKeyPath, getDefaultNode, getEmptyNode, getNodeChildren, getNodeType,
|
|
14
|
+
export { editDictionaryByKeyPath, getContentNodeByKeyPath, getDefaultNode, getEmptyNode, getNodeChildren, getNodeType, mergeDictionaries, normalizeDictionaries, normalizeDictionary, orderDictionaries, removeContentNodeByKeyPath, renameContentNodeByKeyPath, updateNodeChildren };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -25,6 +25,7 @@ import { getLocalizedContent, getPerLocaleDictionary } from "./deepTransformPlug
|
|
|
25
25
|
import { buildMaskPlugin, getMaskContent } from "./deepTransformPlugins/getMaskContent.mjs";
|
|
26
26
|
import { checkMissingLocalesPlugin, getMissingLocalesContent } from "./deepTransformPlugins/getMissingLocalesContent.mjs";
|
|
27
27
|
import { getReplacedValuesContent } from "./deepTransformPlugins/getReplacedValuesContent.mjs";
|
|
28
|
+
import { getSplittedContent, getSplittedDictionaryContent } from "./deepTransformPlugins/getSplittedContent.mjs";
|
|
28
29
|
import { insertContentInDictionary } from "./deepTransformPlugins/insertContentInDictionary.mjs";
|
|
29
30
|
import { editDictionaryByKeyPath } from "./dictionaryManipulator/editDictionaryByKeyPath.mjs";
|
|
30
31
|
import { getContentNodeByKeyPath } from "./dictionaryManipulator/getContentNodeByKeyPath.mjs";
|
|
@@ -33,10 +34,9 @@ import { getEmptyNode } from "./dictionaryManipulator/getEmptyNode.mjs";
|
|
|
33
34
|
import { getNodeChildren } from "./dictionaryManipulator/getNodeChildren.mjs";
|
|
34
35
|
import { isValidElement } from "./utils/isValidReactElement.mjs";
|
|
35
36
|
import { getNodeType } from "./dictionaryManipulator/getNodeType.mjs";
|
|
37
|
+
import { mergeDictionaries } from "./dictionaryManipulator/mergeDictionaries.mjs";
|
|
36
38
|
import { orderDictionaries } from "./dictionaryManipulator/orderDictionaries.mjs";
|
|
37
39
|
import { normalizeDictionaries, normalizeDictionary } from "./dictionaryManipulator/normalizeDictionary.mjs";
|
|
38
|
-
import { getUnmergedDictionaryByKeyPath } from "./dictionaryManipulator/getUnmergedDictionaryByKeyPath.mjs";
|
|
39
|
-
import { mergeDictionaries } from "./dictionaryManipulator/mergeDictionaries.mjs";
|
|
40
40
|
import { removeContentNodeByKeyPath } from "./dictionaryManipulator/removeContentNodeByKeyPath.mjs";
|
|
41
41
|
import { renameContentNodeByKeyPath } from "./dictionaryManipulator/renameContentNodeByKeyPath.mjs";
|
|
42
42
|
import { updateNodeChildren } from "./dictionaryManipulator/updateNodeChildren.mjs";
|
|
@@ -64,4 +64,4 @@ import { getLocalizedUrl } from "./localization/getLocalizedUrl.mjs";
|
|
|
64
64
|
import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.mjs";
|
|
65
65
|
import { isSameKeyPath } from "./utils/isSameKeyPath.mjs";
|
|
66
66
|
|
|
67
|
-
export { CachedIntl, CachedIntl as Intl, LocaleStorage, buildMaskPlugin, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, condition as cond, conditionPlugin, createCachedIntl, currency, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, getBrowserLocale, getCondition, getContent, getContentNodeByKeyPath, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTMLTextDir, getInsertionValues, getIntlayer, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getReplacedValuesContent, getStorageAttributes, getTranslation,
|
|
67
|
+
export { CachedIntl, CachedIntl as Intl, LocaleStorage, buildMaskPlugin, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, condition as cond, conditionPlugin, createCachedIntl, currency, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, getBrowserLocale, getCondition, getContent, getContentNodeByKeyPath, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTMLTextDir, getInsertionValues, getIntlayer, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, insertion as insert, insertContentInDictionary, insertionPlugin, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeDictionaries, normalizeDictionary, number, orderDictionaries, parseYaml, percentage, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, setLocaleInStorage, translation as t, translationPlugin, units, updateNodeChildren };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeProps, Plugins } from "../interpreter/getContent/plugins.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types3 from "@intlayer/types";
|
|
3
3
|
import { ContentNode, DeclaredLocales, Dictionary, LocalesValues } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts
|
|
@@ -25,8 +25,8 @@ declare const getFilterMissingTranslationsDictionary: (dictionary: Dictionary, l
|
|
|
25
25
|
$schema?: string;
|
|
26
26
|
id?: string;
|
|
27
27
|
projectIds?: string[];
|
|
28
|
-
localId?:
|
|
29
|
-
localIds?:
|
|
28
|
+
localId?: _intlayer_types3.LocalDictionaryId;
|
|
29
|
+
localIds?: _intlayer_types3.LocalDictionaryId[];
|
|
30
30
|
key: string;
|
|
31
31
|
title?: string;
|
|
32
32
|
description?: string;
|
|
@@ -35,7 +35,7 @@ declare const getFilterMissingTranslationsDictionary: (dictionary: Dictionary, l
|
|
|
35
35
|
filePath?: string;
|
|
36
36
|
tags?: string[];
|
|
37
37
|
locale?: LocalesValues;
|
|
38
|
-
fill?:
|
|
38
|
+
fill?: _intlayer_types3.Fill;
|
|
39
39
|
filled?: true;
|
|
40
40
|
priority?: number;
|
|
41
41
|
live?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeProps } from "../interpreter/getContent/plugins.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
3
3
|
import { ContentNode, Dictionary, LocalesValues } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/deepTransformPlugins/getFilteredLocalesContent.d.ts
|
|
@@ -9,8 +9,8 @@ declare const getFilteredLocalesDictionary: (dictionary: Dictionary, locale: Loc
|
|
|
9
9
|
$schema?: string;
|
|
10
10
|
id?: string;
|
|
11
11
|
projectIds?: string[];
|
|
12
|
-
localId?:
|
|
13
|
-
localIds?:
|
|
12
|
+
localId?: _intlayer_types0.LocalDictionaryId;
|
|
13
|
+
localIds?: _intlayer_types0.LocalDictionaryId[];
|
|
14
14
|
key: string;
|
|
15
15
|
title?: string;
|
|
16
16
|
description?: string;
|
|
@@ -19,7 +19,7 @@ declare const getFilteredLocalesDictionary: (dictionary: Dictionary, locale: Loc
|
|
|
19
19
|
filePath?: string;
|
|
20
20
|
tags?: string[];
|
|
21
21
|
locale?: LocalesValues;
|
|
22
|
-
fill?:
|
|
22
|
+
fill?: _intlayer_types0.Fill;
|
|
23
23
|
filled?: true;
|
|
24
24
|
priority?: number;
|
|
25
25
|
live?: boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ContentNode, DeclaredLocales, Dictionary } from "@intlayer/types";
|
|
2
|
+
|
|
3
|
+
//#region src/deepTransformPlugins/getSplittedContent.d.ts
|
|
4
|
+
type SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {
|
|
5
|
+
common: T;
|
|
6
|
+
};
|
|
7
|
+
declare const getSplittedContent: (content: ContentNode) => SplittedContentOutput;
|
|
8
|
+
/**
|
|
9
|
+
* Splits the `content` field of a Dictionary into "common" and per-locale buckets.
|
|
10
|
+
*
|
|
11
|
+
* Given a dictionary like:
|
|
12
|
+
* ```js
|
|
13
|
+
* {
|
|
14
|
+
* key: "my-key",
|
|
15
|
+
* content: {
|
|
16
|
+
* commonContent: "common content",
|
|
17
|
+
* multilingualContent: t({
|
|
18
|
+
* en: "english content",
|
|
19
|
+
* fr: "french content",
|
|
20
|
+
* de: "german content",
|
|
21
|
+
* }),
|
|
22
|
+
* },
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* It produces:
|
|
27
|
+
* ```js
|
|
28
|
+
* {
|
|
29
|
+
* common: { commonContent: "common content" },
|
|
30
|
+
* en: { multilingualContent: "english content" },
|
|
31
|
+
* fr: { multilingualContent: "french content" },
|
|
32
|
+
* de: { multilingualContent: "german content" },
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param dictionary - The input dictionary object with possible multilingual or common content.
|
|
37
|
+
* @returns An object mapping "common" and each locale to their corresponding content subtrees.
|
|
38
|
+
*/
|
|
39
|
+
declare const getSplittedDictionaryContent: (dictionary: Dictionary) => SplittedContentOutput<Dictionary["content"]>;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { getSplittedContent, getSplittedDictionaryContent };
|
|
42
|
+
//# sourceMappingURL=getSplittedContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSplittedContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":[],"mappings":";;;KAOK,0BAA0B,eAAe,OAAO,iBAAiB;UAC5D;AAHe,CAAA;AAEM,cAuKlB,kBAvKkB,EAAA,CAAA,OAAA,EAwKpB,WAxKoB,EAAA,GAyK5B,qBAzK4B;;;;;;AAuK/B;AAoDA;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,2CACC,eACX,sBAAsB"}
|
|
@@ -5,5 +5,6 @@ import { getLocalizedContent, getPerLocaleDictionary } from "./getLocalizedConte
|
|
|
5
5
|
import { buildMaskPlugin, getMaskContent } from "./getMaskContent.js";
|
|
6
6
|
import { checkMissingLocalesPlugin, getMissingLocalesContent } from "./getMissingLocalesContent.js";
|
|
7
7
|
import { getReplacedValuesContent } from "./getReplacedValuesContent.js";
|
|
8
|
+
import { getSplittedContent, getSplittedDictionaryContent } from "./getSplittedContent.js";
|
|
8
9
|
import { insertContentInDictionary } from "./insertContentInDictionary.js";
|
|
9
|
-
export { buildMaskPlugin, checkMissingLocalesPlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getLocalizedContent, getMaskContent, getMissingLocalesContent, getPerLocaleDictionary, getReplacedValuesContent, insertContentInDictionary };
|
|
10
|
+
export { buildMaskPlugin, checkMissingLocalesPlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getLocalizedContent, getMaskContent, getMissingLocalesContent, getPerLocaleDictionary, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, insertContentInDictionary };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ContentNode, KeyPath } from "@intlayer/types";
|
|
1
|
+
import { ContentNode, KeyPath, Locale } from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/dictionaryManipulator/getContentNodeByKeyPath.d.ts
|
|
4
|
-
declare const getContentNodeByKeyPath: (dictionaryContent: ContentNode, keyPath: KeyPath[]) => ContentNode;
|
|
4
|
+
declare const getContentNodeByKeyPath: (dictionaryContent: ContentNode, keyPath: KeyPath[], fallbackLocale?: Locale) => ContentNode;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { getContentNodeByKeyPath };
|
|
7
7
|
//# sourceMappingURL=getContentNodeByKeyPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getContentNodeByKeyPath.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getContentNodeByKeyPath.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":[],"mappings":";;;cAOa,6CACQ,sBACV,4BACQ,WAChB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types8 from "@intlayer/types";
|
|
2
2
|
import { IntlayerConfig, KeyPath } from "@intlayer/types";
|
|
3
3
|
import { UnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
4
4
|
|
|
5
5
|
//#region src/dictionaryManipulator/getUnmergedDictionaryByKeyPath.d.ts
|
|
6
|
-
declare const getUnmergedDictionaryByKeyPath: (dictionaryKey: string, keyPath: KeyPath[], dictionariesRecord?: UnmergedDictionaries, configuration?: IntlayerConfig) =>
|
|
6
|
+
declare const getUnmergedDictionaryByKeyPath: (dictionaryKey: string, keyPath: KeyPath[], dictionariesRecord?: UnmergedDictionaries, configuration?: IntlayerConfig) => _intlayer_types8.Dictionary;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { getUnmergedDictionaryByKeyPath };
|
|
9
9
|
//# sourceMappingURL=getUnmergedDictionaryByKeyPath.d.ts.map
|
|
@@ -4,11 +4,10 @@ import { getDefaultNode } from "./getDefaultNode.js";
|
|
|
4
4
|
import { getEmptyNode } from "./getEmptyNode.js";
|
|
5
5
|
import { getNodeChildren } from "./getNodeChildren.js";
|
|
6
6
|
import { getNodeType } from "./getNodeType.js";
|
|
7
|
-
import { getUnmergedDictionaryByKeyPath } from "./getUnmergedDictionaryByKeyPath.js";
|
|
8
7
|
import { mergeDictionaries } from "./mergeDictionaries.js";
|
|
9
8
|
import { normalizeDictionaries, normalizeDictionary } from "./normalizeDictionary.js";
|
|
10
9
|
import { orderDictionaries } from "./orderDictionaries.js";
|
|
11
10
|
import { removeContentNodeByKeyPath } from "./removeContentNodeByKeyPath.js";
|
|
12
11
|
import { renameContentNodeByKeyPath } from "./renameContentNodeByKeyPath.js";
|
|
13
12
|
import { updateNodeChildren } from "./updateNodeChildren.js";
|
|
14
|
-
export { editDictionaryByKeyPath, getContentNodeByKeyPath, getDefaultNode, getEmptyNode, getNodeChildren, getNodeType,
|
|
13
|
+
export { editDictionaryByKeyPath, getContentNodeByKeyPath, getDefaultNode, getEmptyNode, getNodeChildren, getNodeType, mergeDictionaries, normalizeDictionaries, normalizeDictionary, orderDictionaries, removeContentNodeByKeyPath, renameContentNodeByKeyPath, updateNodeChildren };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
2
2
|
import { Dictionary } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/dictionaryManipulator/orderDictionaries.d.ts
|
|
@@ -10,7 +10,7 @@ import { Dictionary } from "@intlayer/types";
|
|
|
10
10
|
* @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')
|
|
11
11
|
* @returns Ordered array of dictionaries
|
|
12
12
|
*/
|
|
13
|
-
declare const orderDictionaries: (dictionaries: Dictionary[], configuration?:
|
|
13
|
+
declare const orderDictionaries: (dictionaries: Dictionary[], configuration?: _intlayer_types0.IntlayerConfig) => Dictionary[];
|
|
14
14
|
//#endregion
|
|
15
15
|
export { orderDictionaries };
|
|
16
16
|
//# sourceMappingURL=orderDictionaries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStorageAttributes.d.ts","names":[],"sources":["../../src/getStorageAttributes.ts"],"sourcesContent":[],"mappings":";;;KAWK,WAAA;;EAAA,UAAA,EAES,IAFE,CAEG,iBAAA,EAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"getStorageAttributes.d.ts","names":[],"sources":["../../src/getStorageAttributes.ts"],"sourcesContent":[],"mappings":";;;KAWK,WAAA;;EAAA,UAAA,EAES,IAFE,CAEG,iBAAA,EAAA,MAAA,GAAA,MAAD,CAAA;AAAA,CAAA;AAGE,KAAf,eAAA,GAIW;EAIJ,IAAA,EAAA,MAAA;CACD;KALN,WAAA,GAMW;EACE,IAAA,EAAA,MAAA;CACP;AAAW,KAJV,0BAAA,GAIU;EAuLT,OAAA,EA1LF,WA0LE,EAAA;gBAzLG;kBACE;WACP;;;;;;;;cAuLE,gCACF,yCACR"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { getLocalizedContent, getPerLocaleDictionary } from "./deepTransformPlug
|
|
|
24
24
|
import { buildMaskPlugin, getMaskContent } from "./deepTransformPlugins/getMaskContent.js";
|
|
25
25
|
import { checkMissingLocalesPlugin, getMissingLocalesContent } from "./deepTransformPlugins/getMissingLocalesContent.js";
|
|
26
26
|
import { getReplacedValuesContent } from "./deepTransformPlugins/getReplacedValuesContent.js";
|
|
27
|
+
import { getSplittedContent, getSplittedDictionaryContent } from "./deepTransformPlugins/getSplittedContent.js";
|
|
27
28
|
import { insertContentInDictionary } from "./deepTransformPlugins/insertContentInDictionary.js";
|
|
28
29
|
import { editDictionaryByKeyPath } from "./dictionaryManipulator/editDictionaryByKeyPath.js";
|
|
29
30
|
import { getContentNodeByKeyPath } from "./dictionaryManipulator/getContentNodeByKeyPath.js";
|
|
@@ -31,7 +32,6 @@ import { getDefaultNode } from "./dictionaryManipulator/getDefaultNode.js";
|
|
|
31
32
|
import { getEmptyNode } from "./dictionaryManipulator/getEmptyNode.js";
|
|
32
33
|
import { getNodeChildren } from "./dictionaryManipulator/getNodeChildren.js";
|
|
33
34
|
import { getNodeType } from "./dictionaryManipulator/getNodeType.js";
|
|
34
|
-
import { getUnmergedDictionaryByKeyPath } from "./dictionaryManipulator/getUnmergedDictionaryByKeyPath.js";
|
|
35
35
|
import { mergeDictionaries } from "./dictionaryManipulator/mergeDictionaries.js";
|
|
36
36
|
import { normalizeDictionaries, normalizeDictionary } from "./dictionaryManipulator/normalizeDictionary.js";
|
|
37
37
|
import { orderDictionaries } from "./dictionaryManipulator/orderDictionaries.js";
|
|
@@ -64,4 +64,4 @@ import { CachedIntl, createCachedIntl } from "./utils/intl.js";
|
|
|
64
64
|
import { isSameKeyPath } from "./utils/isSameKeyPath.js";
|
|
65
65
|
import { isValidElement } from "./utils/isValidReactElement.js";
|
|
66
66
|
import { parseYaml } from "./utils/parseYaml.js";
|
|
67
|
-
export { CachedIntl, CachedIntl as Intl, ConditionCond, ConditionContent, ConditionContentStates, DeepTransformContent, DotPath, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, FileCond, FileContent, FileContentConstructor, Gender, GenderCond, GenderContent, GenderContentStates, GetNestingResult, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, InsertionContent, InsertionContentConstructor, IsAny, LocaleStorage, LocaleStorageOptions, MarkdownContent, MarkdownContentConstructor, NestedCond, NestedContent, NestedContentState, NodeProps, Plugins, ProcessedStorageAttributes, TranslationCond, TranslationContent, ValidDotPathsFor, buildMaskPlugin, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, condition as cond, conditionPlugin, createCachedIntl, currency, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, file, fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, getBrowserLocale, getCondition, getContent, getContentNodeByKeyPath, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTMLTextDir, getInsertionValues, getIntlayer, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getReplacedValuesContent, getStorageAttributes, getTranslation,
|
|
67
|
+
export { CachedIntl, CachedIntl as Intl, ConditionCond, ConditionContent, ConditionContentStates, DeepTransformContent, DotPath, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, FileCond, FileContent, FileContentConstructor, Gender, GenderCond, GenderContent, GenderContentStates, GetNestingResult, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, InsertionContent, InsertionContentConstructor, IsAny, LocaleStorage, LocaleStorageOptions, MarkdownContent, MarkdownContentConstructor, NestedCond, NestedContent, NestedContentState, NodeProps, Plugins, ProcessedStorageAttributes, TranslationCond, TranslationContent, ValidDotPathsFor, buildMaskPlugin, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, condition as cond, conditionPlugin, createCachedIntl, currency, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, file, fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, getBrowserLocale, getCondition, getContent, getContentNodeByKeyPath, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTMLTextDir, getInsertionValues, getIntlayer, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, insertion as insert, insertContentInDictionary, insertionPlugin, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeDictionaries, normalizeDictionary, number, orderDictionaries, parseYaml, percentage, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, setLocaleInStorage, translation as t, translationPlugin, units, updateNodeChildren };
|
|
@@ -23,7 +23,7 @@ type TranslationContent<Content$1 = unknown, RecordContent extends StrictModeLoc
|
|
|
23
23
|
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
24
24
|
*/
|
|
25
25
|
declare const translation: <Content = unknown, ContentRecord extends StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>>(content: ContentRecord) => TypedNodeModel<NodeType.Translation, ContentRecord, {
|
|
26
|
-
nodeType: "translation"
|
|
26
|
+
nodeType: NodeType.Translation | "translation";
|
|
27
27
|
} & {
|
|
28
28
|
translation: ContentRecord;
|
|
29
29
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation.d.ts","names":[],"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":[],"mappings":";;;KAOY,8DAGR,oBAAoB,aAAW,oBAAoB,cACnD,eAAe,QAAA,CAAS,aAAa;;AAJzC;;;;;;;;;AAIwD;;;;;;;;;;cAsBlD,WAKkB,EAAA,CAAA,UAAA,OAAA,EAAA,sBAFpB,mBAEoB,CAFA,OAEA,CAAA,GAFW,mBAEX,CAF+B,OAE/B,CAAA,CAAA,CAAA,OAAA,EAAb,aAAa,EAAA,GAAA,cAAA,CAAA,QAAA,CAAA,WAAA,EAAA,aAAA,EAAA;EAAA,QAAA,
|
|
1
|
+
{"version":3,"file":"translation.d.ts","names":[],"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":[],"mappings":";;;KAOY,8DAGR,oBAAoB,aAAW,oBAAoB,cACnD,eAAe,QAAA,CAAS,aAAa;;AAJzC;;;;;;;;;AAIwD;;;;;;;;;;cAsBlD,WAKkB,EAAA,CAAA,UAAA,OAAA,EAAA,sBAFpB,mBAEoB,CAFA,OAEA,CAAA,GAFW,mBAEX,CAF+B,OAE/B,CAAA,CAAA,CAAA,OAAA,EAAb,aAAa,EAAA,GAAA,cAAA,CAAA,QAAA,CAAA,WAAA,EAAA,aAAA,EAAA;EAAA,QAAA,sBAAA,GAAA,aAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/core",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.3-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
|
|
6
6
|
"keywords": [
|
|
@@ -98,29 +98,29 @@
|
|
|
98
98
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
|
-
"@intlayer/api": "7.0.
|
|
102
|
-
"@intlayer/config": "7.0.
|
|
103
|
-
"@intlayer/dictionaries-entry": "7.0.
|
|
104
|
-
"@intlayer/types": "7.0.
|
|
105
|
-
"@intlayer/unmerged-dictionaries-entry": "7.0.
|
|
101
|
+
"@intlayer/api": "7.0.3-canary.0",
|
|
102
|
+
"@intlayer/config": "7.0.3-canary.0",
|
|
103
|
+
"@intlayer/dictionaries-entry": "7.0.3-canary.0",
|
|
104
|
+
"@intlayer/types": "7.0.3-canary.0",
|
|
105
|
+
"@intlayer/unmerged-dictionaries-entry": "7.0.3-canary.0",
|
|
106
106
|
"deepmerge": "4.3.1"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@types/node": "24.9.1",
|
|
110
|
-
"@utils/ts-config": "7.0.
|
|
111
|
-
"@utils/ts-config-types": "7.0.
|
|
112
|
-
"@utils/tsdown-config": "7.0.
|
|
110
|
+
"@utils/ts-config": "7.0.3-canary.0",
|
|
111
|
+
"@utils/ts-config-types": "7.0.3-canary.0",
|
|
112
|
+
"@utils/tsdown-config": "7.0.3-canary.0",
|
|
113
113
|
"rimraf": "6.0.1",
|
|
114
114
|
"tsdown": "0.15.9",
|
|
115
115
|
"typescript": "5.9.3",
|
|
116
116
|
"vitest": "4.0.3"
|
|
117
117
|
},
|
|
118
118
|
"peerDependencies": {
|
|
119
|
-
"@intlayer/api": "7.0.
|
|
120
|
-
"@intlayer/config": "7.0.
|
|
121
|
-
"@intlayer/dictionaries-entry": "7.0.
|
|
122
|
-
"@intlayer/types": "7.0.
|
|
123
|
-
"@intlayer/unmerged-dictionaries-entry": "7.0.
|
|
119
|
+
"@intlayer/api": "7.0.3-canary.0",
|
|
120
|
+
"@intlayer/config": "7.0.3-canary.0",
|
|
121
|
+
"@intlayer/dictionaries-entry": "7.0.3-canary.0",
|
|
122
|
+
"@intlayer/types": "7.0.3-canary.0",
|
|
123
|
+
"@intlayer/unmerged-dictionaries-entry": "7.0.3-canary.0"
|
|
124
124
|
},
|
|
125
125
|
"engines": {
|
|
126
126
|
"node": ">=14.18"
|