@intlayer/cli 8.1.2 → 8.1.3
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/IntlayerEventListener.cjs +1 -186
- package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/_virtual/_utils_asset.cjs +2 -98
- package/dist/cjs/auth/login.cjs +2 -85
- package/dist/cjs/auth/login.cjs.map +1 -1
- package/dist/cjs/build.cjs +1 -27
- package/dist/cjs/build.cjs.map +1 -1
- package/dist/cjs/ci.cjs +1 -73
- package/dist/cjs/ci.cjs.map +1 -1
- package/dist/cjs/cli.cjs +1 -476
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +1 -12
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/editor.cjs +1 -50
- package/dist/cjs/editor.cjs.map +1 -1
- package/dist/cjs/extract.cjs +1 -96
- package/dist/cjs/extract.cjs.map +1 -1
- package/dist/cjs/fill/deepMergeContent.cjs +1 -27
- package/dist/cjs/fill/deepMergeContent.cjs.map +1 -1
- package/dist/cjs/fill/fill.cjs +1 -78
- package/dist/cjs/fill/fill.cjs.map +1 -1
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -29
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
- package/dist/cjs/fill/formatFillData.cjs +1 -50
- package/dist/cjs/fill/formatFillData.cjs.map +1 -1
- package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs +1 -26
- package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs.map +1 -1
- package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs +1 -50
- package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs.map +1 -1
- package/dist/cjs/fill/index.cjs +1 -6
- package/dist/cjs/fill/listTranslationsTasks.cjs +1 -70
- package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
- package/dist/cjs/fill/mergeChunks.cjs +1 -28
- package/dist/cjs/fill/mergeChunks.cjs.map +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +1 -205
- package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
- package/dist/cjs/fill/writeFill.cjs +1 -54
- package/dist/cjs/fill/writeFill.cjs.map +1 -1
- package/dist/cjs/getTargetDictionary.cjs +1 -36
- package/dist/cjs/getTargetDictionary.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -39
- package/dist/cjs/init.cjs +1 -322
- package/dist/cjs/init.cjs.map +1 -1
- package/dist/cjs/initSkills.cjs +2 -0
- package/dist/cjs/initSkills.cjs.map +1 -0
- package/dist/cjs/listContentDeclaration.cjs +1 -41
- package/dist/cjs/listContentDeclaration.cjs.map +1 -1
- package/dist/cjs/listProjects.cjs +1 -28
- package/dist/cjs/listProjects.cjs.map +1 -1
- package/dist/cjs/liveSync.cjs +8 -151
- package/dist/cjs/liveSync.cjs.map +1 -1
- package/dist/cjs/pull.cjs +1 -146
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs +3 -102
- package/dist/cjs/push/pullLog.cjs.map +1 -1
- package/dist/cjs/push/push.cjs +1 -206
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +1 -19
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/pushLog.cjs +3 -84
- package/dist/cjs/pushLog.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs +1 -68
- package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +1 -94
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
- package/dist/cjs/searchDoc.cjs +1 -38
- package/dist/cjs/searchDoc.cjs.map +1 -1
- package/dist/cjs/test/index.cjs +1 -7
- package/dist/cjs/test/listMissingTranslations.cjs +1 -49
- package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
- package/dist/cjs/test/test.cjs +1 -53
- package/dist/cjs/test/test.cjs.map +1 -1
- package/dist/cjs/translateDoc/index.cjs +1 -9
- package/dist/cjs/translateDoc/translateDoc.cjs +1 -74
- package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
- package/dist/cjs/translateDoc/translateFile.cjs +2 -103
- package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
- package/dist/cjs/translateDoc/validation.cjs +5 -49
- package/dist/cjs/translateDoc/validation.cjs.map +1 -1
- package/dist/cjs/translation-alignment/alignBlocks.cjs +1 -67
- package/dist/cjs/translation-alignment/alignBlocks.cjs.map +1 -1
- package/dist/cjs/translation-alignment/computeSimilarity.cjs +1 -25
- package/dist/cjs/translation-alignment/computeSimilarity.cjs.map +1 -1
- package/dist/cjs/translation-alignment/fingerprintBlock.cjs +1 -23
- package/dist/cjs/translation-alignment/fingerprintBlock.cjs.map +1 -1
- package/dist/cjs/translation-alignment/index.cjs +1 -22
- package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs +1 -18
- package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs.map +1 -1
- package/dist/cjs/translation-alignment/normalizeBlock.cjs +1 -22
- package/dist/cjs/translation-alignment/normalizeBlock.cjs.map +1 -1
- package/dist/cjs/translation-alignment/pipeline.cjs +1 -37
- package/dist/cjs/translation-alignment/pipeline.cjs.map +1 -1
- package/dist/cjs/translation-alignment/planActions.cjs +1 -46
- package/dist/cjs/translation-alignment/planActions.cjs.map +1 -1
- package/dist/cjs/translation-alignment/rebuildDocument.cjs +2 -49
- package/dist/cjs/translation-alignment/rebuildDocument.cjs.map +1 -1
- package/dist/cjs/translation-alignment/segmentDocument.cjs +5 -66
- package/dist/cjs/translation-alignment/segmentDocument.cjs.map +1 -1
- package/dist/cjs/utils/calculateChunks.cjs +2 -89
- package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
- package/dist/cjs/utils/checkAccess.cjs +1 -81
- package/dist/cjs/utils/checkAccess.cjs.map +1 -1
- package/dist/cjs/utils/checkConfigConsistency.cjs +1 -16
- package/dist/cjs/utils/checkConfigConsistency.cjs.map +1 -1
- package/dist/cjs/utils/checkFileModifiedRange.cjs +1 -81
- package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
- package/dist/cjs/utils/checkLastUpdateTime.cjs +1 -19
- package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
- package/dist/cjs/utils/chunkInference.cjs +1 -45
- package/dist/cjs/utils/chunkInference.cjs.map +1 -1
- package/dist/cjs/utils/fixChunkStartEndChars.cjs +3 -27
- package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
- package/dist/cjs/utils/formatTimeDiff.cjs +1 -20
- package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +1 -16
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
- package/dist/cjs/utils/getOutputFilePath.cjs +1 -74
- package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs +1 -20
- package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
- package/dist/cjs/utils/listSpecialChars.cjs +2 -54
- package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +1 -102
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
- package/dist/cjs/utils/openBrowser.cjs +1 -19
- package/dist/cjs/utils/openBrowser.cjs.map +1 -1
- package/dist/cjs/utils/reorderParagraphs.cjs +3 -91
- package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
- package/dist/cjs/utils/setupAI.cjs +1 -64
- package/dist/cjs/utils/setupAI.cjs.map +1 -1
- package/dist/cjs/watch.cjs +1 -43
- package/dist/cjs/watch.cjs.map +1 -1
- package/dist/esm/IntlayerEventListener.mjs +1 -183
- package/dist/esm/IntlayerEventListener.mjs.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -8
- package/dist/esm/_virtual/_utils_asset.mjs +2 -97
- package/dist/esm/auth/login.mjs +2 -82
- package/dist/esm/auth/login.mjs.map +1 -1
- package/dist/esm/build.mjs +1 -25
- package/dist/esm/build.mjs.map +1 -1
- package/dist/esm/ci.mjs +1 -71
- package/dist/esm/ci.mjs.map +1 -1
- package/dist/esm/cli.mjs +1 -473
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +1 -10
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/editor.mjs +1 -49
- package/dist/esm/editor.mjs.map +1 -1
- package/dist/esm/extract.mjs +1 -93
- package/dist/esm/extract.mjs.map +1 -1
- package/dist/esm/fill/deepMergeContent.mjs +1 -25
- package/dist/esm/fill/deepMergeContent.mjs.map +1 -1
- package/dist/esm/fill/fill.mjs +1 -76
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -27
- package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
- package/dist/esm/fill/formatFillData.mjs +1 -49
- package/dist/esm/fill/formatFillData.mjs.map +1 -1
- package/dist/esm/fill/getAvailableLocalesInDictionary.mjs +1 -24
- package/dist/esm/fill/getAvailableLocalesInDictionary.mjs.map +1 -1
- package/dist/esm/fill/getFilterMissingContentPerLocale.mjs +1 -48
- package/dist/esm/fill/getFilterMissingContentPerLocale.mjs.map +1 -1
- package/dist/esm/fill/index.mjs +1 -4
- package/dist/esm/fill/listTranslationsTasks.mjs +1 -68
- package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
- package/dist/esm/fill/mergeChunks.mjs +1 -26
- package/dist/esm/fill/mergeChunks.mjs.map +1 -1
- package/dist/esm/fill/translateDictionary.mjs +1 -203
- package/dist/esm/fill/translateDictionary.mjs.map +1 -1
- package/dist/esm/fill/writeFill.mjs +1 -52
- package/dist/esm/fill/writeFill.mjs.map +1 -1
- package/dist/esm/getTargetDictionary.mjs +1 -33
- package/dist/esm/getTargetDictionary.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -18
- package/dist/esm/init.mjs +1 -317
- package/dist/esm/init.mjs.map +1 -1
- package/dist/esm/initSkills.mjs +2 -0
- package/dist/esm/initSkills.mjs.map +1 -0
- package/dist/esm/listContentDeclaration.mjs +1 -38
- package/dist/esm/listContentDeclaration.mjs.map +1 -1
- package/dist/esm/listProjects.mjs +1 -26
- package/dist/esm/listProjects.mjs.map +1 -1
- package/dist/esm/liveSync.mjs +8 -148
- package/dist/esm/liveSync.mjs.map +1 -1
- package/dist/esm/pull.mjs +1 -144
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push/pullLog.mjs +3 -100
- package/dist/esm/push/pullLog.mjs.map +1 -1
- package/dist/esm/push/push.mjs +1 -203
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +1 -17
- package/dist/esm/pushConfig.mjs.map +1 -1
- package/dist/esm/pushLog.mjs +3 -82
- package/dist/esm/pushLog.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs +1 -65
- package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +1 -92
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
- package/dist/esm/searchDoc.mjs +1 -36
- package/dist/esm/searchDoc.mjs.map +1 -1
- package/dist/esm/test/index.mjs +1 -4
- package/dist/esm/test/listMissingTranslations.mjs +1 -46
- package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
- package/dist/esm/test/test.mjs +1 -51
- package/dist/esm/test/test.mjs.map +1 -1
- package/dist/esm/translateDoc/index.mjs +1 -5
- package/dist/esm/translateDoc/translateDoc.mjs +1 -71
- package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
- package/dist/esm/translateDoc/translateFile.mjs +2 -101
- package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
- package/dist/esm/translateDoc/validation.mjs +5 -46
- package/dist/esm/translateDoc/validation.mjs.map +1 -1
- package/dist/esm/translation-alignment/alignBlocks.mjs +1 -66
- package/dist/esm/translation-alignment/alignBlocks.mjs.map +1 -1
- package/dist/esm/translation-alignment/computeSimilarity.mjs +1 -22
- package/dist/esm/translation-alignment/computeSimilarity.mjs.map +1 -1
- package/dist/esm/translation-alignment/fingerprintBlock.mjs +1 -20
- package/dist/esm/translation-alignment/fingerprintBlock.mjs.map +1 -1
- package/dist/esm/translation-alignment/index.mjs +1 -11
- package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs +1 -16
- package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs.map +1 -1
- package/dist/esm/translation-alignment/normalizeBlock.mjs +1 -20
- package/dist/esm/translation-alignment/normalizeBlock.mjs.map +1 -1
- package/dist/esm/translation-alignment/pipeline.mjs +1 -35
- package/dist/esm/translation-alignment/pipeline.mjs.map +1 -1
- package/dist/esm/translation-alignment/planActions.mjs +1 -44
- package/dist/esm/translation-alignment/planActions.mjs.map +1 -1
- package/dist/esm/translation-alignment/rebuildDocument.mjs +2 -46
- package/dist/esm/translation-alignment/rebuildDocument.mjs.map +1 -1
- package/dist/esm/translation-alignment/segmentDocument.mjs +5 -64
- package/dist/esm/translation-alignment/segmentDocument.mjs.map +1 -1
- package/dist/esm/utils/calculateChunks.mjs +2 -87
- package/dist/esm/utils/calculateChunks.mjs.map +1 -1
- package/dist/esm/utils/checkAccess.mjs +1 -78
- package/dist/esm/utils/checkAccess.mjs.map +1 -1
- package/dist/esm/utils/checkConfigConsistency.mjs +1 -14
- package/dist/esm/utils/checkConfigConsistency.mjs.map +1 -1
- package/dist/esm/utils/checkFileModifiedRange.mjs +1 -80
- package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
- package/dist/esm/utils/checkLastUpdateTime.mjs +1 -17
- package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
- package/dist/esm/utils/chunkInference.mjs +1 -43
- package/dist/esm/utils/chunkInference.mjs.map +1 -1
- package/dist/esm/utils/fixChunkStartEndChars.mjs +3 -25
- package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
- package/dist/esm/utils/formatTimeDiff.mjs +1 -18
- package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs +1 -14
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
- package/dist/esm/utils/getOutputFilePath.mjs +1 -72
- package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
- package/dist/esm/utils/getParentPackageJSON.mjs +1 -18
- package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
- package/dist/esm/utils/listSpecialChars.mjs +2 -52
- package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
- package/dist/esm/utils/mapChunksBetweenFiles.mjs +1 -100
- package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
- package/dist/esm/utils/openBrowser.mjs +1 -17
- package/dist/esm/utils/openBrowser.mjs.map +1 -1
- package/dist/esm/utils/reorderParagraphs.mjs +3 -90
- package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
- package/dist/esm/utils/setupAI.mjs +1 -62
- package/dist/esm/utils/setupAI.mjs.map +1 -1
- package/dist/esm/watch.mjs +1 -41
- package/dist/esm/watch.mjs.map +1 -1
- package/dist/types/auth/login.d.ts +1 -1
- package/dist/types/auth/login.d.ts.map +1 -1
- package/dist/types/build.d.ts +1 -1
- package/dist/types/build.d.ts.map +1 -1
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/extract.d.ts +1 -1
- package/dist/types/extract.d.ts.map +1 -1
- package/dist/types/fill/fill.d.ts +1 -1
- package/dist/types/fill/fill.d.ts.map +1 -1
- package/dist/types/fill/translateDictionary.d.ts +2 -2
- package/dist/types/fill/translateDictionary.d.ts.map +1 -1
- package/dist/types/fill/writeFill.d.ts.map +1 -1
- package/dist/types/getTargetDictionary.d.ts +2 -2
- package/dist/types/index.d.ts +7 -3
- package/dist/types/init.d.ts +2 -5
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/initSkills.d.ts +8 -0
- package/dist/types/initSkills.d.ts.map +1 -0
- package/dist/types/listContentDeclaration.d.ts +1 -1
- package/dist/types/listContentDeclaration.d.ts.map +1 -1
- package/dist/types/liveSync.d.ts +1 -1
- package/dist/types/pull.d.ts +1 -1
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/push/pullLog.d.ts +1 -1
- package/dist/types/push/pullLog.d.ts.map +1 -1
- package/dist/types/push/push.d.ts +2 -2
- package/dist/types/pushConfig.d.ts +1 -1
- package/dist/types/reviewDoc/reviewDoc.d.ts +2 -2
- package/dist/types/reviewDoc/reviewDoc.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +1 -1
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts.map +1 -1
- package/dist/types/searchDoc.d.ts +1 -1
- package/dist/types/searchDoc.d.ts.map +1 -1
- package/dist/types/test/listMissingTranslations.d.ts +1 -1
- package/dist/types/test/test.d.ts +1 -1
- package/dist/types/test/test.d.ts.map +1 -1
- package/dist/types/translateDoc/translateDoc.d.ts.map +1 -1
- package/dist/types/translateDoc/types.d.ts +2 -2
- package/dist/types/translateDoc/validation.d.ts +1 -1
- package/dist/types/utils/checkAccess.d.ts.map +1 -1
- package/dist/types/watch.d.ts +1 -1
- package/dist/types/watch.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -1,204 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getFilterMissingContentPerLocale } from "./getFilterMissingContentPerLocale.mjs";
|
|
3
|
-
import { mergeChunks } from "./mergeChunks.mjs";
|
|
4
|
-
import { getIntlayerAPIProxy } from "@intlayer/api";
|
|
5
|
-
import { chunkJSON, formatLocale, reconstructFromSingleChunk, reduceObjectFormat, verifyIdenticObjectFormat } from "@intlayer/chokidar";
|
|
6
|
-
import { ANSIColors, colon, colorize, colorizeNumber, colorizePath, getAppLogger, retryManager } from "@intlayer/config";
|
|
7
|
-
import { basename } from "node:path";
|
|
8
|
-
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
9
|
-
import { getFilterMissingTranslationsDictionary, getMultilingualDictionary, getPerLocaleDictionary, insertContentInDictionary } from "@intlayer/core";
|
|
10
|
-
|
|
11
|
-
//#region src/fill/translateDictionary.ts
|
|
12
|
-
const hasMissingMetadata = (dictionary) => !dictionary.description || !dictionary.title || !dictionary.tags;
|
|
13
|
-
const CHUNK_SIZE = 7e3;
|
|
14
|
-
const GROUP_MAX_RETRY = 2;
|
|
15
|
-
const MAX_RETRY = 3;
|
|
16
|
-
const RETRY_DELAY = 1e3 * 10;
|
|
17
|
-
const MAX_FOLLOWING_ERRORS = 10;
|
|
18
|
-
let followingErrors = 0;
|
|
19
|
-
const translateDictionary = async (task, configuration, options) => {
|
|
20
|
-
const appLogger = getAppLogger(configuration);
|
|
21
|
-
const intlayerAPI = getIntlayerAPIProxy(void 0, configuration);
|
|
22
|
-
const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {
|
|
23
|
-
mode: "complete",
|
|
24
|
-
fillMetadata: true,
|
|
25
|
-
...options
|
|
26
|
-
};
|
|
27
|
-
const notifySuccess = () => {
|
|
28
|
-
followingErrors = 0;
|
|
29
|
-
options?.onSuccess?.();
|
|
30
|
-
};
|
|
31
|
-
return await retryManager(async () => {
|
|
32
|
-
const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);
|
|
33
|
-
const baseUnmergedDictionary = unmergedDictionariesRecord[task.dictionaryKey].find((dict) => dict.localId === task.dictionaryLocalId);
|
|
34
|
-
if (!baseUnmergedDictionary) {
|
|
35
|
-
appLogger(`${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`, { level: "warn" });
|
|
36
|
-
return {
|
|
37
|
-
...task,
|
|
38
|
-
dictionaryOutput: null
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
let metadata;
|
|
42
|
-
if (fillMetadata && (hasMissingMetadata(baseUnmergedDictionary) || mode === "review")) {
|
|
43
|
-
const defaultLocaleDictionary = getPerLocaleDictionary(baseUnmergedDictionary, configuration.internationalization.defaultLocale);
|
|
44
|
-
appLogger(`${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath))}`, { level: "info" });
|
|
45
|
-
const runAudit = async () => {
|
|
46
|
-
if (aiClient && aiConfig) return { data: await aiClient.auditDictionaryMetadata({
|
|
47
|
-
fileContent: JSON.stringify(defaultLocaleDictionary),
|
|
48
|
-
aiConfig
|
|
49
|
-
}) };
|
|
50
|
-
return await intlayerAPI.ai.auditContentDeclarationMetadata({
|
|
51
|
-
fileContent: JSON.stringify(defaultLocaleDictionary),
|
|
52
|
-
aiOptions
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
metadata = (options?.onHandle ? await options.onHandle(runAudit) : await runAudit()).data?.fileContent;
|
|
56
|
-
}
|
|
57
|
-
const translatedContentResults = await Promise.all(task.targetLocales.map(async (targetLocale) => {
|
|
58
|
-
/**
|
|
59
|
-
* In complete mode, for large dictionaries, we want to filter all content that is already translated
|
|
60
|
-
*
|
|
61
|
-
* targetLocale: fr
|
|
62
|
-
*
|
|
63
|
-
* { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}
|
|
64
|
-
* { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
let dictionaryToProcess = structuredClone(baseUnmergedDictionary);
|
|
68
|
-
let targetLocaleDictionary;
|
|
69
|
-
if (typeof baseUnmergedDictionary.locale === "string") {
|
|
70
|
-
const targetLocaleFilePath = baseUnmergedDictionary.filePath?.replace(new RegExp(`/${task.sourceLocale}/`, "g"), `/${targetLocale}/`);
|
|
71
|
-
const targetUnmergedDictionary = targetLocaleFilePath ? unmergedDictionariesRecord[task.dictionaryKey]?.find((dict) => dict.filePath === targetLocaleFilePath && dict.locale === targetLocale) : void 0;
|
|
72
|
-
targetLocaleDictionary = targetUnmergedDictionary ?? {
|
|
73
|
-
key: baseUnmergedDictionary.key,
|
|
74
|
-
content: {},
|
|
75
|
-
filePath: targetLocaleFilePath,
|
|
76
|
-
locale: targetLocale
|
|
77
|
-
};
|
|
78
|
-
if (mode === "complete") dictionaryToProcess = getFilterMissingContentPerLocale(dictionaryToProcess, targetUnmergedDictionary);
|
|
79
|
-
} else {
|
|
80
|
-
if (mode === "complete") dictionaryToProcess = getFilterMissingTranslationsDictionary(dictionaryToProcess, targetLocale);
|
|
81
|
-
dictionaryToProcess = getPerLocaleDictionary(dictionaryToProcess, task.sourceLocale);
|
|
82
|
-
targetLocaleDictionary = getPerLocaleDictionary(baseUnmergedDictionary, targetLocale);
|
|
83
|
-
}
|
|
84
|
-
const localePreset = colon([
|
|
85
|
-
colorize("[", ANSIColors.GREY_DARK),
|
|
86
|
-
formatLocale(targetLocale),
|
|
87
|
-
colorize("]", ANSIColors.GREY_DARK)
|
|
88
|
-
].join(""), { colSize: 18 });
|
|
89
|
-
const createChunkPreset = (chunkIndex, totalChunks) => {
|
|
90
|
-
if (totalChunks <= 1) return "";
|
|
91
|
-
return colon([
|
|
92
|
-
colorize("[", ANSIColors.GREY_DARK),
|
|
93
|
-
colorizeNumber(chunkIndex + 1),
|
|
94
|
-
colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),
|
|
95
|
-
colorize("]", ANSIColors.GREY_DARK)
|
|
96
|
-
].join(""), { colSize: 5 });
|
|
97
|
-
};
|
|
98
|
-
appLogger(`${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath))}`, { level: "info" });
|
|
99
|
-
const isContentStructured = typeof dictionaryToProcess.content === "object" && dictionaryToProcess.content !== null || Array.isArray(dictionaryToProcess.content);
|
|
100
|
-
const chunkedJsonContent = chunkJSON(isContentStructured ? dictionaryToProcess.content : { __INTLAYER_ROOT_PRIMITIVE_CONTENT__: dictionaryToProcess.content }, CHUNK_SIZE);
|
|
101
|
-
const nbOfChunks = chunkedJsonContent.length;
|
|
102
|
-
if (nbOfChunks > 1) appLogger(`${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`, { level: "info" });
|
|
103
|
-
const chunkResult = [];
|
|
104
|
-
const chunkPromises = chunkedJsonContent.map((chunk) => {
|
|
105
|
-
const chunkPreset = createChunkPreset(chunk.index, chunk.total);
|
|
106
|
-
if (nbOfChunks > 1) appLogger(`${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`, { level: "info" });
|
|
107
|
-
const chunkContent = reconstructFromSingleChunk(chunk);
|
|
108
|
-
const presetOutputContent = reduceObjectFormat(isContentStructured ? targetLocaleDictionary.content : { __INTLAYER_ROOT_PRIMITIVE_CONTENT__: targetLocaleDictionary.content }, chunkContent);
|
|
109
|
-
const executeTranslation = async () => {
|
|
110
|
-
return await retryManager(async () => {
|
|
111
|
-
let translationResult;
|
|
112
|
-
if (aiClient && aiConfig) translationResult = await aiClient.translateJSON({
|
|
113
|
-
entryFileContent: chunkContent,
|
|
114
|
-
presetOutputContent,
|
|
115
|
-
dictionaryDescription: dictionaryToProcess.description ?? metadata?.description ?? "",
|
|
116
|
-
entryLocale: task.sourceLocale,
|
|
117
|
-
outputLocale: targetLocale,
|
|
118
|
-
mode,
|
|
119
|
-
aiConfig
|
|
120
|
-
});
|
|
121
|
-
else translationResult = await intlayerAPI.ai.translateJSON({
|
|
122
|
-
entryFileContent: chunkContent,
|
|
123
|
-
presetOutputContent,
|
|
124
|
-
dictionaryDescription: dictionaryToProcess.description ?? metadata?.description ?? "",
|
|
125
|
-
entryLocale: task.sourceLocale,
|
|
126
|
-
outputLocale: targetLocale,
|
|
127
|
-
mode,
|
|
128
|
-
aiOptions
|
|
129
|
-
}).then((result) => result.data);
|
|
130
|
-
if (!translationResult?.fileContent) throw new Error("No content result");
|
|
131
|
-
const { isIdentic } = verifyIdenticObjectFormat(translationResult.fileContent, chunkContent);
|
|
132
|
-
if (!isIdentic) throw new Error("Translation result does not match expected format");
|
|
133
|
-
notifySuccess();
|
|
134
|
-
return translationResult.fileContent;
|
|
135
|
-
}, {
|
|
136
|
-
maxRetry: MAX_RETRY,
|
|
137
|
-
delay: RETRY_DELAY,
|
|
138
|
-
onError: ({ error, attempt, maxRetry }) => {
|
|
139
|
-
const chunkPreset = createChunkPreset(chunk.index, chunk.total);
|
|
140
|
-
appLogger(`${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize("Error filling:", ANSIColors.RED)} ${colorize(typeof error === "string" ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`, { level: "error" });
|
|
141
|
-
followingErrors += 1;
|
|
142
|
-
if (followingErrors >= MAX_FOLLOWING_ERRORS) {
|
|
143
|
-
appLogger(`There is something wrong.`, { level: "error" });
|
|
144
|
-
process.exit(1);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
})();
|
|
148
|
-
};
|
|
149
|
-
return (options?.onHandle ? options.onHandle(executeTranslation) : executeTranslation()).then((result) => ({
|
|
150
|
-
chunk,
|
|
151
|
-
result
|
|
152
|
-
}));
|
|
153
|
-
});
|
|
154
|
-
(await Promise.all(chunkPromises)).sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index).forEach(({ result }) => {
|
|
155
|
-
chunkResult.push(result);
|
|
156
|
-
});
|
|
157
|
-
const mergedContent = mergeChunks(chunkResult);
|
|
158
|
-
let finalContent = {
|
|
159
|
-
...dictionaryToProcess,
|
|
160
|
-
content: mergedContent
|
|
161
|
-
}.content;
|
|
162
|
-
if (!isContentStructured) finalContent = finalContent?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__;
|
|
163
|
-
if (typeof baseUnmergedDictionary.locale === "string") finalContent = deepMergeContent(targetLocaleDictionary.content ?? {}, finalContent);
|
|
164
|
-
return [targetLocale, finalContent];
|
|
165
|
-
}));
|
|
166
|
-
const translatedContent = Object.fromEntries(translatedContentResults);
|
|
167
|
-
let dictionaryOutput = {
|
|
168
|
-
...getMultilingualDictionary(baseUnmergedDictionary.locale ? {
|
|
169
|
-
...baseUnmergedDictionary,
|
|
170
|
-
key: baseUnmergedDictionary.key,
|
|
171
|
-
content: {}
|
|
172
|
-
} : baseUnmergedDictionary),
|
|
173
|
-
locale: void 0,
|
|
174
|
-
...metadata
|
|
175
|
-
};
|
|
176
|
-
for (const targetLocale of task.targetLocales) if (translatedContent[targetLocale]) dictionaryOutput = insertContentInDictionary(dictionaryOutput, translatedContent[targetLocale], targetLocale);
|
|
177
|
-
appLogger(`${task.dictionaryPreset} ${colorize("Translation completed successfully", ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath))}`, { level: "info" });
|
|
178
|
-
if (baseUnmergedDictionary.locale && (baseUnmergedDictionary.fill === true || baseUnmergedDictionary.fill === void 0) && baseUnmergedDictionary.location === "local") {
|
|
179
|
-
const dictionaryFilePath = baseUnmergedDictionary.filePath.split(".").slice(0, -1);
|
|
180
|
-
const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];
|
|
181
|
-
return JSON.parse(JSON.stringify({
|
|
182
|
-
...task,
|
|
183
|
-
dictionaryOutput: {
|
|
184
|
-
...dictionaryOutput,
|
|
185
|
-
fill: void 0,
|
|
186
|
-
filled: true
|
|
187
|
-
}
|
|
188
|
-
}).replaceAll(new RegExp(`\\.${contentIndex}\\.[a-zA-Z0-9]+`, "g"), `.filled.${contentIndex}.json`));
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
...task,
|
|
192
|
-
dictionaryOutput
|
|
193
|
-
};
|
|
194
|
-
}, {
|
|
195
|
-
maxRetry: GROUP_MAX_RETRY,
|
|
196
|
-
delay: RETRY_DELAY,
|
|
197
|
-
onError: ({ error, attempt, maxRetry }) => appLogger(`${task.dictionaryPreset} ${colorize("Error:", ANSIColors.RED)} ${colorize(typeof error === "string" ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`, { level: "error" }),
|
|
198
|
-
onMaxTryReached: ({ error }) => appLogger(`${task.dictionaryPreset} ${colorize("Maximum number of retries reached:", ANSIColors.RED)} ${colorize(typeof error === "string" ? error : JSON.stringify(error), ANSIColors.GREY_DARK)}`, { level: "error" })
|
|
199
|
-
})();
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
//#endregion
|
|
203
|
-
export { translateDictionary };
|
|
1
|
+
import{deepMergeContent as e}from"./deepMergeContent.mjs";import{getFilterMissingContentPerLocale as t}from"./getFilterMissingContentPerLocale.mjs";import{mergeChunks as n}from"./mergeChunks.mjs";import{getIntlayerAPIProxy as r}from"@intlayer/api";import{chunkJSON as i,formatLocale as a,reconstructFromSingleChunk as o,reduceObjectFormat as s,verifyIdenticObjectFormat as c}from"@intlayer/chokidar/utils";import{basename as l}from"node:path";import{ANSIColors as u,colon as d,colorize as f,colorizeNumber as p,colorizePath as m,getAppLogger as h}from"@intlayer/config/logger";import{retryManager as g}from"@intlayer/config/utils";import{getUnmergedDictionaries as _}from"@intlayer/unmerged-dictionaries-entry";import{getFilterMissingTranslationsDictionary as v,getMultilingualDictionary as y,getPerLocaleDictionary as b,insertContentInDictionary as x}from"@intlayer/core/plugins";const S=e=>!e.description||!e.title||!e.tags,C=1e3*10;let w=0;const T=async(T,E,D)=>{let O=h(E),k=r(void 0,E),{mode:A,aiOptions:j,fillMetadata:M,aiClient:N,aiConfig:P}={mode:`complete`,fillMetadata:!0,...D},F=()=>{w=0,D?.onSuccess?.()};return await g(async()=>{let r=_(E),h=r[T.dictionaryKey].find(e=>e.localId===T.dictionaryLocalId);if(!h)return O(`${T.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,{level:`warn`}),{...T,dictionaryOutput:null};let I;if(M&&(S(h)||A===`review`)){let e=b(h,E.internationalization.defaultLocale);O(`${T.dictionaryPreset} Filling missing metadata for ${m(l(h.filePath))}`,{level:`info`});let t=async()=>N&&P?{data:await N.auditDictionaryMetadata({fileContent:JSON.stringify(e),aiConfig:P})}:await k.ai.auditContentDeclarationMetadata({fileContent:JSON.stringify(e),aiOptions:j});I=(D?.onHandle?await D.onHandle(t):await t()).data?.fileContent}let L=await Promise.all(T.targetLocales.map(async _=>{let y=structuredClone(h),x;if(typeof h.locale==`string`){let e=h.filePath?.replace(RegExp(`/${T.sourceLocale}/`,`g`),`/${_}/`),n=e?r[T.dictionaryKey]?.find(t=>t.filePath===e&&t.locale===_):void 0;x=n??{key:h.key,content:{},filePath:e,locale:_},A===`complete`&&(y=t(y,n))}else A===`complete`&&(y=v(y,_)),y=b(y,T.sourceLocale),x=b(h,_);let S=d([f(`[`,u.GREY_DARK),a(_),f(`]`,u.GREY_DARK)].join(``),{colSize:18}),E=(e,t)=>t<=1?``:d([f(`[`,u.GREY_DARK),p(e+1),f(`/${t}`,u.GREY_DARK),f(`]`,u.GREY_DARK)].join(``),{colSize:5});O(`${T.dictionaryPreset}${S} Preparing ${m(l(x.filePath))}`,{level:`info`});let M=typeof y.content==`object`&&y.content!==null||Array.isArray(y.content),L=i(M?y.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:y.content},7e3),R=L.length;R>1&&O(`${T.dictionaryPreset}${S} Split into ${p(R)} chunks for translation`,{level:`info`});let z=[],B=L.map(e=>{let t=E(e.index,e.total);R>1&&O(`${T.dictionaryPreset}${S}${t} Translating chunk`,{level:`info`});let n=o(e),r=s(M?x.content:{__INTLAYER_ROOT_PRIMITIVE_CONTENT__:x.content},n),i=async()=>await g(async()=>{let e;if(e=N&&P?await N.translateJSON({entryFileContent:n,presetOutputContent:r,dictionaryDescription:y.description??I?.description??``,entryLocale:T.sourceLocale,outputLocale:_,mode:A,aiConfig:P}):await k.ai.translateJSON({entryFileContent:n,presetOutputContent:r,dictionaryDescription:y.description??I?.description??``,entryLocale:T.sourceLocale,outputLocale:_,mode:A,aiOptions:j}).then(e=>e.data),!e?.fileContent)throw Error(`No content result`);let{isIdentic:t}=c(e.fileContent,n);if(!t)throw Error(`Translation result does not match expected format`);return F(),e.fileContent},{maxRetry:3,delay:C,onError:({error:t,attempt:n,maxRetry:r})=>{let i=E(e.index,e.total);O(`${T.dictionaryPreset}${S}${i} ${f(`Error filling:`,u.RED)} ${f(typeof t==`string`?t:JSON.stringify(t),u.GREY_DARK)} - Attempt ${p(n+1)} of ${p(r)}`,{level:`error`}),w+=1,w>=10&&(O(`There is something wrong.`,{level:`error`}),process.exit(1))}})();return(D?.onHandle?D.onHandle(i):i()).then(t=>({chunk:e,result:t}))});(await Promise.all(B)).sort((e,t)=>e.chunk.index-t.chunk.index).forEach(({result:e})=>{z.push(e)});let V=n(z),H={...y,content:V}.content;return M||(H=H?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__),typeof h.locale==`string`&&(H=e(x.content??{},H)),[_,H]})),R=Object.fromEntries(L),z={...y(h.locale?{...h,key:h.key,content:{}}:h),locale:void 0,...I};for(let e of T.targetLocales)R[e]&&(z=x(z,R[e],e));if(O(`${T.dictionaryPreset} ${f(`Translation completed successfully`,u.GREEN)} for ${m(l(z.filePath))}`,{level:`info`}),h.locale&&(h.fill===!0||h.fill===void 0)&&h.location===`local`){let e=h.filePath.split(`.`).slice(0,-1),t=e[e.length-1];return JSON.parse(JSON.stringify({...T,dictionaryOutput:{...z,fill:void 0,filled:!0}}).replaceAll(RegExp(`\\.${t}\\.[a-zA-Z0-9]+`,`g`),`.filled.${t}.json`))}return{...T,dictionaryOutput:z}},{maxRetry:2,delay:C,onError:({error:e,attempt:t,maxRetry:n})=>O(`${T.dictionaryPreset} ${f(`Error:`,u.RED)} ${f(typeof e==`string`?e:JSON.stringify(e),u.GREY_DARK)} - Attempt ${p(t+1)} of ${p(n)}`,{level:`error`}),onMaxTryReached:({error:e})=>O(`${T.dictionaryPreset} ${f(`Maximum number of retries reached:`,u.RED)} ${f(typeof e==`string`?e:JSON.stringify(e),u.GREY_DARK)}`,{level:`error`})})()};export{T as translateDictionary};
|
|
204
2
|
//# sourceMappingURL=translateDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateDictionary.mjs","names":[],"sources":["../../../src/fill/translateDictionary.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport { type AIOptions, getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n chunkJSON,\n formatLocale,\n type JsonChunk,\n reconstructFromSingleChunk,\n reduceObjectFormat,\n verifyIdenticObjectFormat,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n retryManager,\n} from '@intlayer/config';\nimport {\n getFilterMissingTranslationsDictionary,\n getMultilingualDictionary,\n getPerLocaleDictionary,\n insertContentInDictionary,\n} from '@intlayer/core';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport type { AIClient } from '../utils/setupAI';\nimport { deepMergeContent } from './deepMergeContent';\nimport { getFilterMissingContentPerLocale } from './getFilterMissingContentPerLocale';\nimport type { TranslationTask } from './listTranslationsTasks';\nimport { mergeChunks } from './mergeChunks';\n\ntype TranslateDictionaryResult = TranslationTask & {\n dictionaryOutput: Dictionary | null;\n};\n\ntype TranslateDictionaryOptions = {\n mode: 'complete' | 'review';\n aiOptions?: AIOptions;\n fillMetadata?: boolean;\n onHandle?: ReturnType<typeof import('@intlayer/chokidar').getGlobalLimiter>;\n onSuccess?: () => void;\n onError?: (error: unknown) => void;\n getAbortError?: () => Error | null;\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n};\n\nconst hasMissingMetadata = (dictionary: Dictionary) =>\n !dictionary.description || !dictionary.title || !dictionary.tags;\n\nconst CHUNK_SIZE = 7000; // GPT-5 Mini safe input size\nconst GROUP_MAX_RETRY = 2;\nconst MAX_RETRY = 3;\nconst RETRY_DELAY = 1000 * 10; // 10 seconds\n\nconst MAX_FOLLOWING_ERRORS = 10; // 10 errors in a row, hard exit the process\nlet followingErrors = 0;\n\nexport const translateDictionary = async (\n task: TranslationTask,\n configuration: IntlayerConfig,\n options?: TranslateDictionaryOptions\n): Promise<TranslateDictionaryResult> => {\n const appLogger = getAppLogger(configuration);\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {\n mode: 'complete',\n fillMetadata: true,\n ...options,\n } as const;\n\n const notifySuccess = () => {\n followingErrors = 0;\n options?.onSuccess?.();\n };\n\n const result = await retryManager(\n async () => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const baseUnmergedDictionary: Dictionary | undefined =\n unmergedDictionariesRecord[task.dictionaryKey].find(\n (dict) => dict.localId === task.dictionaryLocalId\n );\n\n if (!baseUnmergedDictionary) {\n appLogger(\n `${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n return { ...task, dictionaryOutput: null };\n }\n\n let metadata:\n | Pick<Dictionary, 'description' | 'title' | 'tags'>\n | undefined;\n\n if (\n fillMetadata &&\n (hasMissingMetadata(baseUnmergedDictionary) || mode === 'review')\n ) {\n const defaultLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n configuration.internationalization.defaultLocale\n );\n\n appLogger(\n `${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const runAudit = async () => {\n if (aiClient && aiConfig) {\n const result = await aiClient.auditDictionaryMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiConfig,\n });\n\n return {\n data: result,\n };\n }\n\n return await intlayerAPI.ai.auditContentDeclarationMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiOptions,\n });\n };\n\n const metadataResult = options?.onHandle\n ? await options.onHandle(runAudit)\n : await runAudit();\n\n metadata = metadataResult.data?.fileContent;\n }\n\n const translatedContentResults = await Promise.all(\n task.targetLocales.map(async (targetLocale) => {\n /**\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * targetLocale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\n // Reset to base dictionary for each locale to ensure we filter from the original\n let dictionaryToProcess = structuredClone(baseUnmergedDictionary);\n\n let targetLocaleDictionary: Dictionary;\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // For per-locale files, the content is already in simple JSON format (not translation nodes)\n // The base dictionary is already the source locale content\n\n // Load the existing target locale dictionary\n const targetLocaleFilePath =\n baseUnmergedDictionary.filePath?.replace(\n new RegExp(`/${task.sourceLocale}/`, 'g'),\n `/${targetLocale}/`\n );\n\n // Find the target locale dictionary in unmerged dictionaries\n const targetUnmergedDictionary = targetLocaleFilePath\n ? unmergedDictionariesRecord[task.dictionaryKey]?.find(\n (dict) =>\n dict.filePath === targetLocaleFilePath &&\n dict.locale === targetLocale\n )\n : undefined;\n\n targetLocaleDictionary = targetUnmergedDictionary ?? {\n key: baseUnmergedDictionary.key,\n content: {},\n filePath: targetLocaleFilePath,\n locale: targetLocale,\n };\n\n // In complete mode, filter out already translated content\n if (mode === 'complete') {\n dictionaryToProcess = getFilterMissingContentPerLocale(\n dictionaryToProcess,\n targetUnmergedDictionary\n );\n }\n } else {\n // For multilingual dictionaries\n if (mode === 'complete') {\n // Remove all nodes that don't have any content to translate\n dictionaryToProcess = getFilterMissingTranslationsDictionary(\n dictionaryToProcess,\n targetLocale\n );\n }\n\n dictionaryToProcess = getPerLocaleDictionary(\n dictionaryToProcess,\n task.sourceLocale\n );\n\n targetLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n targetLocale\n );\n }\n\n const localePreset = colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n formatLocale(targetLocale),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 18 }\n );\n\n const createChunkPreset = (\n chunkIndex: number,\n totalChunks: number\n ) => {\n if (totalChunks <= 1) return '';\n return colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n colorizeNumber(chunkIndex + 1),\n colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 5 }\n );\n };\n\n appLogger(\n `${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const isContentStructured =\n (typeof dictionaryToProcess.content === 'object' &&\n dictionaryToProcess.content !== null) ||\n Array.isArray(dictionaryToProcess.content);\n\n const contentToProcess = isContentStructured\n ? dictionaryToProcess.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n dictionaryToProcess.content,\n };\n\n const chunkedJsonContent: JsonChunk[] = chunkJSON(\n contentToProcess as unknown as Record<string, any>,\n CHUNK_SIZE\n );\n\n const nbOfChunks = chunkedJsonContent.length;\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`,\n {\n level: 'info',\n }\n );\n }\n\n const chunkResult: JsonChunk[] = [];\n\n // Process chunks in parallel (globally throttled) to allow concurrent translation\n const chunkPromises = chunkedJsonContent.map((chunk) => {\n const chunkPreset = createChunkPreset(chunk.index, chunk.total);\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`,\n {\n level: 'info',\n }\n );\n }\n\n // Reconstruct partial JSON content from this chunk's patches\n const chunkContent = reconstructFromSingleChunk(chunk);\n const presetOutputContent = reduceObjectFormat(\n isContentStructured\n ? targetLocaleDictionary.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n targetLocaleDictionary.content,\n },\n chunkContent\n ) as unknown as JSON;\n\n const executeTranslation = async () => {\n return await retryManager(\n async () => {\n let translationResult: any;\n\n if (aiClient && aiConfig) {\n translationResult = await aiClient.translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiConfig,\n });\n } else {\n translationResult = await intlayerAPI.ai\n .translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions,\n })\n .then((result) => result.data);\n }\n\n if (!translationResult?.fileContent) {\n throw new Error('No content result');\n }\n\n const { isIdentic } = verifyIdenticObjectFormat(\n translationResult.fileContent,\n chunkContent\n );\n\n if (!isIdentic) {\n throw new Error(\n 'Translation result does not match expected format'\n );\n }\n\n notifySuccess();\n return translationResult.fileContent;\n },\n {\n maxRetry: MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) => {\n const chunkPreset = createChunkPreset(\n chunk.index,\n chunk.total\n );\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize('Error filling:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n );\n\n followingErrors += 1;\n\n if (followingErrors >= MAX_FOLLOWING_ERRORS) {\n appLogger(`There is something wrong.`, {\n level: 'error',\n });\n process.exit(1); // 1 for error\n }\n },\n }\n )();\n };\n\n const wrapped = options?.onHandle\n ? options.onHandle(executeTranslation) // queued in global limiter\n : executeTranslation(); // no global limiter\n\n return wrapped.then((result) => ({ chunk, result }));\n });\n\n // Wait for all chunks for this locale in parallel (still capped by global limiter)\n const chunkResults = await Promise.all(chunkPromises);\n\n // Maintain order\n chunkResults\n .sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index)\n .forEach(({ result }) => {\n chunkResult.push(result);\n });\n\n // Merge partial JSON objects produced from each chunk into a single object\n const mergedContent = mergeChunks(chunkResult);\n\n const merged = {\n ...dictionaryToProcess,\n content: mergedContent,\n };\n\n // For per-locale files, merge the newly translated content with existing target content\n let finalContent = merged.content;\n\n if (!isContentStructured) {\n finalContent = (finalContent as any)\n ?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__;\n }\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // Deep merge: existing content + newly translated content\n finalContent = deepMergeContent(\n targetLocaleDictionary.content ?? {},\n finalContent\n );\n }\n\n return [targetLocale, finalContent] as const;\n })\n );\n\n const translatedContent: Partial<Record<Locale, Dictionary['content']>> =\n Object.fromEntries(translatedContentResults);\n\n const baseDictionary = baseUnmergedDictionary.locale\n ? {\n ...baseUnmergedDictionary,\n key: baseUnmergedDictionary.key!,\n content: {},\n }\n : baseUnmergedDictionary;\n\n let dictionaryOutput: Dictionary = {\n ...getMultilingualDictionary(baseDictionary),\n locale: undefined, // Ensure the dictionary is multilingual\n ...metadata,\n };\n\n for (const targetLocale of task.targetLocales) {\n if (translatedContent[targetLocale]) {\n dictionaryOutput = insertContentInDictionary(\n dictionaryOutput,\n translatedContent[targetLocale],\n targetLocale\n );\n }\n }\n\n appLogger(\n `${task.dictionaryPreset} ${colorize('Translation completed successfully', ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n if (\n baseUnmergedDictionary.locale &&\n (baseUnmergedDictionary.fill === true ||\n baseUnmergedDictionary.fill === undefined) &&\n baseUnmergedDictionary.location === 'local'\n ) {\n const dictionaryFilePath = baseUnmergedDictionary\n .filePath!.split('.')\n .slice(0, -1);\n\n const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];\n\n return JSON.parse(\n JSON.stringify({\n ...task,\n dictionaryOutput: {\n ...dictionaryOutput,\n fill: undefined,\n filled: true,\n },\n }).replaceAll(\n new RegExp(`\\\\.${contentIndex}\\\\.[a-zA-Z0-9]+`, 'g'),\n `.filled.${contentIndex}.json`\n )\n );\n }\n\n return {\n ...task,\n dictionaryOutput,\n };\n },\n {\n maxRetry: GROUP_MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Error:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n ),\n onMaxTryReached: ({ error }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Maximum number of retries reached:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)}`,\n {\n level: 'error',\n }\n ),\n }\n )();\n\n return result as TranslateDictionaryResult;\n};\n"],"mappings":";;;;;;;;;;;AAkDA,MAAM,sBAAsB,eAC1B,CAAC,WAAW,eAAe,CAAC,WAAW,SAAS,CAAC,WAAW;AAE9D,MAAM,aAAa;AACnB,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MAAM,cAAc,MAAO;AAE3B,MAAM,uBAAuB;AAC7B,IAAI,kBAAkB;AAEtB,MAAa,sBAAsB,OACjC,MACA,eACA,YACuC;CACvC,MAAM,YAAY,aAAa,cAAc;CAC7C,MAAM,cAAc,oBAAoB,QAAW,cAAc;CAEjE,MAAM,EAAE,MAAM,WAAW,cAAc,UAAU,aAAa;EAC5D,MAAM;EACN,cAAc;EACd,GAAG;EACJ;CAED,MAAM,sBAAsB;AAC1B,oBAAkB;AAClB,WAAS,aAAa;;AAqbxB,QAlbe,MAA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AAI,OAAO,MAAM,aAAa,kBAAkB,IAAI,EACpD,WAAW,aAAa,OACzB,CACF;;AAGH,SAAO;GACL,GAAG;GACH;GACD;IAEH;EACE,UAAU;EACV,OAAO;EACP,UAAU,EAAE,OAAO,SAAS,eAC1B,UACE,GAAG,KAAK,iBAAiB,GAAG,SAAS,UAAU,WAAW,IAAI,CAAC,GAAG,SAAS,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,MAAM,EAAE,WAAW,UAAU,CAAC,aAAa,eAAe,UAAU,EAAE,CAAC,MAAM,eAAe,SAAS,IACnO,EACE,OAAO,SACR,CACF;EACH,kBAAkB,EAAE,YAClB,UACE,GAAG,KAAK,iBAAiB,GAAG,SAAS,sCAAsC,WAAW,IAAI,CAAC,GAAG,SAAS,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,MAAM,EAAE,WAAW,UAAU,IACvL,EACE,OAAO,SACR,CACF;EACJ,CACF,EAAE"}
|
|
1
|
+
{"version":3,"file":"translateDictionary.mjs","names":[],"sources":["../../../src/fill/translateDictionary.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { AIConfig } from '@intlayer/ai';\nimport { type AIOptions, getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n chunkJSON,\n formatLocale,\n type JsonChunk,\n reconstructFromSingleChunk,\n reduceObjectFormat,\n verifyIdenticObjectFormat,\n} from '@intlayer/chokidar/utils';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport {\n getFilterMissingTranslationsDictionary,\n getMultilingualDictionary,\n getPerLocaleDictionary,\n insertContentInDictionary,\n} from '@intlayer/core/plugins';\nimport type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport type { AIClient } from '../utils/setupAI';\nimport { deepMergeContent } from './deepMergeContent';\nimport { getFilterMissingContentPerLocale } from './getFilterMissingContentPerLocale';\nimport type { TranslationTask } from './listTranslationsTasks';\nimport { mergeChunks } from './mergeChunks';\n\ntype TranslateDictionaryResult = TranslationTask & {\n dictionaryOutput: Dictionary | null;\n};\n\ntype TranslateDictionaryOptions = {\n mode: 'complete' | 'review';\n aiOptions?: AIOptions;\n fillMetadata?: boolean;\n onHandle?: ReturnType<\n typeof import('@intlayer/chokidar/utils').getGlobalLimiter\n >;\n onSuccess?: () => void;\n onError?: (error: unknown) => void;\n getAbortError?: () => Error | null;\n aiClient?: AIClient;\n aiConfig?: AIConfig;\n};\n\nconst hasMissingMetadata = (dictionary: Dictionary) =>\n !dictionary.description || !dictionary.title || !dictionary.tags;\n\nconst CHUNK_SIZE = 7000; // GPT-5 Mini safe input size\nconst GROUP_MAX_RETRY = 2;\nconst MAX_RETRY = 3;\nconst RETRY_DELAY = 1000 * 10; // 10 seconds\n\nconst MAX_FOLLOWING_ERRORS = 10; // 10 errors in a row, hard exit the process\nlet followingErrors = 0;\n\nexport const translateDictionary = async (\n task: TranslationTask,\n configuration: IntlayerConfig,\n options?: TranslateDictionaryOptions\n): Promise<TranslateDictionaryResult> => {\n const appLogger = getAppLogger(configuration);\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n const { mode, aiOptions, fillMetadata, aiClient, aiConfig } = {\n mode: 'complete',\n fillMetadata: true,\n ...options,\n } as const;\n\n const notifySuccess = () => {\n followingErrors = 0;\n options?.onSuccess?.();\n };\n\n const result = await retryManager(\n async () => {\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n\n const baseUnmergedDictionary: Dictionary | undefined =\n unmergedDictionariesRecord[task.dictionaryKey].find(\n (dict) => dict.localId === task.dictionaryLocalId\n );\n\n if (!baseUnmergedDictionary) {\n appLogger(\n `${task.dictionaryPreset}Dictionary not found in unmergedDictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n return { ...task, dictionaryOutput: null };\n }\n\n let metadata:\n | Pick<Dictionary, 'description' | 'title' | 'tags'>\n | undefined;\n\n if (\n fillMetadata &&\n (hasMissingMetadata(baseUnmergedDictionary) || mode === 'review')\n ) {\n const defaultLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n configuration.internationalization.defaultLocale\n );\n\n appLogger(\n `${task.dictionaryPreset} Filling missing metadata for ${colorizePath(basename(baseUnmergedDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const runAudit = async () => {\n if (aiClient && aiConfig) {\n const result = await aiClient.auditDictionaryMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiConfig,\n });\n\n return {\n data: result,\n };\n }\n\n return await intlayerAPI.ai.auditContentDeclarationMetadata({\n fileContent: JSON.stringify(defaultLocaleDictionary),\n aiOptions,\n });\n };\n\n const metadataResult = options?.onHandle\n ? await options.onHandle(runAudit)\n : await runAudit();\n\n metadata = metadataResult.data?.fileContent;\n }\n\n const translatedContentResults = await Promise.all(\n task.targetLocales.map(async (targetLocale) => {\n /**\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * targetLocale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\n // Reset to base dictionary for each locale to ensure we filter from the original\n let dictionaryToProcess = structuredClone(baseUnmergedDictionary);\n\n let targetLocaleDictionary: Dictionary;\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // For per-locale files, the content is already in simple JSON format (not translation nodes)\n // The base dictionary is already the source locale content\n\n // Load the existing target locale dictionary\n const targetLocaleFilePath =\n baseUnmergedDictionary.filePath?.replace(\n new RegExp(`/${task.sourceLocale}/`, 'g'),\n `/${targetLocale}/`\n );\n\n // Find the target locale dictionary in unmerged dictionaries\n const targetUnmergedDictionary = targetLocaleFilePath\n ? unmergedDictionariesRecord[task.dictionaryKey]?.find(\n (dict) =>\n dict.filePath === targetLocaleFilePath &&\n dict.locale === targetLocale\n )\n : undefined;\n\n targetLocaleDictionary = targetUnmergedDictionary ?? {\n key: baseUnmergedDictionary.key,\n content: {},\n filePath: targetLocaleFilePath,\n locale: targetLocale,\n };\n\n // In complete mode, filter out already translated content\n if (mode === 'complete') {\n dictionaryToProcess = getFilterMissingContentPerLocale(\n dictionaryToProcess,\n targetUnmergedDictionary\n );\n }\n } else {\n // For multilingual dictionaries\n if (mode === 'complete') {\n // Remove all nodes that don't have any content to translate\n dictionaryToProcess = getFilterMissingTranslationsDictionary(\n dictionaryToProcess,\n targetLocale\n );\n }\n\n dictionaryToProcess = getPerLocaleDictionary(\n dictionaryToProcess,\n task.sourceLocale\n );\n\n targetLocaleDictionary = getPerLocaleDictionary(\n baseUnmergedDictionary,\n targetLocale\n );\n }\n\n const localePreset = colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n formatLocale(targetLocale),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 18 }\n );\n\n const createChunkPreset = (\n chunkIndex: number,\n totalChunks: number\n ) => {\n if (totalChunks <= 1) return '';\n return colon(\n [\n colorize('[', ANSIColors.GREY_DARK),\n colorizeNumber(chunkIndex + 1),\n colorize(`/${totalChunks}`, ANSIColors.GREY_DARK),\n colorize(']', ANSIColors.GREY_DARK),\n ].join(''),\n { colSize: 5 }\n );\n };\n\n appLogger(\n `${task.dictionaryPreset}${localePreset} Preparing ${colorizePath(basename(targetLocaleDictionary.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n const isContentStructured =\n (typeof dictionaryToProcess.content === 'object' &&\n dictionaryToProcess.content !== null) ||\n Array.isArray(dictionaryToProcess.content);\n\n const contentToProcess = isContentStructured\n ? dictionaryToProcess.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n dictionaryToProcess.content,\n };\n\n const chunkedJsonContent: JsonChunk[] = chunkJSON(\n contentToProcess as unknown as Record<string, any>,\n CHUNK_SIZE\n );\n\n const nbOfChunks = chunkedJsonContent.length;\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset} Split into ${colorizeNumber(nbOfChunks)} chunks for translation`,\n {\n level: 'info',\n }\n );\n }\n\n const chunkResult: JsonChunk[] = [];\n\n // Process chunks in parallel (globally throttled) to allow concurrent translation\n const chunkPromises = chunkedJsonContent.map((chunk) => {\n const chunkPreset = createChunkPreset(chunk.index, chunk.total);\n\n if (nbOfChunks > 1) {\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} Translating chunk`,\n {\n level: 'info',\n }\n );\n }\n\n // Reconstruct partial JSON content from this chunk's patches\n const chunkContent = reconstructFromSingleChunk(chunk);\n const presetOutputContent = reduceObjectFormat(\n isContentStructured\n ? targetLocaleDictionary.content\n : {\n __INTLAYER_ROOT_PRIMITIVE_CONTENT__:\n targetLocaleDictionary.content,\n },\n chunkContent\n ) as unknown as JSON;\n\n const executeTranslation = async () => {\n return await retryManager(\n async () => {\n let translationResult: any;\n\n if (aiClient && aiConfig) {\n translationResult = await aiClient.translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiConfig,\n });\n } else {\n translationResult = await intlayerAPI.ai\n .translateJSON({\n entryFileContent: chunkContent as unknown as JSON,\n presetOutputContent,\n dictionaryDescription:\n dictionaryToProcess.description ??\n metadata?.description ??\n '',\n entryLocale: task.sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions,\n })\n .then((result) => result.data);\n }\n\n if (!translationResult?.fileContent) {\n throw new Error('No content result');\n }\n\n const { isIdentic } = verifyIdenticObjectFormat(\n translationResult.fileContent,\n chunkContent\n );\n\n if (!isIdentic) {\n throw new Error(\n 'Translation result does not match expected format'\n );\n }\n\n notifySuccess();\n return translationResult.fileContent;\n },\n {\n maxRetry: MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) => {\n const chunkPreset = createChunkPreset(\n chunk.index,\n chunk.total\n );\n appLogger(\n `${task.dictionaryPreset}${localePreset}${chunkPreset} ${colorize('Error filling:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n );\n\n followingErrors += 1;\n\n if (followingErrors >= MAX_FOLLOWING_ERRORS) {\n appLogger(`There is something wrong.`, {\n level: 'error',\n });\n process.exit(1); // 1 for error\n }\n },\n }\n )();\n };\n\n const wrapped = options?.onHandle\n ? options.onHandle(executeTranslation) // queued in global limiter\n : executeTranslation(); // no global limiter\n\n return wrapped.then((result) => ({ chunk, result }));\n });\n\n // Wait for all chunks for this locale in parallel (still capped by global limiter)\n const chunkResults = await Promise.all(chunkPromises);\n\n // Maintain order\n chunkResults\n .sort((chunkA, chunkB) => chunkA.chunk.index - chunkB.chunk.index)\n .forEach(({ result }) => {\n chunkResult.push(result);\n });\n\n // Merge partial JSON objects produced from each chunk into a single object\n const mergedContent = mergeChunks(chunkResult);\n\n const merged = {\n ...dictionaryToProcess,\n content: mergedContent,\n };\n\n // For per-locale files, merge the newly translated content with existing target content\n let finalContent = merged.content;\n\n if (!isContentStructured) {\n finalContent = (finalContent as any)\n ?.__INTLAYER_ROOT_PRIMITIVE_CONTENT__;\n }\n\n if (typeof baseUnmergedDictionary.locale === 'string') {\n // Deep merge: existing content + newly translated content\n finalContent = deepMergeContent(\n targetLocaleDictionary.content ?? {},\n finalContent\n );\n }\n\n return [targetLocale, finalContent] as const;\n })\n );\n\n const translatedContent: Partial<Record<Locale, Dictionary['content']>> =\n Object.fromEntries(translatedContentResults);\n\n const baseDictionary = baseUnmergedDictionary.locale\n ? {\n ...baseUnmergedDictionary,\n key: baseUnmergedDictionary.key!,\n content: {},\n }\n : baseUnmergedDictionary;\n\n let dictionaryOutput: Dictionary = {\n ...getMultilingualDictionary(baseDictionary),\n locale: undefined, // Ensure the dictionary is multilingual\n ...metadata,\n };\n\n for (const targetLocale of task.targetLocales) {\n if (translatedContent[targetLocale]) {\n dictionaryOutput = insertContentInDictionary(\n dictionaryOutput,\n translatedContent[targetLocale],\n targetLocale\n );\n }\n }\n\n appLogger(\n `${task.dictionaryPreset} ${colorize('Translation completed successfully', ANSIColors.GREEN)} for ${colorizePath(basename(dictionaryOutput.filePath!))}`,\n {\n level: 'info',\n }\n );\n\n if (\n baseUnmergedDictionary.locale &&\n (baseUnmergedDictionary.fill === true ||\n baseUnmergedDictionary.fill === undefined) &&\n baseUnmergedDictionary.location === 'local'\n ) {\n const dictionaryFilePath = baseUnmergedDictionary\n .filePath!.split('.')\n .slice(0, -1);\n\n const contentIndex = dictionaryFilePath[dictionaryFilePath.length - 1];\n\n return JSON.parse(\n JSON.stringify({\n ...task,\n dictionaryOutput: {\n ...dictionaryOutput,\n fill: undefined,\n filled: true,\n },\n }).replaceAll(\n new RegExp(`\\\\.${contentIndex}\\\\.[a-zA-Z0-9]+`, 'g'),\n `.filled.${contentIndex}.json`\n )\n );\n }\n\n return {\n ...task,\n dictionaryOutput,\n };\n },\n {\n maxRetry: GROUP_MAX_RETRY,\n delay: RETRY_DELAY,\n onError: ({ error, attempt, maxRetry }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Error:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)} - Attempt ${colorizeNumber(attempt + 1)} of ${colorizeNumber(maxRetry)}`,\n {\n level: 'error',\n }\n ),\n onMaxTryReached: ({ error }) =>\n appLogger(\n `${task.dictionaryPreset} ${colorize('Maximum number of retries reached:', ANSIColors.RED)} ${colorize(typeof error === 'string' ? error : JSON.stringify(error), ANSIColors.GREY_DARK)}`,\n {\n level: 'error',\n }\n ),\n }\n )();\n\n return result as TranslateDictionaryResult;\n};\n"],"mappings":"i3BAoDA,MAAM,EAAsB,GAC1B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,IAAI,CACpD,WAAW,EAAa,OACzB,CACF,CAGH,MAAO,CACL,GAAG,EACH,mBACD,EAEH,CACE,SAAU,EACV,MAAO,EACP,SAAU,CAAE,QAAO,UAAS,cAC1B,EACE,GAAG,EAAK,iBAAiB,GAAG,EAAS,SAAU,EAAW,IAAI,CAAC,GAAG,EAAS,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAE,EAAW,UAAU,CAAC,aAAa,EAAe,EAAU,EAAE,CAAC,MAAM,EAAe,EAAS,GACnO,CACE,MAAO,QACR,CACF,CACH,iBAAkB,CAAE,WAClB,EACE,GAAG,EAAK,iBAAiB,GAAG,EAAS,qCAAsC,EAAW,IAAI,CAAC,GAAG,EAAS,OAAO,GAAU,SAAW,EAAQ,KAAK,UAAU,EAAM,CAAE,EAAW,UAAU,GACvL,CACE,MAAO,QACR,CACF,CACJ,CACF,EAAE"}
|
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getAvailableLocalesInDictionary } from "./getAvailableLocalesInDictionary.mjs";
|
|
3
|
-
import { formatLocale, formatPath, writeContentDeclaration } from "@intlayer/chokidar";
|
|
4
|
-
import { colorizeKey, getAppLogger } from "@intlayer/config";
|
|
5
|
-
import { relative } from "node:path";
|
|
6
|
-
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
7
|
-
|
|
8
|
-
//#region src/fill/writeFill.ts
|
|
9
|
-
const writeFill = async (contentDeclarationFile, outputLocales, parentLocales, configuration) => {
|
|
10
|
-
const appLogger = getAppLogger(configuration);
|
|
11
|
-
const fullDictionary = getDictionaries(configuration)[contentDeclarationFile.key];
|
|
12
|
-
const { filePath } = contentDeclarationFile;
|
|
13
|
-
if (!filePath) {
|
|
14
|
-
appLogger("No file path found for dictionary", { level: "error" });
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const fillOptions = contentDeclarationFile.fill ?? configuration.dictionary?.fill ?? true;
|
|
18
|
-
if (fillOptions === false) {
|
|
19
|
-
appLogger(`Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`, { level: "info" });
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const requestedLocales = (outputLocales ?? configuration.internationalization.locales).filter((locale) => !parentLocales?.includes(locale));
|
|
23
|
-
const availableLocales = getAvailableLocalesInDictionary(contentDeclarationFile);
|
|
24
|
-
const localeList = requestedLocales.filter((locale) => availableLocales.includes(locale));
|
|
25
|
-
if (localeList.length === 0) {
|
|
26
|
-
appLogger(`No translations available for dictionary '${colorizeKey(fullDictionary.key)}'`, { level: "info" });
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const fillData = formatFillData(fillOptions, localeList, filePath, fullDictionary.key, configuration);
|
|
30
|
-
for await (const output of fillData) {
|
|
31
|
-
if (!output.filePath) {
|
|
32
|
-
appLogger(`No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`, { level: "error" });
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const { fill, ...rest } = contentDeclarationFile;
|
|
36
|
-
const relativeFilePath = relative(configuration.content.baseDir, output.filePath);
|
|
37
|
-
await writeContentDeclaration({
|
|
38
|
-
...rest,
|
|
39
|
-
filled: true,
|
|
40
|
-
locale: output.isPerLocale ? output.localeList[0] : void 0,
|
|
41
|
-
localId: `${contentDeclarationFile.key}::local::${relativeFilePath}`,
|
|
42
|
-
filePath: relativeFilePath
|
|
43
|
-
}, configuration, { localeList: output.localeList });
|
|
44
|
-
if (output.isPerLocale) {
|
|
45
|
-
const sourceLocale = output.localeList[0];
|
|
46
|
-
appLogger(`Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`, { level: "info" });
|
|
47
|
-
} else appLogger(`Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`, { level: "info" });
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
export { writeFill };
|
|
1
|
+
import{formatFillData as e}from"./formatFillData.mjs";import{getAvailableLocalesInDictionary as t}from"./getAvailableLocalesInDictionary.mjs";import{formatLocale as n,formatPath as r}from"@intlayer/chokidar/utils";import{relative as i}from"node:path";import{colorizeKey as a,getAppLogger as o}from"@intlayer/config/logger";import{writeContentDeclaration as s}from"@intlayer/chokidar/build";import{getDictionaries as c}from"@intlayer/dictionaries-entry";const l=async(l,u,d,f)=>{let p=o(f),m=c(f)[l.key],{filePath:h}=l;if(!h){p(`No file path found for dictionary`,{level:`error`});return}let g=l.fill??f.dictionary?.fill??!0;if(g===!1){p(`Auto fill is disabled for '${a(m.key)}'`,{level:`info`});return}let _=(u??f.internationalization.locales).filter(e=>!d?.includes(e)),v=t(l),y=_.filter(e=>v.includes(e));if(y.length===0){p(`No translations available for dictionary '${a(m.key)}'`,{level:`info`});return}let b=e(g,y,h,m.key,f);for await(let e of b){if(!e.filePath){p(`No file path found for auto filled content declaration for '${a(m.key)}'`,{level:`error`});continue}let{fill:t,...o}=l,c=i(f.content.baseDir,e.filePath);if(await s({...o,filled:!0,locale:e.isPerLocale?e.localeList[0]:void 0,localId:`${l.key}::local::${c}`,filePath:c},f,{localeList:e.localeList}),e.isPerLocale){let t=e.localeList[0];p(`Auto filled per-locale content declaration for '${a(m.key)}' written to ${r(e.filePath)} for locale ${n(t)}`,{level:`info`})}else p(`Auto filled content declaration for '${a(m.key)}' written to ${r(e.filePath)}`,{level:`info`})}};export{l as writeFill};
|
|
53
2
|
//# sourceMappingURL=writeFill.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFill.mjs","names":[],"sources":["../../../src/fill/writeFill.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"writeFill.mjs","names":[],"sources":["../../../src/fill/writeFill.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { writeContentDeclaration } from '@intlayer/chokidar/build';\nimport { formatLocale, formatPath } from '@intlayer/chokidar/utils';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, Fill, IntlayerConfig, Locale } from '@intlayer/types';\nimport { type FillData, formatFillData } from './formatFillData';\nimport { getAvailableLocalesInDictionary } from './getAvailableLocalesInDictionary';\n\nexport const writeFill = async (\n contentDeclarationFile: Dictionary,\n outputLocales: Locale[],\n parentLocales: Locale[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n const dictionaries = getDictionaries(configuration);\n\n const fullDictionary = dictionaries[contentDeclarationFile.key];\n\n const { filePath } = contentDeclarationFile;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const fillOptions: Fill | undefined =\n contentDeclarationFile.fill ?? configuration.dictionary?.fill ?? true;\n\n if ((fillOptions as boolean) === false) {\n appLogger(\n `Auto fill is disabled for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const requestedLocales: Locale[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n // Get locales that actually have translations in the content\n const availableLocales = getAvailableLocalesInDictionary(\n contentDeclarationFile\n );\n\n // Only write files for locales that have actual translations\n const localeList = requestedLocales.filter((locale) =>\n availableLocales.includes(locale)\n );\n\n if (localeList.length === 0) {\n appLogger(\n `No translations available for dictionary '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'info',\n }\n );\n return;\n }\n\n const fillData: FillData[] = formatFillData(\n fillOptions as Fill,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n for await (const output of fillData) {\n if (!output.filePath) {\n appLogger(\n `No file path found for auto filled content declaration for '${colorizeKey(fullDictionary.key)}'`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n // biome-ignore lint/correctness/noUnusedVariables: Just filtering out the fill property\n const { fill, ...rest } = contentDeclarationFile;\n\n const relativeFilePath = relative(\n configuration.content.baseDir,\n output.filePath\n );\n\n // write file\n await writeContentDeclaration(\n {\n ...rest,\n filled: true,\n locale: output.isPerLocale ? output.localeList[0] : undefined,\n localId: `${contentDeclarationFile.key}::local::${relativeFilePath}`,\n filePath: relativeFilePath,\n },\n configuration,\n {\n localeList: output.localeList,\n }\n );\n\n if (output.isPerLocale) {\n const sourceLocale = output.localeList[0];\n\n appLogger(\n `Auto filled per-locale content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)} for locale ${formatLocale(sourceLocale)}`,\n {\n level: 'info',\n }\n );\n } else {\n appLogger(\n `Auto filled content declaration for '${colorizeKey(fullDictionary.key)}' written to ${formatPath(output.filePath)}`,\n {\n level: 'info',\n }\n );\n }\n }\n};\n"],"mappings":"qcASA,MAAa,EAAY,MACvB,EACA,EACA,EACA,IACG,CACH,IAAM,EAAY,EAAa,EAAc,CAGvC,EAFe,EAAgB,EAAc,CAEf,EAAuB,KAErD,CAAE,YAAa,EAErB,GAAI,CAAC,EAAU,CACb,EAAU,oCAAqC,CAC7C,MAAO,QACR,CAAC,CACF,OAGF,IAAM,EACJ,EAAuB,MAAQ,EAAc,YAAY,MAAQ,GAEnE,GAAK,IAA4B,GAAO,CACtC,EACE,8BAA8B,EAAY,EAAe,IAAI,CAAC,GAC9D,CACE,MAAO,OACR,CACF,CACD,OAGF,IAAM,GACJ,GAAiB,EAAc,qBAAqB,SACpD,OAAQ,GAAW,CAAC,GAAe,SAAS,EAAO,CAAC,CAGhD,EAAmB,EACvB,EACD,CAGK,EAAa,EAAiB,OAAQ,GAC1C,EAAiB,SAAS,EAAO,CAClC,CAED,GAAI,EAAW,SAAW,EAAG,CAC3B,EACE,6CAA6C,EAAY,EAAe,IAAI,CAAC,GAC7E,CACE,MAAO,OACR,CACF,CACD,OAGF,IAAM,EAAuB,EAC3B,EACA,EACA,EACA,EAAe,IACf,EACD,CAED,UAAW,IAAM,KAAU,EAAU,CACnC,GAAI,CAAC,EAAO,SAAU,CACpB,EACE,+DAA+D,EAAY,EAAe,IAAI,CAAC,GAC/F,CACE,MAAO,QACR,CACF,CACD,SAIF,GAAM,CAAE,OAAM,GAAG,GAAS,EAEpB,EAAmB,EACvB,EAAc,QAAQ,QACtB,EAAO,SACR,CAiBD,GAdA,MAAM,EACJ,CACE,GAAG,EACH,OAAQ,GACR,OAAQ,EAAO,YAAc,EAAO,WAAW,GAAK,IAAA,GACpD,QAAS,GAAG,EAAuB,IAAI,WAAW,IAClD,SAAU,EACX,CACD,EACA,CACE,WAAY,EAAO,WACpB,CACF,CAEG,EAAO,YAAa,CACtB,IAAM,EAAe,EAAO,WAAW,GAEvC,EACE,mDAAmD,EAAY,EAAe,IAAI,CAAC,eAAe,EAAW,EAAO,SAAS,CAAC,cAAc,EAAa,EAAa,GACtK,CACE,MAAO,OACR,CACF,MAED,EACE,wCAAwC,EAAY,EAAe,IAAI,CAAC,eAAe,EAAW,EAAO,SAAS,GAClH,CACE,MAAO,OACR,CACF"}
|
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
import { listGitFiles }
|
|
2
|
-
import { getConfiguration } from "@intlayer/config";
|
|
3
|
-
import { join, relative } from "node:path";
|
|
4
|
-
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
5
|
-
|
|
6
|
-
//#region src/getTargetDictionary.ts
|
|
7
|
-
const ensureArray = (value) => [value].flat();
|
|
8
|
-
const getTargetUnmergedDictionaries = async (options) => {
|
|
9
|
-
const configuration = getConfiguration(options?.configOptions);
|
|
10
|
-
const { baseDir } = configuration.content;
|
|
11
|
-
const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);
|
|
12
|
-
let result = Object.values(unmergedDictionariesRecord).flat();
|
|
13
|
-
if (typeof options?.file !== "undefined") {
|
|
14
|
-
const relativeFilePaths = ensureArray(options?.file).map((file) => file.startsWith("/") ? relative(baseDir, file) : join("./", file));
|
|
15
|
-
result = result.filter((dict) => dict.filePath && relativeFilePaths.includes(dict.filePath));
|
|
16
|
-
}
|
|
17
|
-
if (typeof options?.keys !== "undefined") result = result.filter((dict) => ensureArray(options?.keys)?.includes(dict.key));
|
|
18
|
-
if (typeof options?.excludedKeys !== "undefined") result = result.filter((dict) => !ensureArray(options?.excludedKeys)?.includes(dict.key));
|
|
19
|
-
if (typeof options?.pathFilter !== "undefined") result = result.filter((dict) => ensureArray(options?.pathFilter)?.includes(dict.filePath ?? ""));
|
|
20
|
-
if (typeof options?.filter !== "undefined") result = result.filter(options?.filter);
|
|
21
|
-
const gitOptions = options?.gitOptions;
|
|
22
|
-
if (gitOptions) {
|
|
23
|
-
const gitChangedFiles = await listGitFiles(gitOptions);
|
|
24
|
-
if (gitChangedFiles) result = result.filter((dict) => {
|
|
25
|
-
if (!dict.filePath) return false;
|
|
26
|
-
return gitChangedFiles.some((gitFile) => dict.filePath === gitFile);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
export { ensureArray, getTargetUnmergedDictionaries };
|
|
1
|
+
import{getConfiguration as e}from"@intlayer/config/node";import{join as t,relative as n}from"node:path";import{listGitFiles as r}from"@intlayer/chokidar/cli";import{getUnmergedDictionaries as i}from"@intlayer/unmerged-dictionaries-entry";const a=e=>[e].flat(),o=async o=>{let s=e(o?.configOptions),{baseDir:c}=s.content,l=i(s),u=Object.values(l).flat();if(o?.file!==void 0){let e=a(o?.file).map(e=>e.startsWith(`/`)?n(c,e):t(`./`,e));u=u.filter(t=>t.filePath&&e.includes(t.filePath))}o?.keys!==void 0&&(u=u.filter(e=>a(o?.keys)?.includes(e.key))),o?.excludedKeys!==void 0&&(u=u.filter(e=>!a(o?.excludedKeys)?.includes(e.key))),o?.pathFilter!==void 0&&(u=u.filter(e=>a(o?.pathFilter)?.includes(e.filePath??``))),o?.filter!==void 0&&(u=u.filter(o?.filter));let d=o?.gitOptions;if(d){let e=await r(d);e&&(u=u.filter(t=>t.filePath?e.some(e=>t.filePath===e):!1))}return u};export{a as ensureArray,o as getTargetUnmergedDictionaries};
|
|
34
2
|
//# sourceMappingURL=getTargetDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTargetDictionary.mjs","names":[],"sources":["../../src/getTargetDictionary.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { type ListGitFilesOptions, listGitFiles } from '@intlayer/chokidar';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport const ensureArray = <T>(value: T | T[]): T[] => [value].flat() as T[];\n\n// Arguments for the fill function\nexport type GetTargetDictionaryOptions = {\n file?: string | string[];\n keys?: string | string[];\n excludedKeys?: string | string[];\n filter?: (entry: Dictionary) => boolean; // DictionaryEntry needs to be defined\n pathFilter?: string | string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n};\n\nexport const getTargetUnmergedDictionaries = async (\n options?: GetTargetDictionaryOptions\n): Promise<Dictionary[]> => {\n const configuration = getConfiguration(options?.configOptions);\n\n const { baseDir } = configuration.content;\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n let result = Object.values(unmergedDictionariesRecord).flat();\n\n // 1. if filePath not defined, list all content declaration files based on unmerged dictionaries list\n if (typeof options?.file !== 'undefined') {\n const fileArray = ensureArray(options?.file);\n const relativeFilePaths = fileArray.map((file) =>\n file.startsWith('/') ? relative(baseDir, file) : join('./', file)\n );\n\n result = result.filter(\n (dict) =>\n dict.filePath &&\n // Check for absolute path\n relativeFilePaths.includes(dict.filePath)\n );\n }\n\n if (typeof options?.keys !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options?.keys)?.includes(dict.key)\n );\n }\n\n if (typeof options?.excludedKeys !== 'undefined') {\n result = result.filter(\n (dict) => !ensureArray(options?.excludedKeys)?.includes(dict.key)\n );\n }\n\n if (typeof options?.pathFilter !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options?.pathFilter)?.includes(dict.filePath ?? '')\n );\n }\n\n if (typeof options?.filter !== 'undefined') {\n result = result.filter(options?.filter);\n }\n\n const gitOptions = options?.gitOptions;\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n result = result.filter((dict) => {\n if (!dict.filePath) return false;\n\n return gitChangedFiles.some((gitFile) => dict.filePath === gitFile);\n });\n }\n }\n\n return result;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getTargetDictionary.mjs","names":[],"sources":["../../src/getTargetDictionary.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { type ListGitFilesOptions, listGitFiles } from '@intlayer/chokidar/cli';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\nexport const ensureArray = <T>(value: T | T[]): T[] => [value].flat() as T[];\n\n// Arguments for the fill function\nexport type GetTargetDictionaryOptions = {\n file?: string | string[];\n keys?: string | string[];\n excludedKeys?: string | string[];\n filter?: (entry: Dictionary) => boolean; // DictionaryEntry needs to be defined\n pathFilter?: string | string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n};\n\nexport const getTargetUnmergedDictionaries = async (\n options?: GetTargetDictionaryOptions\n): Promise<Dictionary[]> => {\n const configuration = getConfiguration(options?.configOptions);\n\n const { baseDir } = configuration.content;\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(configuration);\n let result = Object.values(unmergedDictionariesRecord).flat();\n\n // 1. if filePath not defined, list all content declaration files based on unmerged dictionaries list\n if (typeof options?.file !== 'undefined') {\n const fileArray = ensureArray(options?.file);\n const relativeFilePaths = fileArray.map((file) =>\n file.startsWith('/') ? relative(baseDir, file) : join('./', file)\n );\n\n result = result.filter(\n (dict) =>\n dict.filePath &&\n // Check for absolute path\n relativeFilePaths.includes(dict.filePath)\n );\n }\n\n if (typeof options?.keys !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options?.keys)?.includes(dict.key)\n );\n }\n\n if (typeof options?.excludedKeys !== 'undefined') {\n result = result.filter(\n (dict) => !ensureArray(options?.excludedKeys)?.includes(dict.key)\n );\n }\n\n if (typeof options?.pathFilter !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options?.pathFilter)?.includes(dict.filePath ?? '')\n );\n }\n\n if (typeof options?.filter !== 'undefined') {\n result = result.filter(options?.filter);\n }\n\n const gitOptions = options?.gitOptions;\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n result = result.filter((dict) => {\n if (!dict.filePath) return false;\n\n return gitChangedFiles.some((gitFile) => dict.filePath === gitFile);\n });\n }\n }\n\n return result;\n};\n"],"mappings":"8OASA,MAAa,EAAkB,GAAwB,CAAC,EAAM,CAAC,MAAM,CAaxD,EAAgC,KAC3C,IAC0B,CAC1B,IAAM,EAAgB,EAAiB,GAAS,cAAc,CAExD,CAAE,WAAY,EAAc,QAE5B,EAA6B,EAAwB,EAAc,CACrE,EAAS,OAAO,OAAO,EAA2B,CAAC,MAAM,CAG7D,GAAW,GAAS,OAAS,OAAa,CAExC,IAAM,EADY,EAAY,GAAS,KAAK,CACR,IAAK,GACvC,EAAK,WAAW,IAAI,CAAG,EAAS,EAAS,EAAK,CAAG,EAAK,KAAM,EAAK,CAClE,CAED,EAAS,EAAO,OACb,GACC,EAAK,UAEL,EAAkB,SAAS,EAAK,SAAS,CAC5C,CAGQ,GAAS,OAAS,SAC3B,EAAS,EAAO,OAAQ,GACtB,EAAY,GAAS,KAAK,EAAE,SAAS,EAAK,IAAI,CAC/C,EAGQ,GAAS,eAAiB,SACnC,EAAS,EAAO,OACb,GAAS,CAAC,EAAY,GAAS,aAAa,EAAE,SAAS,EAAK,IAAI,CAClE,EAGQ,GAAS,aAAe,SACjC,EAAS,EAAO,OAAQ,GACtB,EAAY,GAAS,WAAW,EAAE,SAAS,EAAK,UAAY,GAAG,CAChE,EAGQ,GAAS,SAAW,SAC7B,EAAS,EAAO,OAAO,GAAS,OAAO,EAGzC,IAAM,EAAa,GAAS,WAC5B,GAAI,EAAY,CACd,IAAM,EAAkB,MAAM,EAAa,EAAW,CAElD,IAIF,EAAS,EAAO,OAAQ,GACjB,EAAK,SAEH,EAAgB,KAAM,GAAY,EAAK,WAAa,EAAQ,CAFxC,GAG3B,EAIN,OAAO"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { startEditor } from "./editor.mjs";
|
|
3
|
-
import { extract } from "./extract.mjs";
|
|
4
|
-
import { listMissingTranslations, listMissingTranslationsWithConfig } from "./test/listMissingTranslations.mjs";
|
|
5
|
-
import { testMissingTranslations } from "./test/test.mjs";
|
|
6
|
-
import { fill } from "./fill/fill.mjs";
|
|
7
|
-
import { getDetectedPlatform, init, initSkills } from "./init.mjs";
|
|
8
|
-
import { listContentDeclaration, listContentDeclarationRows } from "./listContentDeclaration.mjs";
|
|
9
|
-
import { liveSync } from "./liveSync.mjs";
|
|
10
|
-
import { pull } from "./pull.mjs";
|
|
11
|
-
import { push } from "./push/push.mjs";
|
|
12
|
-
import { pushConfig } from "./pushConfig.mjs";
|
|
13
|
-
import { reviewDoc } from "./reviewDoc/reviewDoc.mjs";
|
|
14
|
-
import { searchDoc } from "./searchDoc.mjs";
|
|
15
|
-
import { translateDoc } from "./translateDoc/translateDoc.mjs";
|
|
16
|
-
import { dirname, setAPI } from "./cli.mjs";
|
|
17
|
-
|
|
18
|
-
export { build, dirname, extract, fill, getDetectedPlatform, init, initSkills, listContentDeclaration, listContentDeclarationRows, listMissingTranslations, listMissingTranslationsWithConfig, liveSync, pull, push, pushConfig, reviewDoc, searchDoc, setAPI, startEditor, testMissingTranslations, translateDoc };
|
|
1
|
+
import{build as e}from"./build.mjs";import{startEditor as t}from"./editor.mjs";import{extract as n}from"./extract.mjs";import{listMissingTranslations as r,listMissingTranslationsWithConfig as i}from"./test/listMissingTranslations.mjs";import{testMissingTranslations as a}from"./test/test.mjs";import{fill as o}from"./fill/fill.mjs";import{findProjectRoot as s,init as c}from"./init.mjs";import{getDetectedPlatform as l,initSkills as u}from"./initSkills.mjs";import{listContentDeclaration as d,listContentDeclarationRows as f}from"./listContentDeclaration.mjs";import{liveSync as p}from"./liveSync.mjs";import{pull as m}from"./pull.mjs";import{push as h}from"./push/push.mjs";import{pushConfig as g}from"./pushConfig.mjs";import{reviewDoc as _}from"./reviewDoc/reviewDoc.mjs";import{searchDoc as v}from"./searchDoc.mjs";import{translateDoc as y}from"./translateDoc/translateDoc.mjs";import{dirname as b,setAPI as x}from"./cli.mjs";export{e as build,b as dirname,n as extract,o as fill,s as findProjectRoot,l as getDetectedPlatform,c as init,u as initSkills,d as listContentDeclaration,f as listContentDeclarationRows,r as listMissingTranslations,i as listMissingTranslationsWithConfig,p as liveSync,m as pull,h as push,g as pushConfig,_ as reviewDoc,v as searchDoc,x as setAPI,t as startEditor,a as testMissingTranslations,y as translateDoc};
|