@intlayer/chokidar 3.5.5 → 3.5.7
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/transpiler/declaration_file_to_dictionary/{i18n_dictionary/buildI18nDictionary.cjs → i18next_dictionary/buildI18nextDictionary.cjs} +5 -5
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/{i18n_dictionary → i18next_dictionary}/convertContentDeclarationInto18nDictionaries.cjs +17 -3
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/{i18n_dictionary → i18next_dictionary}/convertPluralsValues.cjs +7 -20
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/{i18n_dictionary → i18next_dictionary}/index.cjs +4 -4
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/{i18n_dictionary → i18next_dictionary}/writeDictionary.cjs +2 -2
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.cjs.map +1 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs +2 -2
- package/dist/cjs/transpiler/declaration_file_to_dictionary/index.cjs.map +1 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs +52 -0
- package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/{i18n_dictionary/buildI18nDictionary.mjs → i18next_dictionary/buildI18nextDictionary.mjs} +3 -3
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/{i18n_dictionary → i18next_dictionary}/convertContentDeclarationInto18nDictionaries.mjs +16 -2
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.mjs +13 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.mjs +2 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/{i18n_dictionary → i18next_dictionary}/writeDictionary.mjs +2 -2
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.mjs.map +1 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/index.mjs.map +1 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs +28 -0
- package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/{i18n_dictionary/buildI18nDictionary.d.ts → i18next_dictionary/buildI18nextDictionary.d.ts} +1 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/{i18n_dictionary → i18next_dictionary}/convertContentDeclarationInto18nDictionaries.d.ts +2 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.d.ts +2 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.d.ts +2 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts +7 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts.map +1 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.d.ts +7 -0
- package/dist/types/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.d.ts.map +1 -0
- package/package.json +15 -15
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18n_dictionary/buildI18nDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18n_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.cjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/buildI18nDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.mjs +0 -26
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/index.mjs +0 -2
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.mjs.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/buildI18nDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.d.ts +0 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/index.d.ts +0 -2
- package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/index.d.ts.map +0 -1
- package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.d.ts +0 -7
- package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.d.ts.map +0 -1
|
@@ -16,17 +16,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var buildI18nextDictionary_exports = {};
|
|
20
|
+
__export(buildI18nextDictionary_exports, {
|
|
21
21
|
buildI18nDictionary: () => buildI18nDictionary
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(buildI18nextDictionary_exports);
|
|
24
24
|
var import_convertContentDeclarationInto18nDictionaries = require('./convertContentDeclarationInto18nDictionaries.cjs');
|
|
25
25
|
var import_writeDictionary = require('./writeDictionary.cjs');
|
|
26
26
|
const buildI18nDictionary = async (contentDeclarations) => {
|
|
27
27
|
const dictionariesDeclaration = contentDeclarations.reduce((acc, dictionary) => {
|
|
28
28
|
const { key, content } = dictionary;
|
|
29
|
-
const i18Content = (0, import_convertContentDeclarationInto18nDictionaries.
|
|
29
|
+
const i18Content = (0, import_convertContentDeclarationInto18nDictionaries.createI18nextDictionaries)(content);
|
|
30
30
|
return {
|
|
31
31
|
...acc,
|
|
32
32
|
[key]: i18Content
|
|
@@ -41,4 +41,4 @@ const buildI18nDictionary = async (contentDeclarations) => {
|
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
buildI18nDictionary
|
|
43
43
|
});
|
|
44
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=buildI18nextDictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/core';\nimport { createI18nextDictionaries } from './convertContentDeclarationInto18nDictionaries';\nimport {\n writeDictionary,\n type DictionariesDeclaration,\n} from './writeDictionary';\n\n/**\n * This function transpile content declaration to i18n dictionaries\n */\nexport const buildI18nDictionary = async (\n contentDeclarations: Dictionary[]\n) => {\n // Create dictionaries for each nested content and format them\n const dictionariesDeclaration: DictionariesDeclaration =\n contentDeclarations.reduce((acc, dictionary) => {\n const { key, content } = dictionary;\n const i18Content = createI18nextDictionaries(content);\n\n return {\n ...acc,\n [key]: i18Content,\n };\n }, {});\n\n // Write the dictionaries to the file system\n const dictionariesPaths: string[] = await writeDictionary(\n dictionariesDeclaration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0DAA0C;AAC1C,6BAGO;AAKA,MAAM,sBAAsB,OACjC,wBACG;AAEH,QAAM,0BACJ,oBAAoB,OAAO,CAAC,KAAK,eAAe;AAC9C,UAAM,EAAE,KAAK,QAAQ,IAAI;AACzB,UAAM,iBAAa,+EAA0B,OAAO;AAEpD,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AAGP,QAAM,oBAA8B,UAAM;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -18,7 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var convertContentDeclarationInto18nDictionaries_exports = {};
|
|
20
20
|
__export(convertContentDeclarationInto18nDictionaries_exports, {
|
|
21
|
-
|
|
21
|
+
createI18nextDictionaries: () => createI18nextDictionaries
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(convertContentDeclarationInto18nDictionaries_exports);
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
@@ -56,6 +56,20 @@ const buildDictionary = (content, locale) => {
|
|
|
56
56
|
isReactNode(content)
|
|
57
57
|
) {
|
|
58
58
|
return JSON.stringify(content);
|
|
59
|
+
} else if (
|
|
60
|
+
// Nested object
|
|
61
|
+
typeof content === "object" && Array.isArray(content)
|
|
62
|
+
) {
|
|
63
|
+
const result = [];
|
|
64
|
+
Object.keys(content).forEach((dictionaryValue) => {
|
|
65
|
+
result.push(
|
|
66
|
+
buildDictionary(
|
|
67
|
+
content[dictionaryValue],
|
|
68
|
+
locale
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
return result;
|
|
59
73
|
} else if (
|
|
60
74
|
// Nested object
|
|
61
75
|
typeof content === "object"
|
|
@@ -71,7 +85,7 @@ const buildDictionary = (content, locale) => {
|
|
|
71
85
|
}
|
|
72
86
|
return content;
|
|
73
87
|
};
|
|
74
|
-
const
|
|
88
|
+
const createI18nextDictionaries = (content) => {
|
|
75
89
|
const result = locales.reduce(
|
|
76
90
|
(acc, locale) => ({
|
|
77
91
|
...acc,
|
|
@@ -83,6 +97,6 @@ const createI18nDictionaries = (content) => {
|
|
|
83
97
|
};
|
|
84
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
85
99
|
0 && (module.exports = {
|
|
86
|
-
|
|
100
|
+
createI18nextDictionaries
|
|
87
101
|
});
|
|
88
102
|
//# sourceMappingURL=convertContentDeclarationInto18nDictionaries.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type TypedNode,\n type EnumerationContent,\n DictionaryValue,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nextDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst {\n internationalization: { locales },\n} = getConfiguration();\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (\n content: DictionaryValue,\n locale: Locales\n): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const result = (content as TranslationContent<unknown>)[\n NodeType.Translation\n ][locale];\n\n return buildDictionary(result as DictionaryValue, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(\n (content as EnumerationContent<unknown>)[NodeType.Enumeration]\n ).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as DictionaryValue,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object' &&\n Array.isArray(content)\n ) {\n const result: unknown[] = [];\n\n Object.keys(content).forEach((dictionaryValue) => {\n result.push(\n buildDictionary(\n content[dictionaryValue as keyof typeof content] as DictionaryValue,\n locale\n )\n );\n });\n\n return result;\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content).forEach((dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content[dictionaryValue as keyof typeof content] as DictionaryValue,\n locale\n );\n });\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nextDictionaries = (\n content: DictionaryValue\n): I18nextDictionariesOutput => {\n // Map dictionaries for each locale\n const result: I18nextDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,kBAMO;AACP,kCAAqC;AAKrC,MAAM;AAAA,EACJ,sBAAsB,EAAE,QAAQ;AAClC,QAAI,gCAAiB;AAErB,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CACtB,SACA,WACY;AACZ;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,qBAAS;AAAA,IAC7C;AACA,UAAM,SAAU,QACd,qBAAS,WACX,EAAE,MAAM;AAER,WAAO,gBAAgB,QAA2B,MAAM;AAAA,EAC1D;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,qBAAS;AAAA,IAC7C;AACA,UAAM,UAAmC,CAAC;AAE1C,WAAO;AAAA,MACJ,QAAwC,qBAAS,WAAW;AAAA,IAC/D,EAAE,QAAQ,CAAC,aAAa;AACtB,YAAM,mBAAe,kDAAqB,QAAQ;AAElD,YAAM,QAAS,QACb,QACF;AAEA,cAAQ,GAAG,YAAY,IAAI,YAAY,EAAE,IAAI;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,YAAY,OAAkC;AAAA,IAC9C;AACA,WAAO,KAAK,UAAU,OAAO;AAAA,EAC/B;AAAA;AAAA,IAEE,OAAO,YAAY,YACnB,MAAM,QAAQ,OAAO;AAAA,IACrB;AACA,UAAM,SAAoB,CAAC;AAE3B,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO;AAAA,QACL;AAAA,UACE,QAAQ,eAAuC;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,OAAO,YAAY;AAAA,IACnB;AACA,UAAM,SAAkC,CAAC;AAEzC,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO,eAAe,IAAI;AAAA,QACxB,QAAQ,eAAuC;AAAA,QAC/C;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,4BAA4B,CACvC,YAC8B;AAE9B,QAAM,SAAoC,QAAQ;AAAA,IAChD,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,CAAC,MAAM,GAAG,gBAAgB,SAAS,MAAM;AAAA,IAC3C;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -22,26 +22,13 @@ __export(convertPluralsValues_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(convertPluralsValues_exports);
|
|
24
24
|
const convertPluralsValues = (number) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case "4":
|
|
33
|
-
return "four";
|
|
34
|
-
case "5":
|
|
35
|
-
return "five";
|
|
36
|
-
case "6":
|
|
37
|
-
return "six";
|
|
38
|
-
case "7":
|
|
39
|
-
return "seven";
|
|
40
|
-
case "8":
|
|
41
|
-
return "eight";
|
|
42
|
-
default:
|
|
43
|
-
return number.toString();
|
|
44
|
-
}
|
|
25
|
+
const numberValue = Number(number);
|
|
26
|
+
if (numberValue === 0) return "zero";
|
|
27
|
+
else if (numberValue === 1) return "singular";
|
|
28
|
+
else if (numberValue === 2) return "two";
|
|
29
|
+
else if (numberValue <= 7) return "few";
|
|
30
|
+
else if (numberValue <= 99) return "many";
|
|
31
|
+
else return "other";
|
|
45
32
|
};
|
|
46
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
47
34
|
0 && (module.exports = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.ts"],"sourcesContent":["export const convertPluralsValues = (number: string | number): string => {\n const numberValue = Number(number);\n\n if (numberValue === 0) return 'zero';\n else if (numberValue === 1) return 'singular';\n else if (numberValue === 2) return 'two';\n else if (numberValue <= 7) return 'few';\n else if (numberValue <= 99) return 'many';\n else return 'other';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,uBAAuB,CAAC,WAAoC;AACvE,QAAM,cAAc,OAAO,MAAM;AAEjC,MAAI,gBAAgB,EAAG,QAAO;AAAA,WACrB,gBAAgB,EAAG,QAAO;AAAA,WAC1B,gBAAgB,EAAG,QAAO;AAAA,WAC1B,eAAe,EAAG,QAAO;AAAA,WACzB,eAAe,GAAI,QAAO;AAAA,MAC9B,QAAO;AACd;","names":[]}
|
|
@@ -13,11 +13,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
};
|
|
14
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var
|
|
17
|
-
module.exports = __toCommonJS(
|
|
18
|
-
__reExport(
|
|
16
|
+
var i18next_dictionary_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(i18next_dictionary_exports);
|
|
18
|
+
__reExport(i18next_dictionary_exports, require('./buildI18nextDictionary.cjs'), module.exports);
|
|
19
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
20
|
0 && (module.exports = {
|
|
21
|
-
...require('./
|
|
21
|
+
...require('./buildI18nextDictionary.cjs')
|
|
22
22
|
});
|
|
23
23
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.ts"],"sourcesContent":["export * from './buildI18nextDictionary';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uCAAc,qCAAd;","names":[]}
|
|
@@ -25,7 +25,7 @@ var import_promises = require("fs/promises");
|
|
|
25
25
|
var import_path = require("path");
|
|
26
26
|
var import_config = require("@intlayer/config");
|
|
27
27
|
const { content } = (0, import_config.getConfiguration)();
|
|
28
|
-
const {
|
|
28
|
+
const { i18nextResourcesDir } = content;
|
|
29
29
|
const writeDictionary = async (dictionariesDeclaration) => {
|
|
30
30
|
const resultDictionariesPaths = [];
|
|
31
31
|
for (const [nameSpace, localContent] of Object.entries(
|
|
@@ -34,7 +34,7 @@ const writeDictionary = async (dictionariesDeclaration) => {
|
|
|
34
34
|
for await (const [locale, content2] of Object.entries(localContent)) {
|
|
35
35
|
const contentString = JSON.stringify(content2);
|
|
36
36
|
const outputFileName = `${nameSpace}.json`;
|
|
37
|
-
const resultDirPath = (0, import_path.resolve)(
|
|
37
|
+
const resultDirPath = (0, import_path.resolve)(i18nextResourcesDir, locale);
|
|
38
38
|
const resultFilePath = (0, import_path.resolve)(resultDirPath, outputFileName);
|
|
39
39
|
await (0, import_promises.mkdir)(resultDirPath, { recursive: true });
|
|
40
40
|
await (0, import_promises.writeFile)(resultFilePath, contentString, "utf8").catch((err) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { I18nextDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { i18nextResourcesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(i18nextResourcesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiC;AACjC,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,oBAAoB,IAAI;AAOzB,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,oBAAgB,qBAAQ,qBAAqB,MAAM;AACzD,YAAM,qBAAiB,qBAAQ,eAAe,cAAc;AAG5D,gBAAM,uBAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,gBAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
@@ -22,14 +22,14 @@ __export(declaration_file_to_dictionary_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(declaration_file_to_dictionary_exports);
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
|
-
var
|
|
25
|
+
var import_i18next_dictionary = require('./i18next_dictionary/index.cjs');
|
|
26
26
|
var import_intlayer_dictionary = require('./intlayer_dictionary/index.cjs');
|
|
27
27
|
const {
|
|
28
28
|
content: { dictionaryOutput }
|
|
29
29
|
} = (0, import_config.getConfiguration)();
|
|
30
30
|
const buildDictionary = async (contentDeclarationsPaths) => {
|
|
31
31
|
if (dictionaryOutput.includes("i18next")) {
|
|
32
|
-
await (0,
|
|
32
|
+
await (0, import_i18next_dictionary.buildI18nDictionary)(contentDeclarationsPaths);
|
|
33
33
|
}
|
|
34
34
|
if (dictionaryOutput.includes("intlayer")) {
|
|
35
35
|
return await (0, import_intlayer_dictionary.buildIntlayerDictionary)(contentDeclarationsPaths);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './i18next_dictionary/index';\nimport { buildIntlayerDictionary } from './intlayer_dictionary/index';\n\nconst {\n content: { dictionaryOutput },\n} = getConfiguration();\n\nexport const buildDictionary = async (\n contentDeclarationsPaths: Dictionary[]\n): Promise<string[]> => {\n if (dictionaryOutput.includes('i18next')) {\n await buildI18nDictionary(contentDeclarationsPaths);\n }\n\n if (dictionaryOutput.includes('intlayer')) {\n return await buildIntlayerDictionary(contentDeclarationsPaths);\n }\n\n return [];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,gCAAoC;AACpC,iCAAwC;AAExC,MAAM;AAAA,EACJ,SAAS,EAAE,iBAAiB;AAC9B,QAAI,gCAAiB;AAEd,MAAM,kBAAkB,OAC7B,6BACsB;AACtB,MAAI,iBAAiB,SAAS,SAAS,GAAG;AACxC,cAAM,+CAAoB,wBAAwB;AAAA,EACpD;AAEA,MAAI,iBAAiB,SAAS,UAAU,GAAG;AACzC,WAAO,UAAM,oDAAwB,wBAAwB;AAAA,EAC/D;AAEA,SAAO,CAAC;AACV;","names":[]}
|
package/dist/cjs/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.cjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var writeDictionary_exports = {};
|
|
20
|
+
__export(writeDictionary_exports, {
|
|
21
|
+
writeDictionary: () => writeDictionary
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(writeDictionary_exports);
|
|
24
|
+
var import_promises = require("fs/promises");
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_config = require("@intlayer/config");
|
|
27
|
+
const { content } = (0, import_config.getConfiguration)();
|
|
28
|
+
const { reactIntlMessagesDir } = content;
|
|
29
|
+
const writeDictionary = async (dictionariesDeclaration) => {
|
|
30
|
+
const resultDictionariesPaths = [];
|
|
31
|
+
for (const [nameSpace, localContent] of Object.entries(
|
|
32
|
+
dictionariesDeclaration
|
|
33
|
+
)) {
|
|
34
|
+
for await (const [locale, content2] of Object.entries(localContent)) {
|
|
35
|
+
const contentString = JSON.stringify(content2);
|
|
36
|
+
const outputFileName = `${nameSpace}.json`;
|
|
37
|
+
const resultDirPath = (0, import_path.resolve)(reactIntlMessagesDir, locale);
|
|
38
|
+
const resultFilePath = (0, import_path.resolve)(resultDirPath, outputFileName);
|
|
39
|
+
await (0, import_promises.mkdir)(resultDirPath, { recursive: true });
|
|
40
|
+
await (0, import_promises.writeFile)(resultFilePath, contentString, "utf8").catch((err) => {
|
|
41
|
+
console.error(`Error creating ${outputFileName}:`, err);
|
|
42
|
+
});
|
|
43
|
+
resultDictionariesPaths.push(resultFilePath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return resultDictionariesPaths;
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
writeDictionary
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=writeDictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { I18nextDictionariesOutput } from '../i18next_dictionary/convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { reactIntlMessagesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(reactIntlMessagesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiC;AACjC,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,qBAAqB,IAAI;AAO1B,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,oBAAgB,qBAAQ,sBAAsB,MAAM;AAC1D,YAAM,qBAAiB,qBAAQ,eAAe,cAAc;AAG5D,gBAAM,uBAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,gBAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createI18nextDictionaries } from './convertContentDeclarationInto18nDictionaries.mjs';
|
|
2
2
|
import {
|
|
3
3
|
writeDictionary
|
|
4
4
|
} from './writeDictionary.mjs';
|
|
5
5
|
const buildI18nDictionary = async (contentDeclarations) => {
|
|
6
6
|
const dictionariesDeclaration = contentDeclarations.reduce((acc, dictionary) => {
|
|
7
7
|
const { key, content } = dictionary;
|
|
8
|
-
const i18Content =
|
|
8
|
+
const i18Content = createI18nextDictionaries(content);
|
|
9
9
|
return {
|
|
10
10
|
...acc,
|
|
11
11
|
[key]: i18Content
|
|
@@ -19,4 +19,4 @@ const buildI18nDictionary = async (contentDeclarations) => {
|
|
|
19
19
|
export {
|
|
20
20
|
buildI18nDictionary
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=
|
|
22
|
+
//# sourceMappingURL=buildI18nextDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/core';\nimport { createI18nextDictionaries } from './convertContentDeclarationInto18nDictionaries';\nimport {\n writeDictionary,\n type DictionariesDeclaration,\n} from './writeDictionary';\n\n/**\n * This function transpile content declaration to i18n dictionaries\n */\nexport const buildI18nDictionary = async (\n contentDeclarations: Dictionary[]\n) => {\n // Create dictionaries for each nested content and format them\n const dictionariesDeclaration: DictionariesDeclaration =\n contentDeclarations.reduce((acc, dictionary) => {\n const { key, content } = dictionary;\n const i18Content = createI18nextDictionaries(content);\n\n return {\n ...acc,\n [key]: i18Content,\n };\n }, {});\n\n // Write the dictionaries to the file system\n const dictionariesPaths: string[] = await writeDictionary(\n dictionariesDeclaration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":"AACA,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,OAEK;AAKA,MAAM,sBAAsB,OACjC,wBACG;AAEH,QAAM,0BACJ,oBAAoB,OAAO,CAAC,KAAK,eAAe;AAC9C,UAAM,EAAE,KAAK,QAAQ,IAAI;AACzB,UAAM,aAAa,0BAA0B,OAAO;AAEpD,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AAGP,QAAM,oBAA8B,MAAM;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -35,6 +35,20 @@ const buildDictionary = (content, locale) => {
|
|
|
35
35
|
isReactNode(content)
|
|
36
36
|
) {
|
|
37
37
|
return JSON.stringify(content);
|
|
38
|
+
} else if (
|
|
39
|
+
// Nested object
|
|
40
|
+
typeof content === "object" && Array.isArray(content)
|
|
41
|
+
) {
|
|
42
|
+
const result = [];
|
|
43
|
+
Object.keys(content).forEach((dictionaryValue) => {
|
|
44
|
+
result.push(
|
|
45
|
+
buildDictionary(
|
|
46
|
+
content[dictionaryValue],
|
|
47
|
+
locale
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
38
52
|
} else if (
|
|
39
53
|
// Nested object
|
|
40
54
|
typeof content === "object"
|
|
@@ -50,7 +64,7 @@ const buildDictionary = (content, locale) => {
|
|
|
50
64
|
}
|
|
51
65
|
return content;
|
|
52
66
|
};
|
|
53
|
-
const
|
|
67
|
+
const createI18nextDictionaries = (content) => {
|
|
54
68
|
const result = locales.reduce(
|
|
55
69
|
(acc, locale) => ({
|
|
56
70
|
...acc,
|
|
@@ -61,6 +75,6 @@ const createI18nDictionaries = (content) => {
|
|
|
61
75
|
return result;
|
|
62
76
|
};
|
|
63
77
|
export {
|
|
64
|
-
|
|
78
|
+
createI18nextDictionaries
|
|
65
79
|
};
|
|
66
80
|
//# sourceMappingURL=convertContentDeclarationInto18nDictionaries.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type TypedNode,\n type EnumerationContent,\n DictionaryValue,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nextDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst {\n internationalization: { locales },\n} = getConfiguration();\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (\n content: DictionaryValue,\n locale: Locales\n): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const result = (content as TranslationContent<unknown>)[\n NodeType.Translation\n ][locale];\n\n return buildDictionary(result as DictionaryValue, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(\n (content as EnumerationContent<unknown>)[NodeType.Enumeration]\n ).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as DictionaryValue,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object' &&\n Array.isArray(content)\n ) {\n const result: unknown[] = [];\n\n Object.keys(content).forEach((dictionaryValue) => {\n result.push(\n buildDictionary(\n content[dictionaryValue as keyof typeof content] as DictionaryValue,\n locale\n )\n );\n });\n\n return result;\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content).forEach((dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content[dictionaryValue as keyof typeof content] as DictionaryValue,\n locale\n );\n });\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nextDictionaries = (\n content: DictionaryValue\n): I18nextDictionariesOutput => {\n // Map dictionaries for each locale\n const result: I18nextDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":"AAAA,SAAS,wBAAsC;AAC/C;AAAA,EACE;AAAA,OAKK;AACP,SAAS,4BAA4B;AAKrC,MAAM;AAAA,EACJ,sBAAsB,EAAE,QAAQ;AAClC,IAAI,iBAAiB;AAErB,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CACtB,SACA,WACY;AACZ;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,SAAU,QACd,SAAS,WACX,EAAE,MAAM;AAER,WAAO,gBAAgB,QAA2B,MAAM;AAAA,EAC1D;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,UAAmC,CAAC;AAE1C,WAAO;AAAA,MACJ,QAAwC,SAAS,WAAW;AAAA,IAC/D,EAAE,QAAQ,CAAC,aAAa;AACtB,YAAM,eAAe,qBAAqB,QAAQ;AAElD,YAAM,QAAS,QACb,QACF;AAEA,cAAQ,GAAG,YAAY,IAAI,YAAY,EAAE,IAAI;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,YAAY,OAAkC;AAAA,IAC9C;AACA,WAAO,KAAK,UAAU,OAAO;AAAA,EAC/B;AAAA;AAAA,IAEE,OAAO,YAAY,YACnB,MAAM,QAAQ,OAAO;AAAA,IACrB;AACA,UAAM,SAAoB,CAAC;AAE3B,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO;AAAA,QACL;AAAA,UACE,QAAQ,eAAuC;AAAA,UAC/C;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,OAAO,YAAY;AAAA,IACnB;AACA,UAAM,SAAkC,CAAC;AAEzC,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO,eAAe,IAAI;AAAA,QACxB,QAAQ,eAAuC;AAAA,QAC/C;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,4BAA4B,CACvC,YAC8B;AAE9B,QAAM,SAAoC,QAAQ;AAAA,IAChD,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,CAAC,MAAM,GAAG,gBAAgB,SAAS,MAAM;AAAA,IAC3C;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const convertPluralsValues = (number) => {
|
|
2
|
+
const numberValue = Number(number);
|
|
3
|
+
if (numberValue === 0) return "zero";
|
|
4
|
+
else if (numberValue === 1) return "singular";
|
|
5
|
+
else if (numberValue === 2) return "two";
|
|
6
|
+
else if (numberValue <= 7) return "few";
|
|
7
|
+
else if (numberValue <= 99) return "many";
|
|
8
|
+
else return "other";
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
convertPluralsValues
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=convertPluralsValues.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.ts"],"sourcesContent":["export const convertPluralsValues = (number: string | number): string => {\n const numberValue = Number(number);\n\n if (numberValue === 0) return 'zero';\n else if (numberValue === 1) return 'singular';\n else if (numberValue === 2) return 'two';\n else if (numberValue <= 7) return 'few';\n else if (numberValue <= 99) return 'many';\n else return 'other';\n};\n"],"mappings":"AAAO,MAAM,uBAAuB,CAAC,WAAoC;AACvE,QAAM,cAAc,OAAO,MAAM;AAEjC,MAAI,gBAAgB,EAAG,QAAO;AAAA,WACrB,gBAAgB,EAAG,QAAO;AAAA,WAC1B,gBAAgB,EAAG,QAAO;AAAA,WAC1B,eAAe,EAAG,QAAO;AAAA,WACzB,eAAe,GAAI,QAAO;AAAA,MAC9B,QAAO;AACd;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.ts"],"sourcesContent":["export * from './buildI18nextDictionary';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -2,7 +2,7 @@ import { mkdir, writeFile } from "fs/promises";
|
|
|
2
2
|
import { resolve } from "path";
|
|
3
3
|
import { getConfiguration } from "@intlayer/config";
|
|
4
4
|
const { content } = getConfiguration();
|
|
5
|
-
const {
|
|
5
|
+
const { i18nextResourcesDir } = content;
|
|
6
6
|
const writeDictionary = async (dictionariesDeclaration) => {
|
|
7
7
|
const resultDictionariesPaths = [];
|
|
8
8
|
for (const [nameSpace, localContent] of Object.entries(
|
|
@@ -11,7 +11,7 @@ const writeDictionary = async (dictionariesDeclaration) => {
|
|
|
11
11
|
for await (const [locale, content2] of Object.entries(localContent)) {
|
|
12
12
|
const contentString = JSON.stringify(content2);
|
|
13
13
|
const outputFileName = `${nameSpace}.json`;
|
|
14
|
-
const resultDirPath = resolve(
|
|
14
|
+
const resultDirPath = resolve(i18nextResourcesDir, locale);
|
|
15
15
|
const resultFilePath = resolve(resultDirPath, outputFileName);
|
|
16
16
|
await mkdir(resultDirPath, { recursive: true });
|
|
17
17
|
await writeFile(resultFilePath, contentString, "utf8").catch((err) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { I18nextDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { i18nextResourcesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(i18nextResourcesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAGjC,MAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,MAAM,EAAE,oBAAoB,IAAI;AAOzB,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,gBAAgB,QAAQ,qBAAqB,MAAM;AACzD,YAAM,iBAAiB,QAAQ,eAAe,cAAc;AAG5D,YAAM,MAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,YAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getConfiguration } from "@intlayer/config";
|
|
2
|
-
import { buildI18nDictionary } from './
|
|
2
|
+
import { buildI18nDictionary } from './i18next_dictionary/index.mjs';
|
|
3
3
|
import { buildIntlayerDictionary } from './intlayer_dictionary/index.mjs';
|
|
4
4
|
const {
|
|
5
5
|
content: { dictionaryOutput }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/declaration_file_to_dictionary/index.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { buildI18nDictionary } from './i18next_dictionary/index';\nimport { buildIntlayerDictionary } from './intlayer_dictionary/index';\n\nconst {\n content: { dictionaryOutput },\n} = getConfiguration();\n\nexport const buildDictionary = async (\n contentDeclarationsPaths: Dictionary[]\n): Promise<string[]> => {\n if (dictionaryOutput.includes('i18next')) {\n await buildI18nDictionary(contentDeclarationsPaths);\n }\n\n if (dictionaryOutput.includes('intlayer')) {\n return await buildIntlayerDictionary(contentDeclarationsPaths);\n }\n\n return [];\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AAExC,MAAM;AAAA,EACJ,SAAS,EAAE,iBAAiB;AAC9B,IAAI,iBAAiB;AAEd,MAAM,kBAAkB,OAC7B,6BACsB;AACtB,MAAI,iBAAiB,SAAS,SAAS,GAAG;AACxC,UAAM,oBAAoB,wBAAwB;AAAA,EACpD;AAEA,MAAI,iBAAiB,SAAS,UAAU,GAAG;AACzC,WAAO,MAAM,wBAAwB,wBAAwB;AAAA,EAC/D;AAEA,SAAO,CAAC;AACV;","names":[]}
|
package/dist/esm/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
import { getConfiguration } from "@intlayer/config";
|
|
4
|
+
const { content } = getConfiguration();
|
|
5
|
+
const { reactIntlMessagesDir } = content;
|
|
6
|
+
const writeDictionary = async (dictionariesDeclaration) => {
|
|
7
|
+
const resultDictionariesPaths = [];
|
|
8
|
+
for (const [nameSpace, localContent] of Object.entries(
|
|
9
|
+
dictionariesDeclaration
|
|
10
|
+
)) {
|
|
11
|
+
for await (const [locale, content2] of Object.entries(localContent)) {
|
|
12
|
+
const contentString = JSON.stringify(content2);
|
|
13
|
+
const outputFileName = `${nameSpace}.json`;
|
|
14
|
+
const resultDirPath = resolve(reactIntlMessagesDir, locale);
|
|
15
|
+
const resultFilePath = resolve(resultDirPath, outputFileName);
|
|
16
|
+
await mkdir(resultDirPath, { recursive: true });
|
|
17
|
+
await writeFile(resultFilePath, contentString, "utf8").catch((err) => {
|
|
18
|
+
console.error(`Error creating ${outputFileName}:`, err);
|
|
19
|
+
});
|
|
20
|
+
resultDictionariesPaths.push(resultFilePath);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return resultDictionariesPaths;
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
writeDictionary
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=writeDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { I18nextDictionariesOutput } from '../i18next_dictionary/convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { reactIntlMessagesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(reactIntlMessagesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAGjC,MAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,MAAM,EAAE,qBAAqB,IAAI;AAO1B,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,gBAAgB,QAAQ,sBAAsB,MAAM;AAC1D,YAAM,iBAAiB,QAAQ,eAAe,cAAc;AAG5D,YAAM,MAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,YAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
@@ -3,4 +3,4 @@ import type { Dictionary } from '@intlayer/core';
|
|
|
3
3
|
* This function transpile content declaration to i18n dictionaries
|
|
4
4
|
*/
|
|
5
5
|
export declare const buildI18nDictionary: (contentDeclarations: Dictionary[]) => Promise<string[]>;
|
|
6
|
-
//# sourceMappingURL=
|
|
6
|
+
//# sourceMappingURL=buildI18nextDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildI18nextDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOjD;;GAEG;AACH,eAAO,MAAM,mBAAmB,wBACT,UAAU,EAAE,sBAoBlC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Locales } from '@intlayer/config';
|
|
2
2
|
import { DictionaryValue } from '@intlayer/core';
|
|
3
3
|
type Dictionary = Record<string, unknown>;
|
|
4
|
-
export type
|
|
5
|
-
export declare const
|
|
4
|
+
export type I18nextDictionariesOutput = Partial<Record<Locales, Dictionary>>;
|
|
5
|
+
export declare const createI18nextDictionaries: (content: DictionaryValue) => I18nextDictionariesOutput;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=convertContentDeclarationInto18nDictionaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertContentDeclarationInto18nDictionaries.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAKL,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAGxB,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1C,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AA0F7E,eAAO,MAAM,yBAAyB,YAC3B,eAAe,KACvB,yBAWF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertPluralsValues.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/convertPluralsValues.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,WAAY,MAAM,GAAG,MAAM,KAAG,MAS9D,CAAC"}
|
package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { I18nextDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';
|
|
2
|
+
export type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;
|
|
3
|
+
/**
|
|
4
|
+
* This function writes the dictionaries to the file system
|
|
5
|
+
*/
|
|
6
|
+
export declare const writeDictionary: (dictionariesDeclaration: DictionariesDeclaration) => Promise<string[]>;
|
|
7
|
+
//# sourceMappingURL=writeDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/writeDictionary.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAK3F,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,eAAe,4BACD,uBAAuB,sBA2BjD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { I18nextDictionariesOutput } from '../i18next_dictionary/convertContentDeclarationInto18nDictionaries';
|
|
2
|
+
export type DictionariesDeclaration = Record<string, I18nextDictionariesOutput>;
|
|
3
|
+
/**
|
|
4
|
+
* This function writes the dictionaries to the file system
|
|
5
|
+
*/
|
|
6
|
+
export declare const writeDictionary: (dictionariesDeclaration: DictionariesDeclaration) => Promise<string[]>;
|
|
7
|
+
//# sourceMappingURL=writeDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/reactIntl_dictionary/writeDictionary.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,oEAAoE,CAAC;AAK/G,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,eAAe,4BACD,uBAAuB,sBA2BjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Chokidar application for IntLayer - Transpile IntLayer declaration files into dictionaries.",
|
|
6
6
|
"keywords": [
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"quicktype-core": "^23.0.170",
|
|
68
68
|
"react": "^18.3.1",
|
|
69
69
|
"rimraf": "^6.0.1",
|
|
70
|
-
"@intlayer/
|
|
71
|
-
"@intlayer/
|
|
72
|
-
"@intlayer/
|
|
73
|
-
"intlayer": "
|
|
74
|
-
"
|
|
70
|
+
"@intlayer/backend": "3.5.7",
|
|
71
|
+
"@intlayer/config": "3.5.7",
|
|
72
|
+
"@intlayer/core": "3.5.7",
|
|
73
|
+
"@intlayer/design-system": "3.5.7",
|
|
74
|
+
"intlayer": "3.5.7"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@changesets/cli": "2.27.10",
|
|
@@ -85,18 +85,18 @@
|
|
|
85
85
|
"tsup": "^8.3.5",
|
|
86
86
|
"typescript": "^5.7.2",
|
|
87
87
|
"webpack-watch-files-plugin": "^1.2.1",
|
|
88
|
-
"@utils/eslint-config": "
|
|
89
|
-
"@utils/ts-config": "
|
|
90
|
-
"@utils/ts-config-types": "
|
|
91
|
-
"@utils/tsup-config": "
|
|
88
|
+
"@utils/eslint-config": "1.0.4",
|
|
89
|
+
"@utils/ts-config": "1.0.4",
|
|
90
|
+
"@utils/ts-config-types": "1.0.4",
|
|
91
|
+
"@utils/tsup-config": "1.0.4"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"fast-glob": "^3.3.2",
|
|
95
|
-
"@intlayer/backend": "
|
|
96
|
-
"@intlayer/
|
|
97
|
-
"@intlayer/
|
|
98
|
-
"
|
|
99
|
-
"intlayer": "
|
|
95
|
+
"@intlayer/backend": "3.5.7",
|
|
96
|
+
"@intlayer/core": "3.5.7",
|
|
97
|
+
"@intlayer/design-system": "3.5.7",
|
|
98
|
+
"intlayer": "^3.5.7",
|
|
99
|
+
"@intlayer/config": "3.5.7"
|
|
100
100
|
},
|
|
101
101
|
"engines": {
|
|
102
102
|
"node": ">=14.18"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/buildI18nDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/core';\nimport { createI18nDictionaries } from './convertContentDeclarationInto18nDictionaries';\nimport {\n writeDictionary,\n type DictionariesDeclaration,\n} from './writeDictionary';\n\n/**\n * This function transpile content declaration to i18n dictionaries\n */\nexport const buildI18nDictionary = async (\n contentDeclarations: Dictionary[]\n) => {\n // Create dictionaries for each nested content and format them\n const dictionariesDeclaration: DictionariesDeclaration =\n contentDeclarations.reduce((acc, dictionary) => {\n const { key, content } = dictionary;\n const i18Content = createI18nDictionaries(content);\n\n return {\n ...acc,\n [key]: i18Content,\n };\n }, {});\n\n // Write the dictionaries to the file system\n const dictionariesPaths: string[] = await writeDictionary(\n dictionariesDeclaration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0DAAuC;AACvC,6BAGO;AAKA,MAAM,sBAAsB,OACjC,wBACG;AAEH,QAAM,0BACJ,oBAAoB,OAAO,CAAC,KAAK,eAAe;AAC9C,UAAM,EAAE,KAAK,QAAQ,IAAI;AACzB,UAAM,iBAAa,4EAAuB,OAAO;AAEjD,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AAGP,QAAM,oBAA8B,UAAM;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type TypedNode,\n type EnumerationContent,\n DictionaryValue,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst {\n internationalization: { locales },\n} = getConfiguration();\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (\n content: DictionaryValue,\n locale: Locales\n): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const result = (content as TranslationContent<unknown>)[\n NodeType.Translation\n ][locale];\n\n return buildDictionary(result as DictionaryValue, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(\n (content as EnumerationContent<unknown>)[NodeType.Enumeration]\n ).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as DictionaryValue,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content).forEach((dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content[dictionaryValue as keyof typeof content] as DictionaryValue,\n locale\n );\n });\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nDictionaries = (\n content: DictionaryValue\n): I18nDictionariesOutput => {\n // Map dictionaries for each locale\n const result: I18nDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,kBAMO;AACP,kCAAqC;AAKrC,MAAM;AAAA,EACJ,sBAAsB,EAAE,QAAQ;AAClC,QAAI,gCAAiB;AAErB,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CACtB,SACA,WACY;AACZ;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,qBAAS;AAAA,IAC7C;AACA,UAAM,SAAU,QACd,qBAAS,WACX,EAAE,MAAM;AAER,WAAO,gBAAgB,QAA2B,MAAM;AAAA,EAC1D;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,qBAAS;AAAA,IAC7C;AACA,UAAM,UAAmC,CAAC;AAE1C,WAAO;AAAA,MACJ,QAAwC,qBAAS,WAAW;AAAA,IAC/D,EAAE,QAAQ,CAAC,aAAa;AACtB,YAAM,mBAAe,kDAAqB,QAAQ;AAElD,YAAM,QAAS,QACb,QACF;AAEA,cAAQ,GAAG,YAAY,IAAI,YAAY,EAAE,IAAI;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,YAAY,OAAkC;AAAA,IAC9C;AACA,WAAO,KAAK,UAAU,OAAO;AAAA,EAC/B;AAAA;AAAA,IAEE,OAAO,YAAY;AAAA,IACnB;AACA,UAAM,SAAkC,CAAC;AAEzC,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO,eAAe,IAAI;AAAA,QACxB,QAAQ,eAAuC;AAAA,QAC/C;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,yBAAyB,CACpC,YAC2B;AAE3B,QAAM,SAAiC,QAAQ;AAAA,IAC7C,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,CAAC,MAAM,GAAG,gBAAgB,SAAS,MAAM;AAAA,IAC3C;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.ts"],"sourcesContent":["export const convertPluralsValues = (number: string): string => {\n switch (number) {\n case '1':\n return 'one';\n case '2':\n return 'two';\n case '3':\n return 'three';\n case '4':\n return 'four';\n case '5':\n return 'five';\n case '6':\n return 'six';\n case '7':\n return 'seven';\n case '8':\n return 'eight';\n default:\n return number.toString();\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,uBAAuB,CAAC,WAA2B;AAC9D,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO,OAAO,SAAS;AAAA,EAC3B;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/index.ts"],"sourcesContent":["export * from './buildI18nDictionary';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oCAAc,kCAAd;","names":[]}
|
package/dist/cjs/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { I18nDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { i18nDictionariesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(i18nDictionariesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiC;AACjC,kBAAwB;AACxB,oBAAiC;AAGjC,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,oBAAoB,IAAI;AAOzB,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,oBAAgB,qBAAQ,qBAAqB,MAAM;AACzD,YAAM,qBAAiB,qBAAQ,eAAe,cAAc;AAG5D,gBAAM,uBAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,gBAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/buildI18nDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/core';\nimport { createI18nDictionaries } from './convertContentDeclarationInto18nDictionaries';\nimport {\n writeDictionary,\n type DictionariesDeclaration,\n} from './writeDictionary';\n\n/**\n * This function transpile content declaration to i18n dictionaries\n */\nexport const buildI18nDictionary = async (\n contentDeclarations: Dictionary[]\n) => {\n // Create dictionaries for each nested content and format them\n const dictionariesDeclaration: DictionariesDeclaration =\n contentDeclarations.reduce((acc, dictionary) => {\n const { key, content } = dictionary;\n const i18Content = createI18nDictionaries(content);\n\n return {\n ...acc,\n [key]: i18Content,\n };\n }, {});\n\n // Write the dictionaries to the file system\n const dictionariesPaths: string[] = await writeDictionary(\n dictionariesDeclaration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":"AACA,SAAS,8BAA8B;AACvC;AAAA,EACE;AAAA,OAEK;AAKA,MAAM,sBAAsB,OACjC,wBACG;AAEH,QAAM,0BACJ,oBAAoB,OAAO,CAAC,KAAK,eAAe;AAC9C,UAAM,EAAE,KAAK,QAAQ,IAAI;AACzB,UAAM,aAAa,uBAAuB,OAAO;AAEjD,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AAGP,QAAM,oBAA8B,MAAM;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config';\nimport {\n NodeType,\n type TranslationContent,\n type TypedNode,\n type EnumerationContent,\n DictionaryValue,\n} from '@intlayer/core';\nimport { convertPluralsValues } from './convertPluralsValues';\n\ntype Dictionary = Record<string, unknown>;\nexport type I18nDictionariesOutput = Partial<Record<Locales, Dictionary>>;\n\nconst {\n internationalization: { locales },\n} = getConfiguration();\n\nconst isReactNode = (node: Record<string, unknown>): boolean =>\n typeof node?.key !== 'undefined' &&\n typeof node?.props !== 'undefined' &&\n typeof node?.type !== 'undefined';\n\n// Build dictionary for a specific locale\nconst buildDictionary = (\n content: DictionaryValue,\n locale: Locales\n): unknown => {\n if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Translation\n ) {\n const result = (content as TranslationContent<unknown>)[\n NodeType.Translation\n ][locale];\n\n return buildDictionary(result as DictionaryValue, locale);\n } else if (\n // Translation node\n content &&\n (content as TypedNode).nodeType === NodeType.Enumeration\n ) {\n const plurals: Record<string, unknown> = {};\n\n Object.keys(\n (content as EnumerationContent<unknown>)[NodeType.Enumeration]\n ).forEach((quantity) => {\n const letterNumber = convertPluralsValues(quantity);\n\n const value = (content as EnumerationContent<unknown>)[\n quantity as keyof EnumerationContent<unknown>\n ];\n\n plurals[`${letterNumber}_${letterNumber}`] = buildDictionary(\n value as DictionaryValue,\n locale\n );\n });\n\n return plurals;\n } else if (\n // React element node\n isReactNode(content as Record<string, unknown>)\n ) {\n return JSON.stringify(content);\n } else if (\n // Nested object\n typeof content === 'object'\n ) {\n const result: Record<string, unknown> = {};\n\n Object.keys(content).forEach((dictionaryValue) => {\n result[dictionaryValue] = buildDictionary(\n content[dictionaryValue as keyof typeof content] as DictionaryValue,\n locale\n );\n });\n\n return result;\n }\n\n return content;\n};\n\nexport const createI18nDictionaries = (\n content: DictionaryValue\n): I18nDictionariesOutput => {\n // Map dictionaries for each locale\n const result: I18nDictionariesOutput = locales.reduce(\n (acc, locale) => ({\n ...acc,\n [locale]: buildDictionary(content, locale),\n }),\n {}\n );\n\n return result;\n};\n"],"mappings":"AAAA,SAAS,wBAAsC;AAC/C;AAAA,EACE;AAAA,OAKK;AACP,SAAS,4BAA4B;AAKrC,MAAM;AAAA,EACJ,sBAAsB,EAAE,QAAQ;AAClC,IAAI,iBAAiB;AAErB,MAAM,cAAc,CAAC,SACnB,OAAO,MAAM,QAAQ,eACrB,OAAO,MAAM,UAAU,eACvB,OAAO,MAAM,SAAS;AAGxB,MAAM,kBAAkB,CACtB,SACA,WACY;AACZ;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,SAAU,QACd,SAAS,WACX,EAAE,MAAM;AAER,WAAO,gBAAgB,QAA2B,MAAM;AAAA,EAC1D;AAAA;AAAA,IAEE,WACC,QAAsB,aAAa,SAAS;AAAA,IAC7C;AACA,UAAM,UAAmC,CAAC;AAE1C,WAAO;AAAA,MACJ,QAAwC,SAAS,WAAW;AAAA,IAC/D,EAAE,QAAQ,CAAC,aAAa;AACtB,YAAM,eAAe,qBAAqB,QAAQ;AAElD,YAAM,QAAS,QACb,QACF;AAEA,cAAQ,GAAG,YAAY,IAAI,YAAY,EAAE,IAAI;AAAA,QAC3C;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA;AAAA,IAEE,YAAY,OAAkC;AAAA,IAC9C;AACA,WAAO,KAAK,UAAU,OAAO;AAAA,EAC/B;AAAA;AAAA,IAEE,OAAO,YAAY;AAAA,IACnB;AACA,UAAM,SAAkC,CAAC;AAEzC,WAAO,KAAK,OAAO,EAAE,QAAQ,CAAC,oBAAoB;AAChD,aAAO,eAAe,IAAI;AAAA,QACxB,QAAQ,eAAuC;AAAA,QAC/C;AAAA,MACF;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,MAAM,yBAAyB,CACpC,YAC2B;AAE3B,QAAM,SAAiC,QAAQ;AAAA,IAC7C,CAAC,KAAK,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,CAAC,MAAM,GAAG,gBAAgB,SAAS,MAAM;AAAA,IAC3C;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
|
package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const convertPluralsValues = (number) => {
|
|
2
|
-
switch (number) {
|
|
3
|
-
case "1":
|
|
4
|
-
return "one";
|
|
5
|
-
case "2":
|
|
6
|
-
return "two";
|
|
7
|
-
case "3":
|
|
8
|
-
return "three";
|
|
9
|
-
case "4":
|
|
10
|
-
return "four";
|
|
11
|
-
case "5":
|
|
12
|
-
return "five";
|
|
13
|
-
case "6":
|
|
14
|
-
return "six";
|
|
15
|
-
case "7":
|
|
16
|
-
return "seven";
|
|
17
|
-
case "8":
|
|
18
|
-
return "eight";
|
|
19
|
-
default:
|
|
20
|
-
return number.toString();
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
convertPluralsValues
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=convertPluralsValues.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.ts"],"sourcesContent":["export const convertPluralsValues = (number: string): string => {\n switch (number) {\n case '1':\n return 'one';\n case '2':\n return 'two';\n case '3':\n return 'three';\n case '4':\n return 'four';\n case '5':\n return 'five';\n case '6':\n return 'six';\n case '7':\n return 'seven';\n case '8':\n return 'eight';\n default:\n return number.toString();\n }\n};\n"],"mappings":"AAAO,MAAM,uBAAuB,CAAC,WAA2B;AAC9D,UAAQ,QAAQ;AAAA,IACd,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO,OAAO,SAAS;AAAA,EAC3B;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/index.ts"],"sourcesContent":["export * from './buildI18nDictionary';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
package/dist/esm/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.ts"],"sourcesContent":["import { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { I18nDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';\n\nconst { content } = getConfiguration();\nconst { i18nDictionariesDir } = content;\n\nexport type DictionariesDeclaration = Record<string, I18nDictionariesOutput>;\n\n/**\n * This function writes the dictionaries to the file system\n */\nexport const writeDictionary = async (\n dictionariesDeclaration: DictionariesDeclaration\n) => {\n const resultDictionariesPaths: string[] = [];\n\n for (const [nameSpace, localContent] of Object.entries(\n dictionariesDeclaration\n )) {\n for await (const [locale, content] of Object.entries(localContent)) {\n const contentString = JSON.stringify(content);\n\n const outputFileName = `${nameSpace}.json`;\n const resultDirPath = resolve(i18nDictionariesDir, locale);\n const resultFilePath = resolve(resultDirPath, outputFileName);\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resultDirPath, { recursive: true });\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,OAAO,iBAAiB;AACjC,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAGjC,MAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,MAAM,EAAE,oBAAoB,IAAI;AAOzB,MAAM,kBAAkB,OAC7B,4BACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,aAAW,CAAC,WAAW,YAAY,KAAK,OAAO;AAAA,IAC7C;AAAA,EACF,GAAG;AACD,qBAAiB,CAAC,QAAQA,QAAO,KAAK,OAAO,QAAQ,YAAY,GAAG;AAClE,YAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,YAAM,iBAAiB,GAAG,SAAS;AACnC,YAAM,gBAAgB,QAAQ,qBAAqB,MAAM;AACzD,YAAM,iBAAiB,QAAQ,eAAe,cAAc;AAG5D,YAAM,MAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAG9C,YAAM,UAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,gBAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,MACxD,CAAC;AAED,8BAAwB,KAAK,cAAc;AAAA,IAC7C;AAAA,EACF;AAEA,SAAO;AACT;","names":["content"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildI18nDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/buildI18nDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAOjD;;GAEG;AACH,eAAO,MAAM,mBAAmB,wBACT,UAAU,EAAE,sBAoBlC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convertContentDeclarationInto18nDictionaries.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertContentDeclarationInto18nDictionaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAKL,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAGxB,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1C,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAyE1E,eAAO,MAAM,sBAAsB,YACxB,eAAe,KACvB,sBAWF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convertPluralsValues.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/convertPluralsValues.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,WAAY,MAAM,KAAG,MAqBrD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
package/dist/types/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { I18nDictionariesOutput } from './convertContentDeclarationInto18nDictionaries';
|
|
2
|
-
export type DictionariesDeclaration = Record<string, I18nDictionariesOutput>;
|
|
3
|
-
/**
|
|
4
|
-
* This function writes the dictionaries to the file system
|
|
5
|
-
*/
|
|
6
|
-
export declare const writeDictionary: (dictionariesDeclaration: DictionariesDeclaration) => Promise<string[]>;
|
|
7
|
-
//# sourceMappingURL=writeDictionary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeDictionary.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18n_dictionary/writeDictionary.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAKxF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,eAAe,4BACD,uBAAuB,sBA2BjD,CAAC"}
|