@intlayer/chokidar 6.0.2-canary.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -66
- package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/buildIntlayerDictionary.cjs +18 -2
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -0
- package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/index.cjs +4 -4
- package/dist/cjs/buildIntlayerDictionary/index.cjs.map +1 -0
- package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/processContentDeclaration.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -0
- package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeDynamicDictionary.cjs +3 -3
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -0
- package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeFetchDictionary.cjs +2 -2
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -0
- package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeMergedDictionary.cjs +4 -4
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -0
- package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeRemoteDictionary.cjs +4 -4
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -0
- package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeUnmergedDictionary.cjs +4 -4
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -0
- package/dist/cjs/{transpiler/dictionary_to_main → createDictionaryEntryPoint}/createDictionaryEntryPoint.cjs +7 -7
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -0
- package/dist/cjs/{transpiler/dictionary_to_main → createDictionaryEntryPoint}/generateDictionaryListContent.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -0
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -0
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -0
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -0
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -0
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -0
- package/dist/cjs/createDictionaryEntryPoint/index.cjs +35 -0
- package/dist/cjs/createDictionaryEntryPoint/index.cjs.map +1 -0
- package/dist/cjs/{transpiler/dictionary_to_type → createType}/createModuleAugmentation.cjs +3 -3
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -0
- package/dist/cjs/{transpiler/dictionary_to_type → createType}/createType.cjs +1 -1
- package/dist/cjs/createType/createType.cjs.map +1 -0
- package/dist/cjs/{transpiler/dictionary_to_type → createType}/index.cjs +4 -4
- package/dist/cjs/createType/index.cjs.map +1 -0
- package/dist/cjs/filterInvalidDictionaries.cjs +32 -40
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +54 -0
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -0
- package/dist/cjs/handleContentDeclarationFileChange.cjs +59 -0
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -0
- package/dist/cjs/handleUnlikedContentDeclarationFile.cjs +57 -0
- package/dist/cjs/handleUnlikedContentDeclarationFile.cjs.map +1 -0
- package/dist/cjs/index.cjs +35 -12
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +6 -3
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +8 -4
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +10 -8
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +2 -2
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
- package/dist/cjs/utils/extractErrorMessage.cjs +22 -10
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
- package/dist/cjs/utils/parallelize.cjs +139 -12
- package/dist/cjs/utils/parallelize.cjs.map +1 -1
- package/dist/cjs/utils/runParallel.cjs +77 -0
- package/dist/cjs/utils/runParallel.cjs.map +1 -0
- package/dist/cjs/watcher.cjs +89 -0
- package/dist/cjs/watcher.cjs.map +1 -0
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +770 -0
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -0
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +46 -55
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +12 -288
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/esm/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/buildIntlayerDictionary.mjs +18 -2
- package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -0
- package/dist/esm/buildIntlayerDictionary/index.mjs.map +1 -0
- package/dist/esm/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/processContentDeclaration.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/processContentDeclaration.mjs.map +1 -0
- package/dist/esm/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeDynamicDictionary.mjs +3 -3
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -0
- package/dist/esm/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeFetchDictionary.mjs +2 -2
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs.map +1 -0
- package/dist/esm/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeMergedDictionary.mjs +4 -4
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -0
- package/dist/esm/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeRemoteDictionary.mjs +4 -4
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs.map +1 -0
- package/dist/esm/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeUnmergedDictionary.mjs +4 -4
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -0
- package/dist/esm/{transpiler/dictionary_to_main → createDictionaryEntryPoint}/createDictionaryEntryPoint.mjs +7 -7
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs.map +1 -0
- package/dist/esm/{transpiler/dictionary_to_main → createDictionaryEntryPoint}/generateDictionaryListContent.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/generateDictionaryListContent.mjs.map +1 -0
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs.map +1 -0
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs.map +1 -0
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs.map +1 -0
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs.map +1 -0
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs.map +1 -0
- package/dist/esm/createDictionaryEntryPoint/index.mjs +8 -0
- package/dist/esm/createDictionaryEntryPoint/index.mjs.map +1 -0
- package/dist/esm/{transpiler/dictionary_to_type → createType}/createModuleAugmentation.mjs +3 -3
- package/dist/esm/createType/createModuleAugmentation.mjs.map +1 -0
- package/dist/esm/{transpiler/dictionary_to_type → createType}/createType.mjs +1 -1
- package/dist/esm/createType/createType.mjs.map +1 -0
- package/dist/esm/createType/index.mjs.map +1 -0
- package/dist/esm/filterInvalidDictionaries.mjs +29 -28
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs +30 -0
- package/dist/esm/handleAdditionalContentDeclarationFile.mjs.map +1 -0
- package/dist/esm/handleContentDeclarationFileChange.mjs +35 -0
- package/dist/esm/handleContentDeclarationFileChange.mjs.map +1 -0
- package/dist/esm/handleUnlikedContentDeclarationFile.mjs +33 -0
- package/dist/esm/handleUnlikedContentDeclarationFile.mjs.map +1 -0
- package/dist/esm/index.mjs +29 -14
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/listDictionariesPath.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +10 -4
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +12 -5
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs.map +1 -1
- package/dist/esm/prepareIntlayer.mjs +8 -9
- package/dist/esm/prepareIntlayer.mjs.map +1 -1
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs +2 -2
- package/dist/esm/reduceDictionaryContent/reduceDictionaryContent.mjs.map +1 -1
- package/dist/esm/utils/extractErrorMessage.mjs +22 -10
- package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
- package/dist/esm/utils/parallelize.mjs +137 -1
- package/dist/esm/utils/parallelize.mjs.map +1 -1
- package/dist/esm/utils/runParallel.mjs +43 -0
- package/dist/esm/utils/runParallel.mjs.map +1 -0
- package/dist/esm/watcher.mjs +67 -0
- package/dist/esm/watcher.mjs.map +1 -0
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +751 -0
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs.map +1 -0
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +47 -56
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +15 -279
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/types/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/buildIntlayerDictionary.d.ts +1 -1
- package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/index.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -0
- package/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts.map +1 -0
- package/dist/types/createDictionaryEntryPoint/index.d.ts +8 -0
- package/dist/types/createDictionaryEntryPoint/index.d.ts.map +1 -0
- package/dist/types/createType/createModuleAugmentation.d.ts.map +1 -0
- package/dist/types/createType/createType.d.ts.map +1 -0
- package/dist/types/createType/index.d.ts.map +1 -0
- package/dist/types/filterInvalidDictionaries.d.ts +3 -1
- package/dist/types/filterInvalidDictionaries.d.ts.map +1 -1
- package/dist/types/handleAdditionalContentDeclarationFile.d.ts +3 -0
- package/dist/types/handleAdditionalContentDeclarationFile.d.ts.map +1 -0
- package/dist/types/handleContentDeclarationFileChange.d.ts +3 -0
- package/dist/types/handleContentDeclarationFileChange.d.ts.map +1 -0
- package/dist/types/handleUnlikedContentDeclarationFile.d.ts +3 -0
- package/dist/types/handleUnlikedContentDeclarationFile.d.ts.map +1 -0
- package/dist/types/index.d.ts +12 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/listDictionariesPath.d.ts +5 -0
- package/dist/types/listDictionariesPath.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts +1 -1
- package/dist/types/loadDictionaries/loadContentDeclaration.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +2 -1
- package/dist/types/loadDictionaries/loadLocalDictionaries.d.ts.map +1 -1
- package/dist/types/prepareIntlayer.d.ts +1 -1
- package/dist/types/prepareIntlayer.d.ts.map +1 -1
- package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts +1 -1
- package/dist/types/reduceDictionaryContent/reduceDictionaryContent.d.ts.map +1 -1
- package/dist/types/utils/extractErrorMessage.d.ts.map +1 -1
- package/dist/types/utils/parallelize.d.ts +12 -0
- package/dist/types/utils/parallelize.d.ts.map +1 -1
- package/dist/types/utils/runParallel.d.ts +11 -0
- package/dist/types/utils/runParallel.d.ts.map +1 -0
- package/dist/types/watcher.d.ts +12 -0
- package/dist/types/watcher.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts +9 -0
- package/dist/types/writeContentDeclaration/transformJSFile.d.ts.map +1 -0
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts +3 -2
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
- package/package.json +22 -27
- package/dist/cjs/chokidar/index.cjs +0 -23
- package/dist/cjs/chokidar/index.cjs.map +0 -1
- package/dist/cjs/chokidar/watcher.cjs +0 -157
- package/dist/cjs/chokidar/watcher.cjs.map +0 -1
- package/dist/cjs/getBuiltDictionariesPath.cjs.map +0 -1
- package/dist/cjs/getBuiltDynamicDictionariesPath.cjs.map +0 -1
- package/dist/cjs/getBuiltFetchDictionariesPath.cjs.map +0 -1
- package/dist/cjs/getBuiltRemoteDictionariesPath.cjs.map +0 -1
- package/dist/cjs/getBuiltUnmergedDictionariesPath.cjs.map +0 -1
- package/dist/cjs/reduceDictionaryContent/buildMask.cjs +0 -49
- package/dist/cjs/reduceDictionaryContent/buildMask.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryEntryPoint.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs +0 -25
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs.map +0 -1
- package/dist/cjs/transpiler/dictionary_to_type/index.cjs.map +0 -1
- package/dist/cjs/transpiler/intlayer_dictionary/buildIntlayerDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/intlayer_dictionary/index.cjs.map +0 -1
- package/dist/cjs/transpiler/intlayer_dictionary/processContentDeclaration.cjs.map +0 -1
- package/dist/cjs/transpiler/intlayer_dictionary/writeDynamicDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/intlayer_dictionary/writeFetchDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/intlayer_dictionary/writeMergedDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/intlayer_dictionary/writeRemoteDictionary.cjs.map +0 -1
- package/dist/cjs/transpiler/intlayer_dictionary/writeUnmergedDictionary.cjs.map +0 -1
- package/dist/esm/chokidar/index.mjs +0 -2
- package/dist/esm/chokidar/index.mjs.map +0 -1
- package/dist/esm/chokidar/watcher.mjs +0 -135
- package/dist/esm/chokidar/watcher.mjs.map +0 -1
- package/dist/esm/getBuiltDictionariesPath.mjs.map +0 -1
- package/dist/esm/getBuiltDynamicDictionariesPath.mjs.map +0 -1
- package/dist/esm/getBuiltFetchDictionariesPath.mjs.map +0 -1
- package/dist/esm/getBuiltRemoteDictionariesPath.mjs.map +0 -1
- package/dist/esm/getBuiltUnmergedDictionariesPath.mjs.map +0 -1
- package/dist/esm/reduceDictionaryContent/buildMask.mjs +0 -24
- package/dist/esm/reduceDictionaryContent/buildMask.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryEntryPoint.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_main/index.mjs +0 -3
- package/dist/esm/transpiler/dictionary_to_main/index.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs.map +0 -1
- package/dist/esm/transpiler/dictionary_to_type/index.mjs.map +0 -1
- package/dist/esm/transpiler/intlayer_dictionary/buildIntlayerDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/intlayer_dictionary/index.mjs.map +0 -1
- package/dist/esm/transpiler/intlayer_dictionary/processContentDeclaration.mjs.map +0 -1
- package/dist/esm/transpiler/intlayer_dictionary/writeDynamicDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/intlayer_dictionary/writeFetchDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/intlayer_dictionary/writeMergedDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/intlayer_dictionary/writeRemoteDictionary.mjs.map +0 -1
- package/dist/esm/transpiler/intlayer_dictionary/writeUnmergedDictionary.mjs.map +0 -1
- package/dist/types/chokidar/index.d.ts +0 -2
- package/dist/types/chokidar/index.d.ts.map +0 -1
- package/dist/types/chokidar/watcher.d.ts +0 -14
- package/dist/types/chokidar/watcher.d.ts.map +0 -1
- package/dist/types/getBuiltDictionariesPath.d.ts.map +0 -1
- package/dist/types/getBuiltDynamicDictionariesPath.d.ts.map +0 -1
- package/dist/types/getBuiltFetchDictionariesPath.d.ts.map +0 -1
- package/dist/types/getBuiltRemoteDictionariesPath.d.ts.map +0 -1
- package/dist/types/getBuiltUnmergedDictionariesPath.d.ts.map +0 -1
- package/dist/types/reduceDictionaryContent/buildMask.d.ts +0 -5
- package/dist/types/reduceDictionaryContent/buildMask.d.ts.map +0 -1
- package/dist/types/transpiler/dictionary_to_main/createDictionaryEntryPoint.d.ts.map +0 -1
- package/dist/types/transpiler/dictionary_to_main/generateDictionaryListContent.d.ts.map +0 -1
- package/dist/types/transpiler/dictionary_to_main/index.d.ts +0 -3
- package/dist/types/transpiler/dictionary_to_main/index.d.ts.map +0 -1
- package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts.map +0 -1
- package/dist/types/transpiler/dictionary_to_type/createType.d.ts.map +0 -1
- package/dist/types/transpiler/dictionary_to_type/index.d.ts.map +0 -1
- package/dist/types/transpiler/intlayer_dictionary/buildIntlayerDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/intlayer_dictionary/index.d.ts.map +0 -1
- package/dist/types/transpiler/intlayer_dictionary/processContentDeclaration.d.ts.map +0 -1
- package/dist/types/transpiler/intlayer_dictionary/writeDynamicDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/intlayer_dictionary/writeFetchDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/intlayer_dictionary/writeMergedDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/intlayer_dictionary/writeRemoteDictionary.d.ts.map +0 -1
- package/dist/types/transpiler/intlayer_dictionary/writeUnmergedDictionary.d.ts.map +0 -1
- /package/dist/cjs/{getBuiltDictionariesPath.cjs → createDictionaryEntryPoint/getBuiltDictionariesPath.cjs} +0 -0
- /package/dist/cjs/{getBuiltDynamicDictionariesPath.cjs → createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs} +0 -0
- /package/dist/cjs/{getBuiltFetchDictionariesPath.cjs → createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs} +0 -0
- /package/dist/cjs/{getBuiltRemoteDictionariesPath.cjs → createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs} +0 -0
- /package/dist/cjs/{getBuiltUnmergedDictionariesPath.cjs → createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs} +0 -0
- /package/dist/esm/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/index.mjs +0 -0
- /package/dist/esm/{getBuiltDictionariesPath.mjs → createDictionaryEntryPoint/getBuiltDictionariesPath.mjs} +0 -0
- /package/dist/esm/{getBuiltDynamicDictionariesPath.mjs → createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs} +0 -0
- /package/dist/esm/{getBuiltFetchDictionariesPath.mjs → createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs} +0 -0
- /package/dist/esm/{getBuiltRemoteDictionariesPath.mjs → createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs} +0 -0
- /package/dist/esm/{getBuiltUnmergedDictionariesPath.mjs → createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs} +0 -0
- /package/dist/esm/{transpiler/dictionary_to_type → createType}/index.mjs +0 -0
- /package/dist/types/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/index.d.ts +0 -0
- /package/dist/types/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/processContentDeclaration.d.ts +0 -0
- /package/dist/types/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeDynamicDictionary.d.ts +0 -0
- /package/dist/types/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeFetchDictionary.d.ts +0 -0
- /package/dist/types/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeMergedDictionary.d.ts +0 -0
- /package/dist/types/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeRemoteDictionary.d.ts +0 -0
- /package/dist/types/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeUnmergedDictionary.d.ts +0 -0
- /package/dist/types/{transpiler/dictionary_to_main → createDictionaryEntryPoint}/createDictionaryEntryPoint.d.ts +0 -0
- /package/dist/types/{transpiler/dictionary_to_main → createDictionaryEntryPoint}/generateDictionaryListContent.d.ts +0 -0
- /package/dist/types/{getBuiltDictionariesPath.d.ts → createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts} +0 -0
- /package/dist/types/{getBuiltDynamicDictionariesPath.d.ts → createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts} +0 -0
- /package/dist/types/{getBuiltFetchDictionariesPath.d.ts → createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts} +0 -0
- /package/dist/types/{getBuiltRemoteDictionariesPath.d.ts → createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts} +0 -0
- /package/dist/types/{getBuiltUnmergedDictionariesPath.d.ts → createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts} +0 -0
- /package/dist/types/{transpiler/dictionary_to_type → createType}/createModuleAugmentation.d.ts +0 -0
- /package/dist/types/{transpiler/dictionary_to_type → createType}/createType.d.ts +0 -0
- /package/dist/types/{transpiler/dictionary_to_type → createType}/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,93 +1,276 @@
|
|
|
1
|
-
<
|
|
2
|
-
<a href="https://intlayer.org">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://intlayer.org" rel="">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.png" width="60%" alt="Intlayer Logo" />
|
|
4
4
|
</a>
|
|
5
|
-
</
|
|
5
|
+
</p>
|
|
6
6
|
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
<h1 align="center">
|
|
8
|
+
<strong> Intlayer : an Open-source, per-component i18n toolkit with AI-powered translation & CMS.</strong>
|
|
9
|
+
</h1>
|
|
10
|
+
|
|
11
|
+
<br />
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">Docs</a> •
|
|
15
|
+
<a href="https://intlayer.org/doc/environment/nextjs" rel="">Next.js</a> •
|
|
16
|
+
<a href="https://intlayer.org/doc/environment/vite-and-react" rel="">React + Vite</a> •
|
|
17
|
+
<a href="https://intlayer.org/doc/concept/cms" rel="">CMS</a> •
|
|
18
|
+
<a href="https://discord.gg/7uxamYVeCk" rel="noopener noreferrer nofollow">Discord</a>
|
|
19
|
+
</p>
|
|
20
|
+
<p align="center" style="margin-top:15px;">
|
|
21
|
+
<a href="https://www.npmjs.com/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/intlayer?style=for-the-badge&labelColor=FFFFFF&color=000000&logoColor=FFFFFF" alt="npm version" height="24"/></a>
|
|
22
|
+
<a href="https://github.com/aymericzip/intlayer/stargazers" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/stars/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logo=github&logoColor=FFD700" alt="GitHub Stars" height="24"/></a>
|
|
23
|
+
<a href="https://www.npmjs.org/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/dm/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000" alt="monthly downloads" height="24"/></a>
|
|
24
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/LICENSE" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/license/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000" alt="license"/></a>
|
|
25
|
+
<a href="https://github.com/aymericzip/intlayer/commits/main" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/last-commit/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000" alt="last commit"/>
|
|
26
|
+
</a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
32
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
33
|
+
</a>
|
|
34
|
+
|
|
35
|
+
## What is Intlayer?
|
|
36
|
+
|
|
37
|
+
Most i18n libraries are either too complex, too rigid, or not built for modern frameworks.
|
|
38
|
+
|
|
39
|
+
Intlayer is a **modern i18n solution** for web and mobile apps.
|
|
40
|
+
It’s framework-agnostic, **AI-powered**, and includes a free **CMS & visual editor**.
|
|
41
|
+
|
|
42
|
+
With **per-locale content files**, **TypeScript autocompletion**, **tree-shakable dictionaries**, and **CI/CD integration**, Intlayer makes internationalization **faster, cleaner, and smarter**.
|
|
43
|
+
|
|
44
|
+
## Keys benefits of Intlayer:
|
|
45
|
+
|
|
46
|
+
| Feature | Description |
|
|
47
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
|
|
49
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.png?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
|
|
50
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
|
|
51
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
52
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
53
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
|
|
54
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
|
|
55
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
|
|
56
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
57
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
|
|
58
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.png?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
|
|
59
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.png?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
|
|
60
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.png?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
61
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
|
|
62
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
|
|
63
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.png?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, builting your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
|
|
64
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, and react-intl. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 📦 Installation
|
|
69
|
+
|
|
70
|
+
Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
|
|
71
|
+
|
|
72
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
73
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
74
|
+
</a>
|
|
26
75
|
|
|
27
|
-
|
|
76
|
+
```bash
|
|
77
|
+
npm install intlayer react-intlayer
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
⚡ Quick Start (Next.js)
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// intlayer.config.ts
|
|
84
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
85
|
+
|
|
86
|
+
const config: IntlayerConfig = {
|
|
87
|
+
internationalization: {
|
|
88
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
89
|
+
defaultLocale: Locales.ENGLISH,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default config;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
// app/home.content.ts
|
|
98
|
+
import { t, type Dictionary } from "intlayer";
|
|
99
|
+
|
|
100
|
+
const content = {
|
|
101
|
+
key: "home",
|
|
102
|
+
content: {
|
|
103
|
+
title: t({
|
|
104
|
+
en: "Home",
|
|
105
|
+
fr: "Accueil",
|
|
106
|
+
es: "Inicio",
|
|
107
|
+
}),
|
|
108
|
+
},
|
|
109
|
+
} satisfies Dictionary;
|
|
110
|
+
|
|
111
|
+
export default content;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
// app/page.tsx
|
|
116
|
+
import { useIntlayer } from "react-intlayer";
|
|
117
|
+
|
|
118
|
+
const HomePage = () => {
|
|
119
|
+
const { title } = useIntlayer("home");
|
|
120
|
+
|
|
121
|
+
return <h1>{title}</h1>;
|
|
122
|
+
};
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
<a href="https://intlayer.org/doc/environment/nextjs"> Get the full guide → </a>
|
|
126
|
+
|
|
127
|
+
## 🎥 Live tutorial on YouTube
|
|
128
|
+
|
|
129
|
+
[](https://youtu.be/e_PPG7PTqGU?si=GyU_KpVhr61razRw)
|
|
130
|
+
|
|
131
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
132
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
133
|
+
</a>
|
|
134
|
+
|
|
135
|
+
## Table of Contents
|
|
136
|
+
|
|
137
|
+
Explore our comprehensive documentation to get started with Intlayer and learn how to integrate it into your projects.
|
|
138
|
+
|
|
139
|
+
<details open>
|
|
140
|
+
<summary style="font-size:16px; font-weight:bold;">📘 Get Started</summary>
|
|
141
|
+
<ul>
|
|
142
|
+
<li><a href="https://intlayer.org/doc/why" rel=''>Why Intlayer?</a></li>
|
|
143
|
+
<li><a href="https://intlayer.org/doc" rel=''>Introduction</a></li>
|
|
144
|
+
</ul>
|
|
145
|
+
</details>
|
|
146
|
+
|
|
147
|
+
<details>
|
|
148
|
+
<summary style="font-size:16px; font-weight:bold;">⚙️ Concept</summary>
|
|
149
|
+
<ul>
|
|
150
|
+
<li><a href="https://intlayer.org/doc/concept/how-works-intlayer" rel=''>How Intlayer Works</a></li>
|
|
151
|
+
<li><a href="https://intlayer.org/doc/concept/configuration" rel=''>Configuration</a></li>
|
|
152
|
+
<li><a href="https://intlayer.org/doc/concept/cli" rel=''>Intlayer CLI</a></li>
|
|
153
|
+
<li><a href="https://intlayer.org/doc/concept/editor" rel=''>Intlayer Editor</a></li>
|
|
154
|
+
<li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
|
|
155
|
+
<li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
|
|
156
|
+
<ul>
|
|
157
|
+
<li><a href="https://intlayer.org/doc/concept/content/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
|
|
158
|
+
<li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
|
|
159
|
+
<li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
|
|
160
|
+
<li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
|
|
161
|
+
<li><a href="https://intlayer.org/doc/concept/content/nesting" rel=''>Nesting</a></li>
|
|
162
|
+
<li><a href="https://intlayer.org/doc/concept/content/markdown" rel=''>Markdown</a></li>
|
|
163
|
+
<li><a href="https://intlayer.org/doc/concept/content/function-fetching" rel=''>Function Fetching</a></li>
|
|
164
|
+
<li><a href="https://intlayer.org/doc/concept/content/insertion" rel=''>Insertion</a></li>
|
|
165
|
+
<li><a href="https://intlayer.org/doc/concept/content/file" rel=''>File</a></li>
|
|
166
|
+
</ul>
|
|
167
|
+
</li>
|
|
168
|
+
</ul>
|
|
169
|
+
</details>
|
|
170
|
+
|
|
171
|
+
<details open>
|
|
172
|
+
<summary style="font-size:16px; font-weight:bold;">🌐 Environment</summary>
|
|
173
|
+
<ul>
|
|
174
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs" rel=''>Intlayer with Next.js 15</a>
|
|
175
|
+
<ul>
|
|
176
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
|
|
177
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/next-with-Page-Router" rel=''>Next.js Page Router</a></li>
|
|
178
|
+
</ul>
|
|
179
|
+
</li>
|
|
180
|
+
<li><a href="https://intlayer.org/doc/environment/create-react-app" rel=''>React CRA</a></li>
|
|
181
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React</a>
|
|
182
|
+
<ul>
|
|
183
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react/react-router-v7" rel=''>React-router-v7</a></li>
|
|
184
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react/tanstack-start" rel=''>Tanstack start</a></li>
|
|
185
|
+
</ul>
|
|
186
|
+
</li>
|
|
187
|
+
<li><a href="https://intlayer.org/doc/environment/react-native-and-expo" rel=''>React Native</a></li>
|
|
188
|
+
<li><a href="https://intlayer.org/doc/environment/lynx-and-react" rel=''>Lynx + React</a></li>
|
|
189
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-svelte" rel=''>Vite + Svelte</a></li>
|
|
190
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
|
|
191
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
|
|
192
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
|
|
193
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
|
|
194
|
+
<li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
|
|
195
|
+
<li><a href="https://intlayer.org/doc/environment/express" rel=''>Express</a></li>
|
|
196
|
+
<li><a href="https://intlayer.org/doc/environment/nest" rel=''>NestJS</a></li>
|
|
197
|
+
</ul>
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
<details>
|
|
201
|
+
<summary style="font-size:16px; font-weight:bold;">📰 Blog</summary>
|
|
202
|
+
<ul>
|
|
203
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/what_is_internationalization.md" rel=''>What is i18n</a></li>
|
|
204
|
+
<li><a href="https://intlayer.org/blog/SEO-and-i18n" rel=''>i18n and SEO</a></li>
|
|
205
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-i18next" rel=''>Intlayer and i18next</a></li>
|
|
206
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-react-i18next" rel=''>Intlayer and react-intl</a></li>
|
|
207
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-intl" rel=''>Intlayer and next-intl</a></li>
|
|
208
|
+
</ul>
|
|
209
|
+
</details>
|
|
210
|
+
|
|
211
|
+
## 🌐 Readme in other languages
|
|
212
|
+
|
|
213
|
+
<p align="center">
|
|
214
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/readme.md">English</a> •
|
|
215
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/readme.md">简体中文</a> •
|
|
216
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/readme.md">Русский</a> •
|
|
217
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/readme.md">日本語</a> •
|
|
218
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/readme.md">Français</a> •
|
|
219
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/readme.md">한국어</a> •
|
|
220
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/readme.md">Español</a> •
|
|
221
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/readme.md">Deutsch</a> •
|
|
222
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/readme.md">العربية</a> •
|
|
223
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/readme.md">Italiano</a> •
|
|
224
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/readme.md">English (UK)</a> •
|
|
225
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/readme.md">Português</a> •
|
|
226
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/readme.md">हिन्दी</a> •
|
|
227
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/readme.md">Türkçe</a>
|
|
228
|
+
</p>
|
|
229
|
+
|
|
230
|
+
## 🤝 Community
|
|
231
|
+
|
|
232
|
+
Intlayer is built with and for the community and we’d love your input!
|
|
233
|
+
|
|
234
|
+
- Have a suggestion? [Open an issue](https://github.com/aymericzip/intlayer/issues)
|
|
235
|
+
- Found a bug or improvement? [Submit a PR](https://github.com/aymericzip/intlayer/pulls)
|
|
236
|
+
- Need help or want to connect? [Join our Discord](https://discord.gg/7uxamYVeCk)
|
|
237
|
+
|
|
238
|
+
You can also follow us on :
|
|
239
|
+
|
|
240
|
+
<div>
|
|
28
241
|
<br/>
|
|
29
242
|
<p align="center">
|
|
30
|
-
<a href="https://discord.gg/528mBV4N" target="blank"><img align="center"
|
|
243
|
+
<a href="https://discord.gg/528mBV4N" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
31
244
|
src="https://img.shields.io/badge/discord-5865F2.svg?style=for-the-badge&logo=discord&logoColor=white"
|
|
32
245
|
alt="Intlayer Discord" height="30"/></a>
|
|
33
|
-
<a href="https://www.linkedin.com/company/intlayerorg" target="blank"><img align="center"
|
|
246
|
+
<a href="https://www.linkedin.com/company/intlayerorg" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
34
247
|
src="https://img.shields.io/badge/linkedin-%231DA1F2.svg?style=for-the-badge&logo=linkedin&logoColor=white"
|
|
35
248
|
alt="Intlayer LinkedIn" height="30"/></a>
|
|
36
|
-
<a href="https://www.facebook.com/intlayer" target="blank"><img align="center"
|
|
249
|
+
<a href="https://www.facebook.com/intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
37
250
|
src="https://img.shields.io/badge/facebook-4267B2.svg?style=for-the-badge&logo=facebook&logoColor=white"
|
|
38
251
|
alt="Intlayer Facebook" height="30"/></a>
|
|
39
|
-
<a href="https://www.instagram.com/intlayer/" target="blank"><img align="center"
|
|
252
|
+
<a href="https://www.instagram.com/intlayer/" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
40
253
|
src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
|
|
41
254
|
alt="Intlayer Instagram" height="30"/></a>
|
|
42
|
-
<a href="https://x.com/Intlayer183096" target="blank"><img align="center"
|
|
255
|
+
<a href="https://x.com/Intlayer183096" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
43
256
|
src="https://img.shields.io/badge/x-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white"
|
|
44
257
|
alt="Intlayer X" height="30"/></a>
|
|
45
|
-
<a href="https://www.youtube.com/@intlayer" target="blank"><img align="center"
|
|
258
|
+
<a href="https://www.youtube.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
46
259
|
src="https://img.shields.io/badge/youtube-FF0000.svg?style=for-the-badge&logo=youtube&logoColor=white"
|
|
47
260
|
alt="Intlayer YouTube" height="30"/></a>
|
|
48
|
-
<a href="https://www.tiktok.com/@intlayer" target="blank"><img align="center"
|
|
261
|
+
<a href="https://www.tiktok.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
49
262
|
src="https://img.shields.io/badge/tiktok-000000.svg?style=for-the-badge&logo=tiktok&logoColor=white"
|
|
50
263
|
alt="Intlayer TikTok" height="30"/></a>
|
|
51
264
|
<br>
|
|
52
265
|
</p>
|
|
53
266
|
</div>
|
|
54
267
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
**Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, React, and Express.js.
|
|
58
|
-
|
|
59
|
-
The **`@intlayer/chokidar`** package is used to scan and build Intlayer declaration files into dictionaries using [chokidar](https://github.com/paulmillr/chokidar) and according to the [Intlayer configuration](https://intlayer.org/doc/concept/configuration).
|
|
60
|
-
|
|
61
|
-
## Usage
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
import { watch, prepareIntlayer } from "@intlayer/chokidar";
|
|
65
|
-
|
|
66
|
-
await prepareIntlayer(); // Build Intlayer dictionaries
|
|
67
|
-
|
|
68
|
-
watch({ persistent: true }); // Watch changes in the configuration files
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Installation
|
|
72
|
-
|
|
73
|
-
Install the necessary package using your preferred package manager:
|
|
74
|
-
|
|
75
|
-
```bash packageManager="npm"
|
|
76
|
-
npm install @intlayer/chokidar
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
```bash packageManager="pnpm"
|
|
80
|
-
pnpm add @intlayer/chokidar
|
|
81
|
-
```
|
|
268
|
+
### Contribution
|
|
82
269
|
|
|
83
|
-
|
|
84
|
-
yarn add @intlayer/chokidar
|
|
85
|
-
```
|
|
270
|
+
For more detailed guidelines on contributing to this project, please refer to the [`CONTRIBUTING.md`](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md) file. It contains essential information on our development process, commit message conventions, and release procedures. Your contributions are valuable to us, and we appreciate your efforts in making this project better!
|
|
86
271
|
|
|
87
|
-
|
|
272
|
+
### Thank You for the Support
|
|
88
273
|
|
|
89
|
-
|
|
90
|
-
- [Intlayer Documentation](https://intlayer.org/doc)
|
|
91
|
-
- [Intlayer GitHub](https://github.com/aymericzip/intlayer)
|
|
274
|
+
If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
|
|
92
275
|
|
|
93
|
-
|
|
276
|
+
[](https://star-history.com/#aymericzip/intlayer&Date)
|
|
@@ -22,14 +22,30 @@ __export(buildIntlayerDictionary_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(buildIntlayerDictionary_exports);
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
|
+
var import_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
|
|
25
26
|
var import_writeDynamicDictionary = require('./writeDynamicDictionary.cjs');
|
|
26
27
|
var import_writeFetchDictionary = require('./writeFetchDictionary.cjs');
|
|
27
28
|
var import_writeMergedDictionary = require('./writeMergedDictionary.cjs');
|
|
28
29
|
var import_writeUnmergedDictionary = require('./writeUnmergedDictionary.cjs');
|
|
29
|
-
const buildDictionary = async (localDictionariesEntries, configuration = (0, import_config.getConfiguration)(), formats = ["cjs", "esm"]) => {
|
|
30
|
+
const buildDictionary = async (localDictionariesEntries, configuration = (0, import_config.getConfiguration)(), formats = ["cjs", "esm"], importOtherDictionaries = true) => {
|
|
30
31
|
const { importMode } = configuration.build;
|
|
32
|
+
let unmergedDictionariesToUpdate = [
|
|
33
|
+
...localDictionariesEntries
|
|
34
|
+
];
|
|
35
|
+
if (importOtherDictionaries) {
|
|
36
|
+
const prevUnmergedDictionaries = (0, import_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
|
|
37
|
+
for (const dictionaryToWrite of localDictionariesEntries) {
|
|
38
|
+
const allPrebuiltUnmergedDictionaries = prevUnmergedDictionaries[dictionaryToWrite.key];
|
|
39
|
+
if (allPrebuiltUnmergedDictionaries?.length > 0) {
|
|
40
|
+
const otherUnmergedDictionaries = allPrebuiltUnmergedDictionaries.filter(
|
|
41
|
+
(unmergedDictionary) => unmergedDictionary.localId !== dictionaryToWrite.localId
|
|
42
|
+
);
|
|
43
|
+
unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
31
47
|
const unmergedDictionaries = await (0, import_writeUnmergedDictionary.writeUnmergedDictionaries)(
|
|
32
|
-
|
|
48
|
+
unmergedDictionariesToUpdate,
|
|
33
49
|
configuration
|
|
34
50
|
);
|
|
35
51
|
const mergedDictionaries = await (0, import_writeMergedDictionary.writeMergedDictionaries)(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/buildIntlayerDictionary/buildIntlayerDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport {\n LocalizedDictionaryOutput,\n writeDynamicDictionary,\n} from './writeDynamicDictionary';\nimport { writeFetchDictionary } from './writeFetchDictionary';\nimport { writeMergedDictionaries } from './writeMergedDictionary';\nimport { writeUnmergedDictionaries } from './writeUnmergedDictionary';\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const buildDictionary = async (\n localDictionariesEntries: Dictionary[],\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm'],\n importOtherDictionaries = true\n) => {\n const { importMode } = configuration.build;\n\n let unmergedDictionariesToUpdate: Dictionary[] = [\n ...localDictionariesEntries,\n ];\n\n if (importOtherDictionaries) {\n const prevUnmergedDictionaries: Record<string, Dictionary[]> =\n getUnmergedDictionaries(configuration);\n\n // Reinsert other dictionaries with the same key to avoid merging errors\n for (const dictionaryToWrite of localDictionariesEntries) {\n const allPrebuiltUnmergedDictionaries =\n prevUnmergedDictionaries[dictionaryToWrite.key];\n\n if (allPrebuiltUnmergedDictionaries?.length > 0) {\n // Do not add the same dictionary again by filtering out the one with the same localId\n const otherUnmergedDictionaries =\n allPrebuiltUnmergedDictionaries.filter(\n (unmergedDictionary) =>\n unmergedDictionary.localId !== dictionaryToWrite.localId\n );\n\n unmergedDictionariesToUpdate.push(...otherUnmergedDictionaries);\n }\n }\n }\n\n const unmergedDictionaries = await writeUnmergedDictionaries(\n unmergedDictionariesToUpdate,\n configuration\n );\n\n const mergedDictionaries = await writeMergedDictionaries(\n unmergedDictionaries,\n configuration\n );\n\n let dynamicDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (importMode === 'dynamic' || importMode === 'live') {\n dynamicDictionaries = await writeDynamicDictionary(\n mergedDictionaries,\n configuration,\n formats\n );\n }\n\n let fetchDictionaries: LocalizedDictionaryOutput | null = null;\n\n if (importMode === 'live') {\n fetchDictionaries = await writeFetchDictionary(\n dynamicDictionaries!,\n configuration,\n formats\n );\n }\n\n return {\n unmergedDictionaries,\n mergedDictionaries,\n dynamicDictionaries,\n fetchDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,yCAAwC;AACxC,oCAGO;AACP,kCAAqC;AACrC,mCAAwC;AACxC,qCAA0C;AAKnC,MAAM,kBAAkB,OAC7B,0BACA,oBAAgB,gCAAiB,GACjC,UAA6B,CAAC,OAAO,KAAK,GAC1C,0BAA0B,SACvB;AACH,QAAM,EAAE,WAAW,IAAI,cAAc;AAErC,MAAI,+BAA6C;AAAA,IAC/C,GAAG;AAAA,EACL;AAEA,MAAI,yBAAyB;AAC3B,UAAM,+BACJ,4DAAwB,aAAa;AAGvC,eAAW,qBAAqB,0BAA0B;AACxD,YAAM,kCACJ,yBAAyB,kBAAkB,GAAG;AAEhD,UAAI,iCAAiC,SAAS,GAAG;AAE/C,cAAM,4BACJ,gCAAgC;AAAA,UAC9B,CAAC,uBACC,mBAAmB,YAAY,kBAAkB;AAAA,QACrD;AAEF,qCAA6B,KAAK,GAAG,yBAAyB;AAAA,MAChE;AAAA,IACF;AAAA,EACF;AAEA,QAAM,uBAAuB,UAAM;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,qBAAqB,UAAM;AAAA,IAC/B;AAAA,IACA;AAAA,EACF;AAEA,MAAI,sBAAwD;AAE5D,MAAI,eAAe,aAAa,eAAe,QAAQ;AACrD,0BAAsB,UAAM;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,oBAAsD;AAE1D,MAAI,eAAe,QAAQ;AACzB,wBAAoB,UAAM;AAAA,MACxB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -13,10 +13,10 @@ 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(
|
|
19
|
-
__reExport(
|
|
16
|
+
var buildIntlayerDictionary_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(buildIntlayerDictionary_exports);
|
|
18
|
+
__reExport(buildIntlayerDictionary_exports, require('./buildIntlayerDictionary.cjs'), module.exports);
|
|
19
|
+
__reExport(buildIntlayerDictionary_exports, require('./processContentDeclaration.cjs'), module.exports);
|
|
20
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
21
21
|
0 && (module.exports = {
|
|
22
22
|
...require('./buildIntlayerDictionary.cjs'),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/buildIntlayerDictionary/index.ts"],"sourcesContent":["export * from './buildIntlayerDictionary';\nexport * from './processContentDeclaration';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4CAAc,sCAAd;AACA,4CAAc,wCADd;","names":[]}
|
|
@@ -22,7 +22,7 @@ __export(processContentDeclaration_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(processContentDeclaration_exports);
|
|
24
24
|
var import_client = require("@intlayer/config/client");
|
|
25
|
-
var import_resolveObjectPromises = require('
|
|
25
|
+
var import_resolveObjectPromises = require('../utils/resolveObjectPromises.cjs');
|
|
26
26
|
const processContentDeclaration = async (contentDeclaration) => {
|
|
27
27
|
try {
|
|
28
28
|
const content = await (0, import_resolveObjectPromises.resolveObjectPromises)(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/buildIntlayerDictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport { resolveObjectPromises } from '../utils/resolveObjectPromises';\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary\n): Promise<Dictionary | undefined> => {\n try {\n const content = (await resolveObjectPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n return {\n ...contentDeclaration,\n content,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AAEvB,mCAAsC;AAK/B,MAAM,4BAA4B,OACvC,uBACoC;AACpC,MAAI;AACF,UAAM,UAAW,UAAM;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,8BAAO,OAAO;AAAA,MACZ,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -26,9 +26,9 @@ var import_config = require("@intlayer/config");
|
|
|
26
26
|
var import_core = require("@intlayer/core");
|
|
27
27
|
var import_promises = require("fs/promises");
|
|
28
28
|
var import_path = require("path");
|
|
29
|
-
var import_parallelize = require('
|
|
30
|
-
var import_writeFileIfChanged = require('
|
|
31
|
-
var import_writeJsonIfChanged = require('
|
|
29
|
+
var import_parallelize = require('../utils/parallelize.cjs');
|
|
30
|
+
var import_writeFileIfChanged = require('../writeFileIfChanged.cjs');
|
|
31
|
+
var import_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
|
|
32
32
|
const generateDictionaryEntryPoint = (localedDictionariesPathsRecord, format = "esm", configuration = (0, import_config.getConfiguration)()) => {
|
|
33
33
|
const { dynamicDictionariesDir } = configuration.content;
|
|
34
34
|
let content = "";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"sourcesContent":["import {\n colorizePath,\n getConfiguration,\n Locales,\n normalizePath,\n} from '@intlayer/config';\nimport { getLocalisedContent, type Dictionary } from '@intlayer/core';\nimport { mkdir } from 'fs/promises';\nimport { relative, resolve } from 'path';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport { MergedDictionaryOutput } from './writeMergedDictionary';\n\nexport type DictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type LocalizedDictionaryResult = Partial<\n Record<Locales, DictionaryResult>\n>;\n\nexport type LocalizedDictionaryOutput = Record<\n string,\n LocalizedDictionaryResult\n>;\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { dynamicDictionariesDir } = configuration.content;\n\n let content = '';\n\n // Format Dictionary Map - map locales to functions\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n // The following filter/sort preserve determinism of the generated map\n // when files are built in parallel or across different Node versions.\n .filter((entry): entry is [string, DictionaryResult] => Boolean(entry[1]))\n .sort(([a], [b]) => String(a).localeCompare(String(b)))\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(dynamicDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)`;\n }\n\n return ` '${locale}': () => Promise.resolve(require('./${relativePath}'))`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dynamic_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeDynamicDictionary = async (\n mergedDictionaries: MergedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { locales, defaultLocale } = configuration.internationalization;\n const { dynamicDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dynamicDictionariesDir), { recursive: true });\n\n let resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n Object.entries(mergedDictionaries).sort(([a], [b]) =>\n String(a).localeCompare(String(b))\n ),\n async ([key, dictionaryEntry]) => {\n if (key === 'undefined') return;\n\n let localedDictionariesPathsRecord: LocalizedDictionaryResult = {};\n\n await parallelize(locales, async (locale) => {\n const localizedDictionary = {\n ...dictionaryEntry.dictionary,\n locale,\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n content: getLocalisedContent(\n JSON.parse(JSON.stringify(dictionaryEntry.dictionary.content)),\n locale,\n { dictionaryKey: key, keyPath: [] },\n defaultLocale\n ) as any,\n };\n\n const outputFileName = `${key}.${locale}.json`;\n const resultFilePath = resolve(dynamicDictionariesDir, outputFileName);\n\n // Write the localized dictionary\n await writeJsonIfChanged(resultFilePath, localizedDictionary).catch(\n (err) => {\n console.error(`Error creating localized ${outputFileName}:`, err);\n }\n );\n\n localedDictionariesPathsRecord[locale] = {\n dictionaryPath: resultFilePath,\n dictionary: localizedDictionary,\n };\n });\n\n resultDictionariesPaths[key] = localedDictionariesPathsRecord;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(dynamicDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating dynamic ${colorizePath(resolve(dynamicDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAKO;AACP,kBAAqD;AACrD,sBAAsB;AACtB,kBAAkC;AAClC,yBAA4B;AAC5B,gCAAmC;AACnC,gCAAmC;AAoB5B,MAAM,+BAA+B,CAC1C,gCACA,SAAwB,OACxB,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,uBAAuB,IAAI,cAAc;AAEjD,MAAI,UAAU;AAGd,QAAM,yBAAiC,OAAO;AAAA,IAC5C;AAAA,EACF,EAGG,OAAO,CAAC,UAA+C,QAAQ,MAAM,CAAC,CAAC,CAAC,EACxE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,OAAO,CAAC,EAAE,cAAc,OAAO,CAAC,CAAC,CAAC,EACrD,IAAI,CAAC,CAAC,QAAQ,UAAU,MAAM;AAC7B,UAAM,mBAAe;AAAA,UACnB,sBAAS,wBAAwB,WAAW,cAAc;AAAA,IAC5D;AAEA,QAAI,WAAW,OAAO;AACpB,aAAO,MAAM,MAAM,sBAAsB,YAAY;AAAA,IACvD;AAEA,WAAO,MAAM,MAAM,uCAAuC,YAAY;AAAA,EACxE,CAAC,EACA,KAAK,KAAK;AAEb,aAAW;AAAA,EAAsB,sBAAsB;AAAA;AAAA;AAEvD,MAAI,WAAW,MAAO,YAAW;AAAA;AACjC,MAAI,WAAW,MAAO,YAAW;AAAA;AAEjC,SAAO;AACT;AAkBO,MAAM,yBAAyB,OACpC,oBACA,oBAAgB,gCAAiB,GACjC,UAA6B,CAAC,OAAO,KAAK,MACH;AACvC,QAAM,EAAE,SAAS,cAAc,IAAI,cAAc;AACjD,QAAM,EAAE,uBAAuB,IAAI,cAAc;AAGjD,YAAM,2BAAM,qBAAQ,sBAAsB,GAAG,EAAE,WAAW,KAAK,CAAC;AAEhE,MAAI,0BAAqD,CAAC;AAG1D,YAAM;AAAA,IACJ,OAAO,QAAQ,kBAAkB,EAAE;AAAA,MAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAC9C,OAAO,CAAC,EAAE,cAAc,OAAO,CAAC,CAAC;AAAA,IACnC;AAAA,IACA,OAAO,CAAC,KAAK,eAAe,MAAM;AAChC,UAAI,QAAQ,YAAa;AAEzB,UAAI,iCAA4D,CAAC;AAEjE,gBAAM,gCAAY,SAAS,OAAO,WAAW;AAC3C,cAAM,sBAAsB;AAAA,UAC1B,GAAG,gBAAgB;AAAA,UACnB;AAAA;AAAA,UAEA,aAAS;AAAA,YACP,KAAK,MAAM,KAAK,UAAU,gBAAgB,WAAW,OAAO,CAAC;AAAA,YAC7D;AAAA,YACA,EAAE,eAAe,KAAK,SAAS,CAAC,EAAE;AAAA,YAClC;AAAA,UACF;AAAA,QACF;AAEA,cAAM,iBAAiB,GAAG,GAAG,IAAI,MAAM;AACvC,cAAM,qBAAiB,qBAAQ,wBAAwB,cAAc;AAGrE,kBAAM,8CAAmB,gBAAgB,mBAAmB,EAAE;AAAA,UAC5D,CAAC,QAAQ;AACP,oBAAQ,MAAM,4BAA4B,cAAc,KAAK,GAAG;AAAA,UAClE;AAAA,QACF;AAEA,uCAA+B,MAAM,IAAI;AAAA,UACvC,gBAAgB;AAAA,UAChB,YAAY;AAAA,QACd;AAAA,MACF,CAAC;AAED,8BAAwB,GAAG,IAAI;AAE/B,gBAAM,gCAAY,SAAS,OAAO,WAAW;AAC3C,cAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,cAAM,UAAU;AAAA,UACd;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAEA,kBAAM;AAAA,cACJ,qBAAQ,wBAAwB,GAAG,GAAG,IAAI,SAAS,EAAE;AAAA,UACrD;AAAA,QACF,EAAE,MAAM,CAAC,QAAQ;AACf,kBAAQ;AAAA,YACN,8BAA0B,gCAAa,qBAAQ,wBAAwB,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,CAAC;AAAA,YAC9F;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/cjs/{transpiler/intlayer_dictionary → buildIntlayerDictionary}/writeFetchDictionary.cjs
RENAMED
|
@@ -25,8 +25,8 @@ module.exports = __toCommonJS(writeFetchDictionary_exports);
|
|
|
25
25
|
var import_config = require("@intlayer/config");
|
|
26
26
|
var import_promises = require("fs/promises");
|
|
27
27
|
var import_path = require("path");
|
|
28
|
-
var import_parallelize = require('
|
|
29
|
-
var import_writeFileIfChanged = require('
|
|
28
|
+
var import_parallelize = require('../utils/parallelize.cjs');
|
|
29
|
+
var import_writeFileIfChanged = require('../writeFileIfChanged.cjs');
|
|
30
30
|
const generateDictionaryEntryPoint = (localedDictionariesPathsRecord, format = "esm", configuration = (0, import_config.getConfiguration)()) => {
|
|
31
31
|
const { fetchDictionariesDir } = configuration.content;
|
|
32
32
|
const { liveSyncURL } = configuration.editor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"sourcesContent":["import {\n colorizePath,\n getConfiguration,\n normalizePath,\n} from '@intlayer/config';\nimport { mkdir } from 'fs/promises';\nimport { relative, resolve } from 'path';\nimport { parallelize } from '../utils/parallelize';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport type {\n LocalizedDictionaryOutput,\n LocalizedDictionaryResult,\n} from './writeDynamicDictionary';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryEntryPoint = (\n localedDictionariesPathsRecord: LocalizedDictionaryResult,\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { fetchDictionariesDir } = configuration.content;\n const { liveSyncURL } = configuration.editor;\n\n let content = '';\n\n const formattedDictionaryMap: string = Object.entries(\n localedDictionariesPathsRecord\n )\n .map(([locale, dictionary]) => {\n const relativePath = normalizePath(\n relative(fetchDictionariesDir, dictionary.dictionaryPath)\n );\n\n if (format === 'esm') {\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return await import('./${relativePath}', { assert: { type: 'json' }}).then(mod => mod.default)}})()`;\n }\n\n return ` '${locale}': () => (async () => { try {return await fetch('${liveSyncURL}/dictionaries/${dictionary.dictionary.key}/${locale}').then(res => res.json())} catch (_error) {return Promise.resolve(require('./${relativePath}'))}})()`;\n })\n .join(',\\n');\n\n content += `const content = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n if (format === 'esm') content += `export default content;\\n`;\n if (format === 'cjs') content += `module.exports = content;\\n`;\n\n return content;\n};\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeFetchDictionary = async (\n dynamicDictionaries: LocalizedDictionaryOutput,\n configuration = getConfiguration(),\n formats: ('cjs' | 'esm')[] = ['cjs', 'esm']\n): Promise<LocalizedDictionaryOutput> => {\n const { fetchDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(fetchDictionariesDir), { recursive: true });\n\n let resultDictionariesPaths: LocalizedDictionaryOutput = {};\n\n // Write entry points for each dictionary in parallel\n await parallelize(\n Object.entries(dynamicDictionaries),\n async ([key, localedDictionariesPathsRecord]) => {\n if (key === 'undefined') return;\n\n await parallelize(formats, async (format) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const content = generateDictionaryEntryPoint(\n localedDictionariesPathsRecord,\n format,\n configuration\n );\n\n await writeFileIfChanged(\n resolve(fetchDictionariesDir, `${key}.${extension}`),\n content\n ).catch((err) => {\n console.error(\n `Error creating fetch ${colorizePath(resolve(fetchDictionariesDir, `${key}.${extension}`))}:`,\n err\n );\n });\n });\n }\n );\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAIO;AACP,sBAAsB;AACtB,kBAAkC;AAClC,yBAA4B;AAC5B,gCAAmC;AAS5B,MAAM,+BAA+B,CAC1C,gCACA,SAAwB,OACxB,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,qBAAqB,IAAI,cAAc;AAC/C,QAAM,EAAE,YAAY,IAAI,cAAc;AAEtC,MAAI,UAAU;AAEd,QAAM,yBAAiC,OAAO;AAAA,IAC5C;AAAA,EACF,EACG,IAAI,CAAC,CAAC,QAAQ,UAAU,MAAM;AAC7B,UAAM,mBAAe;AAAA,UACnB,sBAAS,sBAAsB,WAAW,cAAc;AAAA,IAC1D;AAEA,QAAI,WAAW,OAAO;AACpB,aAAO,MAAM,MAAM,oDAAoD,WAAW,iBAAiB,WAAW,WAAW,GAAG,IAAI,MAAM,sEAAsE,YAAY;AAAA,IAC1N;AAEA,WAAO,MAAM,MAAM,oDAAoD,WAAW,iBAAiB,WAAW,WAAW,GAAG,IAAI,MAAM,iFAAiF,YAAY;AAAA,EACrO,CAAC,EACA,KAAK,KAAK;AAEb,aAAW;AAAA,EAAsB,sBAAsB;AAAA;AAAA;AAEvD,MAAI,WAAW,MAAO,YAAW;AAAA;AACjC,MAAI,WAAW,MAAO,YAAW;AAAA;AAEjC,SAAO;AACT;AAkBO,MAAM,uBAAuB,OAClC,qBACA,oBAAgB,gCAAiB,GACjC,UAA6B,CAAC,OAAO,KAAK,MACH;AACvC,QAAM,EAAE,qBAAqB,IAAI,cAAc;AAG/C,YAAM,2BAAM,qBAAQ,oBAAoB,GAAG,EAAE,WAAW,KAAK,CAAC;AAE9D,MAAI,0BAAqD,CAAC;AAG1D,YAAM;AAAA,IACJ,OAAO,QAAQ,mBAAmB;AAAA,IAClC,OAAO,CAAC,KAAK,8BAA8B,MAAM;AAC/C,UAAI,QAAQ,YAAa;AAEzB,gBAAM,gCAAY,SAAS,OAAO,WAAW;AAC3C,cAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,cAAM,UAAU;AAAA,UACd;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAEA,kBAAM;AAAA,cACJ,qBAAQ,sBAAsB,GAAG,GAAG,IAAI,SAAS,EAAE;AAAA,UACnD;AAAA,QACF,EAAE,MAAM,CAAC,QAAQ;AACf,kBAAQ;AAAA,YACN,4BAAwB,gCAAa,qBAAQ,sBAAsB,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,CAAC;AAAA,YAC1F;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -24,10 +24,10 @@ module.exports = __toCommonJS(writeMergedDictionary_exports);
|
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
25
|
var import_promises = require("fs/promises");
|
|
26
26
|
var import_path = require("path");
|
|
27
|
-
var import_mergeDictionaries = require('
|
|
28
|
-
var import_processPerLocaleDictionary = require('
|
|
29
|
-
var import_parallelize = require('
|
|
30
|
-
var import_writeJsonIfChanged = require('
|
|
27
|
+
var import_mergeDictionaries = require('../mergeDictionaries.cjs');
|
|
28
|
+
var import_processPerLocaleDictionary = require('../processPerLocaleDictionary.cjs');
|
|
29
|
+
var import_parallelize = require('../utils/parallelize.cjs');
|
|
30
|
+
var import_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
|
|
31
31
|
const writeMergedDictionaries = async (groupedDictionaries, configuration = (0, import_config.getConfiguration)()) => {
|
|
32
32
|
const { dictionariesDir } = configuration.content;
|
|
33
33
|
await (0, import_promises.mkdir)((0, import_path.resolve)(dictionariesDir), { recursive: true });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"sourcesContent":["import { colorizePath, getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\nimport { mergeDictionaries } from '../mergeDictionaries';\nimport { processPerLocaleDictionary } from '../processPerLocaleDictionary';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\nimport { UnmergedDictionaryOutput } from './writeUnmergedDictionary';\n\nexport type MergedDictionaryResult = {\n dictionaryPath: string;\n dictionary: Dictionary;\n};\n\nexport type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;\n\n/**\n * Write the merged dictionaries to the dictionariesDir\n * @param groupedDictionaries - The grouped dictionaries\n * @param configuration - The configuration\n * @returns The merged dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/dictionary/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeMergedDictionaries = async (\n groupedDictionaries: UnmergedDictionaryOutput,\n configuration = getConfiguration()\n): Promise<MergedDictionaryOutput> => {\n const { dictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionariesEntry]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n MergedDictionaryResult,\n ];\n }\n\n const multiLocaleDictionaries = dictionariesEntry.dictionaries.map(\n (dictionary) => processPerLocaleDictionary(dictionary)\n );\n\n const mergedDictionary = mergeDictionaries(multiLocaleDictionaries);\n\n const outputFileName = `${key}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, mergedDictionary).catch(\n (err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: resultFilePath,\n dictionary: mergedDictionary,\n } as MergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<readonly [string, MergedDictionaryResult]>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAE/C,sBAAsB;AACtB,kBAAwB;AACxB,+BAAkC;AAClC,wCAA2C;AAC3C,yBAA4B;AAC5B,gCAAmC;AA0B5B,MAAM,0BAA0B,OACrC,qBACA,oBAAgB,gCAAiB,MACG;AACpC,QAAM,EAAE,gBAAgB,IAAI,cAAc;AAG1C,YAAM,2BAAM,qBAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,QAAM,UAAU,UAAM;AAAA,IACpB,OAAO,QAAQ,mBAAmB;AAAA,IAClC,OAAO,CAAC,KAAK,iBAAiB,MAAM;AAClC,UAAI,QAAQ,aAAa;AACvB,eAAO;AAAA,MAIT;AAEA,YAAM,0BAA0B,kBAAkB,aAAa;AAAA,QAC7D,CAAC,mBAAe,8DAA2B,UAAU;AAAA,MACvD;AAEA,YAAM,uBAAmB,4CAAkB,uBAAuB;AAElE,YAAM,iBAAiB,GAAG,GAAG;AAC7B,YAAM,qBAAiB,qBAAQ,iBAAiB,cAAc;AAG9D,gBAAM,8CAAmB,gBAAgB,gBAAgB,EAAE;AAAA,QACzD,CAAC,QAAQ;AACP,kBAAQ;AAAA,YACN,6BAAyB,4BAAa,cAAc,CAAC;AAAA,YACrD;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,UACE,gBAAgB;AAAA,UAChB,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO;AAAA,IACZ,QAAQ,OAAO,OAAO;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -24,10 +24,10 @@ module.exports = __toCommonJS(writeRemoteDictionary_exports);
|
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
25
|
var import_promises = require("fs/promises");
|
|
26
26
|
var import_path = require("path");
|
|
27
|
-
var import_filterInvalidDictionaries = require('
|
|
28
|
-
var import_loadDictionaries = require('
|
|
29
|
-
var import_parallelize = require('
|
|
30
|
-
var import_writeJsonIfChanged = require('
|
|
27
|
+
var import_filterInvalidDictionaries = require('../filterInvalidDictionaries.cjs');
|
|
28
|
+
var import_loadDictionaries = require('../loadDictionaries/index.cjs');
|
|
29
|
+
var import_parallelize = require('../utils/parallelize.cjs');
|
|
30
|
+
var import_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
|
|
31
31
|
const writeRemoteDictionary = async (remoteDictionaries, configuration = (0, import_config.getConfiguration)()) => {
|
|
32
32
|
const { remoteDictionariesDir } = configuration.content;
|
|
33
33
|
await (0, import_promises.mkdir)((0, import_path.resolve)(remoteDictionariesDir), { recursive: true });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"sourcesContent":["import { colorizePath, getConfiguration } from '@intlayer/config';\nimport { Dictionary } from '@intlayer/core';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDistantDictionaries } from '../loadDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\n/**\n * Write the localized dictionaries to the dictionariesDir\n * @param mergedDictionaries - The merged dictionaries\n * @param configuration - The configuration\n * @returns The final dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * const finalDictionaries = await writeFinalDictionaries(unmergedDictionaries);\n * console.log(finalDictionaries);\n *\n * // .intlayer/fetch_dictionaries/home.json\n * // { key: 'home', content: { ... } },\n * ```\n */\nexport const writeRemoteDictionary = async (\n remoteDictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<Dictionary[]> => {\n const { remoteDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(remoteDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(remoteDictionaries);\n\n // Merge dictionaries with the same key and write to dictionariesDir\n await parallelize(\n filteredDictionaries.filter((dictionary) => dictionary.key !== 'undefined'),\n async (dictionary) => {\n const outputFileName = `${dictionary.key}.json`;\n const resultFilePath = resolve(remoteDictionariesDir, outputFileName);\n\n // Write the merged dictionary\n await writeJsonIfChanged(resultFilePath, dictionary).catch((err) => {\n console.error(\n `Error creating merged ${colorizePath(resultFilePath)}:`,\n err\n );\n });\n }\n );\n\n return formatDistantDictionaries(remoteDictionaries);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAE/C,sBAAsB;AACtB,kBAAwB;AACxB,uCAA0C;AAC1C,8BAA0C;AAC1C,yBAA4B;AAC5B,gCAAmC;AAkB5B,MAAM,wBAAwB,OACnC,oBACA,oBAAgB,gCAAiB,MACP;AAC1B,QAAM,EAAE,sBAAsB,IAAI,cAAc;AAGhD,YAAM,2BAAM,qBAAQ,qBAAqB,GAAG,EAAE,WAAW,KAAK,CAAC;AAE/D,QAAM,2BAAuB,4DAA0B,kBAAkB;AAGzE,YAAM;AAAA,IACJ,qBAAqB,OAAO,CAAC,eAAe,WAAW,QAAQ,WAAW;AAAA,IAC1E,OAAO,eAAe;AACpB,YAAM,iBAAiB,GAAG,WAAW,GAAG;AACxC,YAAM,qBAAiB,qBAAQ,uBAAuB,cAAc;AAGpE,gBAAM,8CAAmB,gBAAgB,UAAU,EAAE,MAAM,CAAC,QAAQ;AAClE,gBAAQ;AAAA,UACN,6BAAyB,4BAAa,cAAc,CAAC;AAAA,UACrD;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,aAAO,mDAA0B,kBAAkB;AACrD;","names":[]}
|
|
@@ -24,10 +24,10 @@ module.exports = __toCommonJS(writeUnmergedDictionary_exports);
|
|
|
24
24
|
var import_config = require("@intlayer/config");
|
|
25
25
|
var import_promises = require("fs/promises");
|
|
26
26
|
var import_path = require("path");
|
|
27
|
-
var import_filterInvalidDictionaries = require('
|
|
28
|
-
var import_orderDictionaries = require('
|
|
29
|
-
var import_parallelize = require('
|
|
30
|
-
var import_writeJsonIfChanged = require('
|
|
27
|
+
var import_filterInvalidDictionaries = require('../filterInvalidDictionaries.cjs');
|
|
28
|
+
var import_orderDictionaries = require('../orderDictionaries.cjs');
|
|
29
|
+
var import_parallelize = require('../utils/parallelize.cjs');
|
|
30
|
+
var import_writeJsonIfChanged = require('../writeJsonIfChanged.cjs');
|
|
31
31
|
const groupDictionariesByKey = (dictionaries) => dictionaries.reduce(
|
|
32
32
|
(acc, dictionary) => {
|
|
33
33
|
const key = dictionary.key;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/buildIntlayerDictionary/writeUnmergedDictionary.ts"],"sourcesContent":["import { colorizePath, getConfiguration, x } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { mkdir } from 'fs/promises';\nimport { resolve } from 'path';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { orderDictionaries } from '../orderDictionaries';\nimport { parallelize } from '../utils/parallelize';\nimport { writeJsonIfChanged } from '../writeJsonIfChanged';\n\nconst groupDictionariesByKey = (\n dictionaries: Dictionary[]\n): Record<string, Dictionary[]> =>\n dictionaries.reduce(\n (acc, dictionary) => {\n const key = dictionary.key;\n if (!acc[key]) {\n acc[key] = [];\n }\n acc[key].push(dictionary);\n return acc;\n },\n {} as Record<string, Dictionary[]>\n );\n\nexport type UnmergedDictionaryResult = {\n dictionaryPath: string;\n dictionaries: Dictionary[];\n};\n\nexport type UnmergedDictionaryOutput = Record<string, UnmergedDictionaryResult>;\n\n/**\n * Write the unmerged dictionaries to the unmergedDictionariesDir\n * @param dictionaries - The dictionaries to write\n * @param configuration - The configuration\n * @returns The grouped dictionaries\n *\n * @example\n * ```ts\n * const unmergedDictionaries = await writeUnmergedDictionaries(dictionaries);\n * console.log(unmergedDictionaries);\n *\n * // .intlayer/unmerged_dictionaries/home.json\n * // {\n * // [\n * // { key: 'home', content: { ... } },\n * // { key: 'home', content: { ... } },\n * // ],\n * // }\n * ```\n */\nexport const writeUnmergedDictionaries = async (\n dictionaries: Dictionary[],\n configuration = getConfiguration()\n): Promise<UnmergedDictionaryOutput> => {\n const { unmergedDictionariesDir } = configuration.content;\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(unmergedDictionariesDir), { recursive: true });\n\n const filteredDictionaries = filterInvalidDictionaries(dictionaries);\n\n // Group dictionaries by key and write to unmergedDictionariesDir\n const groupedDictionaries = groupDictionariesByKey(filteredDictionaries);\n\n const results = await parallelize(\n Object.entries(groupedDictionaries),\n async ([key, dictionaries]) => {\n if (key === 'undefined') {\n return undefined as unknown as readonly [\n string,\n UnmergedDictionaryResult,\n ];\n }\n\n const orderedDictionaries = orderDictionaries(\n dictionaries,\n configuration\n );\n\n const outputFileName = `${key}.json`;\n const unmergedFilePath = resolve(unmergedDictionariesDir, outputFileName);\n\n // Write the grouped dictionaries\n await writeJsonIfChanged(unmergedFilePath, orderedDictionaries).catch(\n (err) => {\n console.error(\n `${x} Error creating unmerged ${colorizePath(unmergedFilePath)}:`,\n err\n );\n }\n );\n\n return [\n key,\n {\n dictionaryPath: unmergedFilePath,\n dictionaries: dictionaries,\n } as UnmergedDictionaryResult,\n ] as const;\n }\n );\n\n return Object.fromEntries(\n results.filter(Boolean) as Array<\n readonly [string, UnmergedDictionaryResult]\n >\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAkD;AAElD,sBAAsB;AACtB,kBAAwB;AACxB,uCAA0C;AAC1C,+BAAkC;AAClC,yBAA4B;AAC5B,gCAAmC;AAEnC,MAAM,yBAAyB,CAC7B,iBAEA,aAAa;AAAA,EACX,CAAC,KAAK,eAAe;AACnB,UAAM,MAAM,WAAW;AACvB,QAAI,CAAC,IAAI,GAAG,GAAG;AACb,UAAI,GAAG,IAAI,CAAC;AAAA,IACd;AACA,QAAI,GAAG,EAAE,KAAK,UAAU;AACxB,WAAO;AAAA,EACT;AAAA,EACA,CAAC;AACH;AA6BK,MAAM,4BAA4B,OACvC,cACA,oBAAgB,gCAAiB,MACK;AACtC,QAAM,EAAE,wBAAwB,IAAI,cAAc;AAGlD,YAAM,2BAAM,qBAAQ,uBAAuB,GAAG,EAAE,WAAW,KAAK,CAAC;AAEjE,QAAM,2BAAuB,4DAA0B,YAAY;AAGnE,QAAM,sBAAsB,uBAAuB,oBAAoB;AAEvE,QAAM,UAAU,UAAM;AAAA,IACpB,OAAO,QAAQ,mBAAmB;AAAA,IAClC,OAAO,CAAC,KAAKA,aAAY,MAAM;AAC7B,UAAI,QAAQ,aAAa;AACvB,eAAO;AAAA,MAIT;AAEA,YAAM,0BAAsB;AAAA,QAC1BA;AAAA,QACA;AAAA,MACF;AAEA,YAAM,iBAAiB,GAAG,GAAG;AAC7B,YAAM,uBAAmB,qBAAQ,yBAAyB,cAAc;AAGxE,gBAAM,8CAAmB,kBAAkB,mBAAmB,EAAE;AAAA,QAC9D,CAAC,QAAQ;AACP,kBAAQ;AAAA,YACN,GAAG,eAAC,gCAA4B,4BAAa,gBAAgB,CAAC;AAAA,YAC9D;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,aAAO;AAAA,QACL;AAAA,QACA;AAAA,UACE,gBAAgB;AAAA,UAChB,cAAcA;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,OAAO;AAAA,IACZ,QAAQ,OAAO,OAAO;AAAA,EAGxB;AACF;","names":["dictionaries"]}
|