@intlayer/core 8.4.4 → 8.4.5

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.
Files changed (780) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +213 -1
  3. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +95 -1
  5. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  6. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +46 -1
  7. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +33 -1
  9. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  10. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs +27 -1
  11. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
  12. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +151 -1
  13. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  14. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +87 -1
  15. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  16. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs +60 -1
  17. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
  18. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +123 -1
  19. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  20. package/dist/cjs/deepTransformPlugins/index.cjs +32 -1
  21. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +107 -1
  22. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  23. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +65 -1
  24. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +19 -1
  26. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  27. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +56 -1
  28. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  29. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +27 -1
  30. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  31. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +24 -1
  32. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  33. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +55 -1
  34. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  35. package/dist/cjs/dictionaryManipulator/index.cjs +27 -1
  36. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +69 -1
  37. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  38. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +30 -1
  39. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  40. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +48 -1
  41. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  42. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +32 -1
  43. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  44. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +40 -1
  45. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  46. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +39 -1
  47. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  48. package/dist/cjs/formatters/compact.cjs +25 -1
  49. package/dist/cjs/formatters/compact.cjs.map +1 -1
  50. package/dist/cjs/formatters/currency.cjs +29 -1
  51. package/dist/cjs/formatters/currency.cjs.map +1 -1
  52. package/dist/cjs/formatters/date.cjs +60 -1
  53. package/dist/cjs/formatters/date.cjs.map +1 -1
  54. package/dist/cjs/formatters/index.cjs +23 -1
  55. package/dist/cjs/formatters/list.cjs +30 -1
  56. package/dist/cjs/formatters/list.cjs.map +1 -1
  57. package/dist/cjs/formatters/number.cjs +20 -1
  58. package/dist/cjs/formatters/number.cjs.map +1 -1
  59. package/dist/cjs/formatters/percentage.cjs +27 -1
  60. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  61. package/dist/cjs/formatters/relativeTime.cjs +43 -1
  62. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  63. package/dist/cjs/formatters/units.cjs +23 -1
  64. package/dist/cjs/formatters/units.cjs.map +1 -1
  65. package/dist/cjs/getStorageAttributes.cjs +134 -1
  66. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  67. package/dist/cjs/index.cjs +315 -1
  68. package/dist/cjs/interpreter/getCondition.cjs +27 -1
  69. package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
  70. package/dist/cjs/interpreter/getContent/deepTransform.cjs +42 -1
  71. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  72. package/dist/cjs/interpreter/getContent/getContent.cjs +32 -1
  73. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -0
  74. package/dist/cjs/interpreter/getContent/index.cjs +15 -1
  75. package/dist/cjs/interpreter/getContent/plugins.cjs +163 -1
  76. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -0
  77. package/dist/cjs/interpreter/getDictionary.cjs +25 -1
  78. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -0
  79. package/dist/cjs/interpreter/getEnumeration.cjs +72 -1
  80. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  81. package/dist/cjs/interpreter/getGender.cjs +38 -1
  82. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  83. package/dist/cjs/interpreter/getHTML.cjs +124 -1
  84. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  85. package/dist/cjs/interpreter/getInsertion.cjs +22 -1
  86. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  87. package/dist/cjs/interpreter/getIntlayer.cjs +41 -1
  88. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -0
  89. package/dist/cjs/interpreter/getNesting.cjs +37 -1
  90. package/dist/cjs/interpreter/getNesting.cjs.map +1 -0
  91. package/dist/cjs/interpreter/getTranslation.cjs +112 -1
  92. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  93. package/dist/cjs/interpreter/index.cjs +32 -1
  94. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +55 -1
  95. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  96. package/dist/cjs/localization/getBrowserLocale.cjs +143 -1
  97. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  98. package/dist/cjs/localization/getHTMLTextDir.cjs +40 -1
  99. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  100. package/dist/cjs/localization/getLocale.cjs +27 -1
  101. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  102. package/dist/cjs/localization/getLocaleFromPath.cjs +36 -1
  103. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  104. package/dist/cjs/localization/getLocaleLang.cjs +20 -1
  105. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  106. package/dist/cjs/localization/getLocaleName.cjs +10 -1
  107. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  108. package/dist/cjs/localization/getLocalizedUrl.cjs +73 -1
  109. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  110. package/dist/cjs/localization/getMultilingualUrls.cjs +46 -1
  111. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  112. package/dist/cjs/localization/getPathWithoutLocale.cjs +55 -1
  113. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  114. package/dist/cjs/localization/getPrefix.cjs +73 -1
  115. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  116. package/dist/cjs/localization/index.cjs +41 -1
  117. package/dist/cjs/localization/localeDetector.cjs +133 -1
  118. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  119. package/dist/cjs/localization/localeMapper.cjs +124 -1
  120. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  121. package/dist/cjs/localization/localeResolver.cjs +28 -1
  122. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  123. package/dist/cjs/localization/rewriteUtils.cjs +110 -1
  124. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  125. package/dist/cjs/localization/validatePrefix.cjs +45 -1
  126. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  127. package/dist/cjs/markdown/compiler.cjs +810 -10
  128. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  129. package/dist/cjs/markdown/constants.cjs +328 -1
  130. package/dist/cjs/markdown/constants.cjs.map +1 -1
  131. package/dist/cjs/markdown/index.cjs +126 -1
  132. package/dist/cjs/markdown/parser.cjs +66 -1
  133. package/dist/cjs/markdown/parser.cjs.map +1 -1
  134. package/dist/cjs/markdown/renderer.cjs +61 -1
  135. package/dist/cjs/markdown/renderer.cjs.map +1 -1
  136. package/dist/cjs/markdown/utils.cjs +391 -6
  137. package/dist/cjs/markdown/utils.cjs.map +1 -1
  138. package/dist/cjs/messageFormat/ICU.cjs +334 -1
  139. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  140. package/dist/cjs/messageFormat/i18next.cjs +345 -1
  141. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  142. package/dist/cjs/messageFormat/index.cjs +11 -1
  143. package/dist/cjs/messageFormat/verify-icu-format.cjs +64 -2
  144. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
  145. package/dist/cjs/messageFormat/vue-i18n.cjs +181 -1
  146. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  147. package/dist/cjs/transpiler/condition/condition.cjs +26 -1
  148. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  149. package/dist/cjs/transpiler/condition/index.cjs +4 -1
  150. package/dist/cjs/transpiler/enumeration/enumeration.cjs +28 -1
  151. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  152. package/dist/cjs/transpiler/enumeration/index.cjs +4 -1
  153. package/dist/cjs/transpiler/file/file.cjs +51 -1
  154. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  155. package/dist/cjs/transpiler/file/fileBrowser.cjs +24 -1
  156. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  157. package/dist/cjs/transpiler/file/index.cjs +5 -1
  158. package/dist/cjs/transpiler/gender/gender.cjs +26 -1
  159. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  160. package/dist/cjs/transpiler/gender/index.cjs +4 -1
  161. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +45 -1
  162. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -0
  163. package/dist/cjs/transpiler/html/html.cjs +44 -1
  164. package/dist/cjs/transpiler/html/html.cjs.map +1 -0
  165. package/dist/cjs/transpiler/html/htmlTags.cjs +116 -1
  166. package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
  167. package/dist/cjs/transpiler/html/index.cjs +9 -1
  168. package/dist/cjs/transpiler/html/validateHTML.cjs +65 -1
  169. package/dist/cjs/transpiler/html/validateHTML.cjs.map +1 -1
  170. package/dist/cjs/transpiler/index.cjs +29 -1
  171. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +11 -1
  172. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  173. package/dist/cjs/transpiler/insertion/index.cjs +6 -1
  174. package/dist/cjs/transpiler/insertion/insertion.cjs +36 -1
  175. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  176. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +23 -2
  177. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  178. package/dist/cjs/transpiler/markdown/index.cjs +8 -1
  179. package/dist/cjs/transpiler/markdown/markdown.cjs +62 -1
  180. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  181. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs +74 -4
  182. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs.map +1 -1
  183. package/dist/cjs/transpiler/nesting/index.cjs +4 -1
  184. package/dist/cjs/transpiler/nesting/nesting.cjs +27 -1
  185. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  186. package/dist/cjs/transpiler/translation/index.cjs +4 -1
  187. package/dist/cjs/transpiler/translation/translation.cjs +29 -1
  188. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  189. package/dist/cjs/utils/checkIsURLAbsolute.cjs +7 -1
  190. package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
  191. package/dist/cjs/utils/getCookie.cjs +32 -1
  192. package/dist/cjs/utils/getCookie.cjs.map +1 -1
  193. package/dist/cjs/utils/index.cjs +21 -1
  194. package/dist/cjs/utils/intl.cjs +91 -1
  195. package/dist/cjs/utils/intl.cjs.map +1 -1
  196. package/dist/cjs/utils/isSameKeyPath.cjs +7 -1
  197. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  198. package/dist/cjs/utils/isValidReactElement.cjs +14 -1
  199. package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
  200. package/dist/cjs/utils/localeStorage.cjs +140 -1
  201. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  202. package/dist/cjs/utils/parseYaml.cjs +322 -16
  203. package/dist/cjs/utils/parseYaml.cjs.map +1 -1
  204. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +207 -1
  205. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  206. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +89 -1
  207. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  208. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +42 -1
  209. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  210. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +31 -1
  211. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  212. package/dist/esm/deepTransformPlugins/getMaskContent.mjs +25 -1
  213. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  214. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +145 -1
  215. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  216. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +86 -1
  217. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  218. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs +59 -1
  219. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  220. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +119 -1
  221. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  222. package/dist/esm/deepTransformPlugins/index.mjs +12 -1
  223. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +104 -1
  224. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  225. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +62 -1
  226. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  227. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +16 -1
  228. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  229. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +53 -1
  230. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  231. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +24 -1
  232. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  233. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +21 -1
  234. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  235. package/dist/esm/dictionaryManipulator/getNodeType.mjs +52 -1
  236. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  237. package/dist/esm/dictionaryManipulator/index.mjs +14 -1
  238. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +66 -1
  239. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  240. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +28 -1
  241. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  242. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs +45 -1
  243. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  244. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +29 -1
  245. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  246. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +37 -1
  247. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  248. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +36 -1
  249. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  250. package/dist/esm/formatters/compact.mjs +22 -1
  251. package/dist/esm/formatters/compact.mjs.map +1 -1
  252. package/dist/esm/formatters/currency.mjs +26 -1
  253. package/dist/esm/formatters/currency.mjs.map +1 -1
  254. package/dist/esm/formatters/date.mjs +57 -1
  255. package/dist/esm/formatters/date.mjs.map +1 -1
  256. package/dist/esm/formatters/index.mjs +11 -1
  257. package/dist/esm/formatters/list.mjs +27 -1
  258. package/dist/esm/formatters/list.mjs.map +1 -1
  259. package/dist/esm/formatters/number.mjs +17 -1
  260. package/dist/esm/formatters/number.mjs.map +1 -1
  261. package/dist/esm/formatters/percentage.mjs +24 -1
  262. package/dist/esm/formatters/percentage.mjs.map +1 -1
  263. package/dist/esm/formatters/relativeTime.mjs +40 -1
  264. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  265. package/dist/esm/formatters/units.mjs +20 -1
  266. package/dist/esm/formatters/units.mjs.map +1 -1
  267. package/dist/esm/getStorageAttributes.mjs +132 -1
  268. package/dist/esm/getStorageAttributes.mjs.map +1 -1
  269. package/dist/esm/index.mjs +87 -1
  270. package/dist/esm/interpreter/getCondition.mjs +25 -1
  271. package/dist/esm/interpreter/getCondition.mjs.map +1 -1
  272. package/dist/esm/interpreter/getContent/deepTransform.mjs +39 -1
  273. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  274. package/dist/esm/interpreter/getContent/getContent.mjs +28 -1
  275. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -0
  276. package/dist/esm/interpreter/getContent/index.mjs +5 -1
  277. package/dist/esm/interpreter/getContent/plugins.mjs +154 -1
  278. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -0
  279. package/dist/esm/interpreter/getDictionary.mjs +24 -1
  280. package/dist/esm/interpreter/getDictionary.mjs.map +1 -0
  281. package/dist/esm/interpreter/getEnumeration.mjs +69 -1
  282. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  283. package/dist/esm/interpreter/getGender.mjs +36 -1
  284. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  285. package/dist/esm/interpreter/getHTML.mjs +122 -1
  286. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  287. package/dist/esm/interpreter/getInsertion.mjs +20 -1
  288. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  289. package/dist/esm/interpreter/getIntlayer.mjs +37 -1
  290. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -0
  291. package/dist/esm/interpreter/getNesting.mjs +36 -1
  292. package/dist/esm/interpreter/getNesting.mjs.map +1 -0
  293. package/dist/esm/interpreter/getTranslation.mjs +110 -1
  294. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  295. package/dist/esm/interpreter/index.mjs +13 -1
  296. package/dist/esm/interpreter/splitAndJoinInsertion.mjs +53 -1
  297. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  298. package/dist/esm/localization/getBrowserLocale.mjs +138 -1
  299. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  300. package/dist/esm/localization/getHTMLTextDir.mjs +38 -1
  301. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  302. package/dist/esm/localization/getLocale.mjs +24 -1
  303. package/dist/esm/localization/getLocale.mjs.map +1 -1
  304. package/dist/esm/localization/getLocaleFromPath.mjs +35 -1
  305. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  306. package/dist/esm/localization/getLocaleLang.mjs +18 -1
  307. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  308. package/dist/esm/localization/getLocaleName.mjs +9 -1
  309. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  310. package/dist/esm/localization/getLocalizedUrl.mjs +70 -1
  311. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  312. package/dist/esm/localization/getMultilingualUrls.mjs +45 -1
  313. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  314. package/dist/esm/localization/getPathWithoutLocale.mjs +52 -1
  315. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  316. package/dist/esm/localization/getPrefix.mjs +69 -1
  317. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  318. package/dist/esm/localization/index.mjs +18 -1
  319. package/dist/esm/localization/localeDetector.mjs +131 -1
  320. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  321. package/dist/esm/localization/localeMapper.mjs +119 -1
  322. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  323. package/dist/esm/localization/localeResolver.mjs +25 -1
  324. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  325. package/dist/esm/localization/rewriteUtils.mjs +104 -1
  326. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  327. package/dist/esm/localization/validatePrefix.mjs +44 -1
  328. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  329. package/dist/esm/markdown/compiler.mjs +786 -10
  330. package/dist/esm/markdown/compiler.mjs.map +1 -1
  331. package/dist/esm/markdown/constants.mjs +247 -1
  332. package/dist/esm/markdown/constants.mjs.map +1 -1
  333. package/dist/esm/markdown/index.mjs +10 -1
  334. package/dist/esm/markdown/parser.mjs +65 -1
  335. package/dist/esm/markdown/parser.mjs.map +1 -1
  336. package/dist/esm/markdown/renderer.mjs +59 -1
  337. package/dist/esm/markdown/renderer.mjs.map +1 -1
  338. package/dist/esm/markdown/utils.mjs +361 -6
  339. package/dist/esm/markdown/utils.mjs.map +1 -1
  340. package/dist/esm/messageFormat/ICU.mjs +330 -1
  341. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  342. package/dist/esm/messageFormat/i18next.mjs +341 -1
  343. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  344. package/dist/esm/messageFormat/index.mjs +5 -1
  345. package/dist/esm/messageFormat/verify-icu-format.mjs +64 -2
  346. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  347. package/dist/esm/messageFormat/vue-i18n.mjs +177 -1
  348. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  349. package/dist/esm/transpiler/condition/condition.mjs +24 -1
  350. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  351. package/dist/esm/transpiler/condition/index.mjs +3 -1
  352. package/dist/esm/transpiler/enumeration/enumeration.mjs +26 -1
  353. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  354. package/dist/esm/transpiler/enumeration/index.mjs +3 -1
  355. package/dist/esm/transpiler/file/file.mjs +48 -1
  356. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  357. package/dist/esm/transpiler/file/fileBrowser.mjs +22 -1
  358. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  359. package/dist/esm/transpiler/file/index.mjs +3 -1
  360. package/dist/esm/transpiler/gender/gender.mjs +24 -1
  361. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  362. package/dist/esm/transpiler/gender/index.mjs +3 -1
  363. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +44 -1
  364. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -0
  365. package/dist/esm/transpiler/html/html.mjs +42 -1
  366. package/dist/esm/transpiler/html/html.mjs.map +1 -0
  367. package/dist/esm/transpiler/html/htmlTags.mjs +114 -1
  368. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  369. package/dist/esm/transpiler/html/index.mjs +5 -1
  370. package/dist/esm/transpiler/html/validateHTML.mjs +62 -1
  371. package/dist/esm/transpiler/html/validateHTML.mjs.map +1 -1
  372. package/dist/esm/transpiler/index.mjs +15 -1
  373. package/dist/esm/transpiler/insertion/getInsertionValues.mjs +9 -1
  374. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  375. package/dist/esm/transpiler/insertion/index.mjs +4 -1
  376. package/dist/esm/transpiler/insertion/insertion.mjs +34 -1
  377. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  378. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +22 -2
  379. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  380. package/dist/esm/transpiler/markdown/index.mjs +5 -1
  381. package/dist/esm/transpiler/markdown/markdown.mjs +60 -1
  382. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  383. package/dist/esm/transpiler/markdown/validateMarkdown.mjs +73 -4
  384. package/dist/esm/transpiler/markdown/validateMarkdown.mjs.map +1 -1
  385. package/dist/esm/transpiler/nesting/index.mjs +3 -1
  386. package/dist/esm/transpiler/nesting/nesting.mjs +25 -1
  387. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  388. package/dist/esm/transpiler/translation/index.mjs +3 -1
  389. package/dist/esm/transpiler/translation/translation.mjs +27 -1
  390. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  391. package/dist/esm/utils/checkIsURLAbsolute.mjs +5 -1
  392. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  393. package/dist/esm/utils/getCookie.mjs +30 -1
  394. package/dist/esm/utils/getCookie.mjs.map +1 -1
  395. package/dist/esm/utils/index.mjs +9 -1
  396. package/dist/esm/utils/intl.mjs +86 -1
  397. package/dist/esm/utils/intl.mjs.map +1 -1
  398. package/dist/esm/utils/isSameKeyPath.mjs +5 -1
  399. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  400. package/dist/esm/utils/isValidReactElement.mjs +12 -1
  401. package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
  402. package/dist/esm/utils/localeStorage.mjs +135 -1
  403. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  404. package/dist/esm/utils/parseYaml.mjs +320 -16
  405. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  406. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +50 -2
  407. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -0
  408. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +42 -2
  409. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -0
  410. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +34 -2
  411. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -0
  412. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts +18 -2
  413. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +1 -0
  414. package/dist/types/deepTransformPlugins/getMaskContent.d.ts +10 -2
  415. package/dist/types/deepTransformPlugins/getMaskContent.d.ts.map +1 -0
  416. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts +19 -2
  417. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts.map +1 -0
  418. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts +32 -2
  419. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +1 -0
  420. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts +8 -2
  421. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +1 -0
  422. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +43 -2
  423. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +1 -0
  424. package/dist/types/deepTransformPlugins/index.d.ts +10 -10
  425. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts +25 -2
  426. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts.map +1 -0
  427. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +8 -2
  428. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +1 -0
  429. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +9 -2
  430. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -0
  431. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +9 -2
  432. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -0
  433. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts +7 -2
  434. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +1 -0
  435. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +7 -2
  436. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -0
  437. package/dist/types/dictionaryManipulator/getNodeType.d.ts +8 -2
  438. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -0
  439. package/dist/types/dictionaryManipulator/index.d.ts +12 -12
  440. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts +7 -2
  441. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +1 -0
  442. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts +9 -2
  443. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +1 -0
  444. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +15 -2
  445. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -0
  446. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +8 -2
  447. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +1 -0
  448. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +8 -2
  449. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +1 -0
  450. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +7 -2
  451. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +1 -0
  452. package/dist/types/formatters/compact.d.ts +20 -2
  453. package/dist/types/formatters/compact.d.ts.map +1 -0
  454. package/dist/types/formatters/currency.d.ts +20 -2
  455. package/dist/types/formatters/currency.d.ts.map +1 -0
  456. package/dist/types/formatters/date.d.ts +20 -2
  457. package/dist/types/formatters/date.d.ts.map +1 -0
  458. package/dist/types/formatters/index.d.ts +9 -9
  459. package/dist/types/formatters/list.d.ts +30 -2
  460. package/dist/types/formatters/list.d.ts.map +1 -0
  461. package/dist/types/formatters/number.d.ts +18 -2
  462. package/dist/types/formatters/number.d.ts.map +1 -0
  463. package/dist/types/formatters/percentage.d.ts +18 -2
  464. package/dist/types/formatters/percentage.d.ts.map +1 -0
  465. package/dist/types/formatters/relativeTime.d.ts +21 -2
  466. package/dist/types/formatters/relativeTime.d.ts.map +1 -0
  467. package/dist/types/formatters/units.d.ts +16 -2
  468. package/dist/types/formatters/units.d.ts.map +1 -0
  469. package/dist/types/getStorageAttributes.d.ts +29 -2
  470. package/dist/types/getStorageAttributes.d.ts.map +1 -0
  471. package/dist/types/index.d.ts +88 -80
  472. package/dist/types/interpreter/getCondition.d.ts +22 -2
  473. package/dist/types/interpreter/getCondition.d.ts.map +1 -0
  474. package/dist/types/interpreter/getContent/deepTransform.d.ts +12 -2
  475. package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -0
  476. package/dist/types/interpreter/getContent/getContent.d.ts +16 -2
  477. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -0
  478. package/dist/types/interpreter/getContent/index.d.ts +3 -1
  479. package/dist/types/interpreter/getContent/plugins.d.ts +152 -2
  480. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -0
  481. package/dist/types/interpreter/getDictionary.d.ts +17 -2
  482. package/dist/types/interpreter/getDictionary.d.ts.map +1 -0
  483. package/dist/types/interpreter/getEnumeration.d.ts +58 -2
  484. package/dist/types/interpreter/getEnumeration.d.ts.map +1 -0
  485. package/dist/types/interpreter/getGender.d.ts +1 -1
  486. package/dist/types/interpreter/getGender.d.ts.map +1 -1
  487. package/dist/types/interpreter/getHTML.d.ts +32 -2
  488. package/dist/types/interpreter/getHTML.d.ts.map +1 -0
  489. package/dist/types/interpreter/getInsertion.d.ts +1 -1
  490. package/dist/types/interpreter/getInsertion.d.ts.map +1 -1
  491. package/dist/types/interpreter/getIntlayer.d.ts +8 -2
  492. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -0
  493. package/dist/types/interpreter/getNesting.d.ts +27 -2
  494. package/dist/types/interpreter/getNesting.d.ts.map +1 -0
  495. package/dist/types/interpreter/getTranslation.d.ts +30 -2
  496. package/dist/types/interpreter/getTranslation.d.ts.map +1 -0
  497. package/dist/types/interpreter/index.d.ts +11 -4
  498. package/dist/types/interpreter/splitAndJoinInsertion.d.ts +25 -2
  499. package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +1 -0
  500. package/dist/types/localization/getBrowserLocale.d.ts +35 -2
  501. package/dist/types/localization/getBrowserLocale.d.ts.map +1 -0
  502. package/dist/types/localization/getHTMLTextDir.d.ts +21 -2
  503. package/dist/types/localization/getHTMLTextDir.d.ts.map +1 -0
  504. package/dist/types/localization/getLocale.d.ts +11 -2
  505. package/dist/types/localization/getLocale.d.ts.map +1 -0
  506. package/dist/types/localization/getLocaleFromPath.d.ts +20 -2
  507. package/dist/types/localization/getLocaleFromPath.d.ts.map +1 -0
  508. package/dist/types/localization/getLocaleLang.d.ts +20 -2
  509. package/dist/types/localization/getLocaleLang.d.ts.map +1 -0
  510. package/dist/types/localization/getLocaleName.d.ts +7 -2
  511. package/dist/types/localization/getLocaleName.d.ts.map +1 -0
  512. package/dist/types/localization/getLocalizedUrl.d.ts +44 -2
  513. package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -0
  514. package/dist/types/localization/getMultilingualUrls.d.ts +42 -2
  515. package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -0
  516. package/dist/types/localization/getPathWithoutLocale.d.ts +31 -2
  517. package/dist/types/localization/getPathWithoutLocale.d.ts.map +1 -0
  518. package/dist/types/localization/getPrefix.d.ts +83 -2
  519. package/dist/types/localization/getPrefix.d.ts.map +1 -0
  520. package/dist/types/localization/index.d.ts +16 -16
  521. package/dist/types/localization/localeDetector.d.ts +18 -2
  522. package/dist/types/localization/localeDetector.d.ts.map +1 -0
  523. package/dist/types/localization/localeMapper.d.ts +92 -2
  524. package/dist/types/localization/localeMapper.d.ts.map +1 -0
  525. package/dist/types/localization/localeResolver.d.ts +12 -2
  526. package/dist/types/localization/localeResolver.d.ts.map +1 -0
  527. package/dist/types/localization/rewriteUtils.d.ts +34 -2
  528. package/dist/types/localization/rewriteUtils.d.ts.map +1 -0
  529. package/dist/types/localization/validatePrefix.d.ts +34 -2
  530. package/dist/types/localization/validatePrefix.d.ts.map +1 -0
  531. package/dist/types/markdown/compiler.d.ts +9 -2
  532. package/dist/types/markdown/compiler.d.ts.map +1 -0
  533. package/dist/types/markdown/constants.d.ts +177 -2
  534. package/dist/types/markdown/constants.d.ts.map +1 -0
  535. package/dist/types/markdown/index.d.ts +10 -10
  536. package/dist/types/markdown/parser.d.ts +16 -2
  537. package/dist/types/markdown/parser.d.ts.map +1 -0
  538. package/dist/types/markdown/renderer.d.ts +22 -2
  539. package/dist/types/markdown/renderer.d.ts.map +1 -0
  540. package/dist/types/markdown/types.d.ts +333 -2
  541. package/dist/types/markdown/types.d.ts.map +1 -0
  542. package/dist/types/markdown/utils.d.ts +140 -2
  543. package/dist/types/markdown/utils.d.ts.map +1 -0
  544. package/dist/types/messageFormat/ICU.d.ts +11 -2
  545. package/dist/types/messageFormat/ICU.d.ts.map +1 -0
  546. package/dist/types/messageFormat/i18next.d.ts +9 -2
  547. package/dist/types/messageFormat/i18next.d.ts.map +1 -0
  548. package/dist/types/messageFormat/index.d.ts +3 -3
  549. package/dist/types/messageFormat/vue-i18n.d.ts +9 -2
  550. package/dist/types/messageFormat/vue-i18n.d.ts.map +1 -0
  551. package/dist/types/transpiler/condition/condition.d.ts +28 -2
  552. package/dist/types/transpiler/condition/condition.d.ts.map +1 -0
  553. package/dist/types/transpiler/condition/index.d.ts +1 -1
  554. package/dist/types/transpiler/enumeration/enumeration.d.ts +40 -2
  555. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -0
  556. package/dist/types/transpiler/enumeration/index.d.ts +1 -1
  557. package/dist/types/transpiler/file/file.d.ts +28 -2
  558. package/dist/types/transpiler/file/file.d.ts.map +1 -0
  559. package/dist/types/transpiler/file/fileBrowser.d.ts +1 -1
  560. package/dist/types/transpiler/file/index.d.ts +1 -1
  561. package/dist/types/transpiler/gender/gender.d.ts +29 -2
  562. package/dist/types/transpiler/gender/gender.d.ts.map +1 -0
  563. package/dist/types/transpiler/gender/index.d.ts +1 -1
  564. package/dist/types/transpiler/html/html.d.ts +25 -2
  565. package/dist/types/transpiler/html/html.d.ts.map +1 -0
  566. package/dist/types/transpiler/html/htmlTags.d.ts +115 -2
  567. package/dist/types/transpiler/html/htmlTags.d.ts.map +1 -0
  568. package/dist/types/transpiler/html/index.d.ts +3 -3
  569. package/dist/types/transpiler/html/validateHTML.d.ts +21 -2
  570. package/dist/types/transpiler/html/validateHTML.d.ts.map +1 -0
  571. package/dist/types/transpiler/index.d.ts +15 -15
  572. package/dist/types/transpiler/insertion/getInsertionValues.d.ts +5 -2
  573. package/dist/types/transpiler/insertion/getInsertionValues.d.ts.map +1 -0
  574. package/dist/types/transpiler/insertion/index.d.ts +2 -2
  575. package/dist/types/transpiler/insertion/insertion.d.ts +23 -2
  576. package/dist/types/transpiler/insertion/insertion.d.ts.map +1 -0
  577. package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts +5 -2
  578. package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +1 -0
  579. package/dist/types/transpiler/markdown/index.d.ts +4 -4
  580. package/dist/types/transpiler/markdown/markdown.d.ts +26 -2
  581. package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -0
  582. package/dist/types/transpiler/markdown/validateMarkdown.d.ts +18 -3
  583. package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +1 -0
  584. package/dist/types/transpiler/nesting/index.d.ts +1 -1
  585. package/dist/types/transpiler/nesting/nesting.d.ts +49 -2
  586. package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -0
  587. package/dist/types/transpiler/translation/index.d.ts +1 -1
  588. package/dist/types/transpiler/translation/translation.d.ts +33 -2
  589. package/dist/types/transpiler/translation/translation.d.ts.map +1 -0
  590. package/dist/types/utils/checkIsURLAbsolute.d.ts +5 -2
  591. package/dist/types/utils/checkIsURLAbsolute.d.ts.map +1 -0
  592. package/dist/types/utils/getCookie.d.ts +11 -2
  593. package/dist/types/utils/getCookie.d.ts.map +1 -0
  594. package/dist/types/utils/index.d.ts +7 -7
  595. package/dist/types/utils/intl.d.ts +33 -2
  596. package/dist/types/utils/intl.d.ts.map +1 -0
  597. package/dist/types/utils/isSameKeyPath.d.ts +7 -2
  598. package/dist/types/utils/isSameKeyPath.d.ts.map +1 -0
  599. package/dist/types/utils/isValidReactElement.d.ts +12 -2
  600. package/dist/types/utils/isValidReactElement.d.ts.map +1 -0
  601. package/dist/types/utils/localeStorage.d.ts +108 -2
  602. package/dist/types/utils/localeStorage.d.ts.map +1 -0
  603. package/dist/types/utils/parseYaml.d.ts +5 -2
  604. package/dist/types/utils/parseYaml.d.ts.map +1 -0
  605. package/package.json +6 -6
  606. package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
  607. package/dist/cjs/getContent-DrqM8pqO.cjs +0 -2
  608. package/dist/cjs/getContent-DrqM8pqO.cjs.map +0 -1
  609. package/dist/cjs/html-CZ1N-VL0.cjs +0 -2
  610. package/dist/cjs/html-CZ1N-VL0.cjs.map +0 -1
  611. package/dist/esm/getContent-DKqtIZGL.mjs +0 -2
  612. package/dist/esm/getContent-DKqtIZGL.mjs.map +0 -1
  613. package/dist/esm/html-3bo80xzx.mjs +0 -2
  614. package/dist/esm/html-3bo80xzx.mjs.map +0 -1
  615. package/dist/types/ICU-tA3ZHN5U.d.ts +0 -11
  616. package/dist/types/ICU-tA3ZHN5U.d.ts.map +0 -1
  617. package/dist/types/checkIsURLAbsolute-CTf3JFU6.d.ts +0 -5
  618. package/dist/types/checkIsURLAbsolute-CTf3JFU6.d.ts.map +0 -1
  619. package/dist/types/compact-IHXcM4pT.d.ts +0 -20
  620. package/dist/types/compact-IHXcM4pT.d.ts.map +0 -1
  621. package/dist/types/compiler-DFiAsUdH.d.ts +0 -9
  622. package/dist/types/compiler-DFiAsUdH.d.ts.map +0 -1
  623. package/dist/types/condition-BDUtoh_1.d.ts +0 -28
  624. package/dist/types/condition-BDUtoh_1.d.ts.map +0 -1
  625. package/dist/types/constants-CI_D82B1.d.ts +0 -177
  626. package/dist/types/constants-CI_D82B1.d.ts.map +0 -1
  627. package/dist/types/currency-PbMCnHep.d.ts +0 -20
  628. package/dist/types/currency-PbMCnHep.d.ts.map +0 -1
  629. package/dist/types/date-C-PI8KqU.d.ts +0 -20
  630. package/dist/types/date-C-PI8KqU.d.ts.map +0 -1
  631. package/dist/types/editDictionaryByKeyPath-BYIHcsyf.d.ts +0 -8
  632. package/dist/types/editDictionaryByKeyPath-BYIHcsyf.d.ts.map +0 -1
  633. package/dist/types/enumeration-CtuvB5Zz.d.ts +0 -40
  634. package/dist/types/enumeration-CtuvB5Zz.d.ts.map +0 -1
  635. package/dist/types/file-C3q8xvQb.d.ts +0 -28
  636. package/dist/types/file-C3q8xvQb.d.ts.map +0 -1
  637. package/dist/types/gender-Dd39Ijmf.d.ts +0 -29
  638. package/dist/types/gender-Dd39Ijmf.d.ts.map +0 -1
  639. package/dist/types/getBrowserLocale-RD_Mwv1t.d.ts +0 -35
  640. package/dist/types/getBrowserLocale-RD_Mwv1t.d.ts.map +0 -1
  641. package/dist/types/getContentNodeByKeyPath-B0Tdi5mj.d.ts +0 -9
  642. package/dist/types/getContentNodeByKeyPath-B0Tdi5mj.d.ts.map +0 -1
  643. package/dist/types/getCookie-DPOvVv_h.d.ts +0 -11
  644. package/dist/types/getCookie-DPOvVv_h.d.ts.map +0 -1
  645. package/dist/types/getDefaultNode-DQNsje2D.d.ts +0 -9
  646. package/dist/types/getDefaultNode-DQNsje2D.d.ts.map +0 -1
  647. package/dist/types/getEmptyNode-DW27TTBj.d.ts +0 -7
  648. package/dist/types/getEmptyNode-DW27TTBj.d.ts.map +0 -1
  649. package/dist/types/getFilterMissingTranslationsContent-CDNQqoy1.d.ts +0 -50
  650. package/dist/types/getFilterMissingTranslationsContent-CDNQqoy1.d.ts.map +0 -1
  651. package/dist/types/getFilterTranslationsOnlyContent-D2YgBkHn.d.ts +0 -42
  652. package/dist/types/getFilterTranslationsOnlyContent-D2YgBkHn.d.ts.map +0 -1
  653. package/dist/types/getFilteredLocalesContent-D0GP-uEg.d.ts +0 -34
  654. package/dist/types/getFilteredLocalesContent-D0GP-uEg.d.ts.map +0 -1
  655. package/dist/types/getHTML-CP6OXtdo.d.ts +0 -32
  656. package/dist/types/getHTML-CP6OXtdo.d.ts.map +0 -1
  657. package/dist/types/getHTMLTextDir-4Zh8J3x7.d.ts +0 -21
  658. package/dist/types/getHTMLTextDir-4Zh8J3x7.d.ts.map +0 -1
  659. package/dist/types/getInsertionValues-Cu9IdbuE.d.ts +0 -5
  660. package/dist/types/getInsertionValues-Cu9IdbuE.d.ts.map +0 -1
  661. package/dist/types/getLocale-B9dECUM_.d.ts +0 -11
  662. package/dist/types/getLocale-B9dECUM_.d.ts.map +0 -1
  663. package/dist/types/getLocaleFromPath-621W32QA.d.ts +0 -26
  664. package/dist/types/getLocaleFromPath-621W32QA.d.ts.map +0 -1
  665. package/dist/types/getLocaleLang-Bcan1gS4.d.ts +0 -20
  666. package/dist/types/getLocaleLang-Bcan1gS4.d.ts.map +0 -1
  667. package/dist/types/getLocaleName-CfRAD9Hc.d.ts +0 -7
  668. package/dist/types/getLocaleName-CfRAD9Hc.d.ts.map +0 -1
  669. package/dist/types/getLocalizedContent-DOncZd-0.d.ts +0 -18
  670. package/dist/types/getLocalizedContent-DOncZd-0.d.ts.map +0 -1
  671. package/dist/types/getLocalizedUrl-BbqeA3-W.d.ts +0 -49
  672. package/dist/types/getLocalizedUrl-BbqeA3-W.d.ts.map +0 -1
  673. package/dist/types/getMarkdownMetadata-Bf1S1NQ0.d.ts +0 -5
  674. package/dist/types/getMarkdownMetadata-Bf1S1NQ0.d.ts.map +0 -1
  675. package/dist/types/getMaskContent-BwLFqp7v.d.ts +0 -10
  676. package/dist/types/getMaskContent-BwLFqp7v.d.ts.map +0 -1
  677. package/dist/types/getMissingLocalesContent-BYffYcdx.d.ts +0 -19
  678. package/dist/types/getMissingLocalesContent-BYffYcdx.d.ts.map +0 -1
  679. package/dist/types/getMultilingualDictionary-DO3i1MFs.d.ts +0 -32
  680. package/dist/types/getMultilingualDictionary-DO3i1MFs.d.ts.map +0 -1
  681. package/dist/types/getMultilingualUrls-CUxYYfA4.d.ts +0 -47
  682. package/dist/types/getMultilingualUrls-CUxYYfA4.d.ts.map +0 -1
  683. package/dist/types/getNodeChildren-OT7Liqke.d.ts +0 -7
  684. package/dist/types/getNodeChildren-OT7Liqke.d.ts.map +0 -1
  685. package/dist/types/getNodeType-Cp765I26.d.ts +0 -8
  686. package/dist/types/getNodeType-Cp765I26.d.ts.map +0 -1
  687. package/dist/types/getPathWithoutLocale-B_aIR7O0.d.ts +0 -31
  688. package/dist/types/getPathWithoutLocale-B_aIR7O0.d.ts.map +0 -1
  689. package/dist/types/getPrefix-X9XKkrZD.d.ts +0 -68
  690. package/dist/types/getPrefix-X9XKkrZD.d.ts.map +0 -1
  691. package/dist/types/getReplacedValuesContent-BvL25pdt.d.ts +0 -8
  692. package/dist/types/getReplacedValuesContent-BvL25pdt.d.ts.map +0 -1
  693. package/dist/types/getSplittedContent-YD4JDMfB.d.ts +0 -43
  694. package/dist/types/getSplittedContent-YD4JDMfB.d.ts.map +0 -1
  695. package/dist/types/getStorageAttributes-CIO2xWqQ.d.ts +0 -29
  696. package/dist/types/getStorageAttributes-CIO2xWqQ.d.ts.map +0 -1
  697. package/dist/types/getTranslation-BG2Wg-af.d.ts +0 -30
  698. package/dist/types/getTranslation-BG2Wg-af.d.ts.map +0 -1
  699. package/dist/types/html-Dn6KrpJ3.d.ts +0 -25
  700. package/dist/types/html-Dn6KrpJ3.d.ts.map +0 -1
  701. package/dist/types/htmlTags-YxTtVUx6.d.ts +0 -115
  702. package/dist/types/htmlTags-YxTtVUx6.d.ts.map +0 -1
  703. package/dist/types/i18next-qY0AixrB.d.ts +0 -9
  704. package/dist/types/i18next-qY0AixrB.d.ts.map +0 -1
  705. package/dist/types/index-1CTsSKEn.d.ts +0 -1
  706. package/dist/types/index-B8xF2zGo.d.ts +0 -1
  707. package/dist/types/index-BcsOTSQF.d.ts +0 -1
  708. package/dist/types/index-BnEeKNKW.d.ts +0 -322
  709. package/dist/types/index-BnEeKNKW.d.ts.map +0 -1
  710. package/dist/types/index-Cf8zm5QQ.d.ts +0 -1
  711. package/dist/types/index-CfvILin8.d.ts +0 -1
  712. package/dist/types/index-DK_kKFOF.d.ts +0 -1
  713. package/dist/types/index-DeJa0xZp.d.ts +0 -1
  714. package/dist/types/index-Vlqtiwjx.d.ts +0 -1
  715. package/dist/types/insertContentInDictionary-DZ3UzG4K.d.ts +0 -25
  716. package/dist/types/insertContentInDictionary-DZ3UzG4K.d.ts.map +0 -1
  717. package/dist/types/insertion-M5fwK-29.d.ts +0 -23
  718. package/dist/types/insertion-M5fwK-29.d.ts.map +0 -1
  719. package/dist/types/intl-B2Ap8I5x.d.ts +0 -33
  720. package/dist/types/intl-B2Ap8I5x.d.ts.map +0 -1
  721. package/dist/types/isSameKeyPath-CkH8NdJh.d.ts +0 -7
  722. package/dist/types/isSameKeyPath-CkH8NdJh.d.ts.map +0 -1
  723. package/dist/types/isValidReactElement-BsoJ01oP.d.ts +0 -12
  724. package/dist/types/isValidReactElement-BsoJ01oP.d.ts.map +0 -1
  725. package/dist/types/list-BdjJM2Gx.d.ts +0 -30
  726. package/dist/types/list-BdjJM2Gx.d.ts.map +0 -1
  727. package/dist/types/localeDetector-BWNCQRiZ.d.ts +0 -18
  728. package/dist/types/localeDetector-BWNCQRiZ.d.ts.map +0 -1
  729. package/dist/types/localeMapper-DoAnasqf.d.ts +0 -92
  730. package/dist/types/localeMapper-DoAnasqf.d.ts.map +0 -1
  731. package/dist/types/localeResolver-bb7AWQNX.d.ts +0 -12
  732. package/dist/types/localeResolver-bb7AWQNX.d.ts.map +0 -1
  733. package/dist/types/localeStorage-CZHwY0u3.d.ts +0 -108
  734. package/dist/types/localeStorage-CZHwY0u3.d.ts.map +0 -1
  735. package/dist/types/markdown-MzfikrI1.d.ts +0 -26
  736. package/dist/types/markdown-MzfikrI1.d.ts.map +0 -1
  737. package/dist/types/mergeDictionaries-D6WUMQN5.d.ts +0 -7
  738. package/dist/types/mergeDictionaries-D6WUMQN5.d.ts.map +0 -1
  739. package/dist/types/normalizeDictionary-coviIGTW.d.ts +0 -9
  740. package/dist/types/normalizeDictionary-coviIGTW.d.ts.map +0 -1
  741. package/dist/types/number-C8izkCmU.d.ts +0 -16
  742. package/dist/types/number-C8izkCmU.d.ts.map +0 -1
  743. package/dist/types/orderDictionaries-SSCMY6qG.d.ts +0 -15
  744. package/dist/types/orderDictionaries-SSCMY6qG.d.ts.map +0 -1
  745. package/dist/types/parseYaml-D5gxutvA.d.ts +0 -5
  746. package/dist/types/parseYaml-D5gxutvA.d.ts.map +0 -1
  747. package/dist/types/parser-BVwR6Tjw.d.ts +0 -16
  748. package/dist/types/parser-BVwR6Tjw.d.ts.map +0 -1
  749. package/dist/types/percentage-BqsvW0Zw.d.ts +0 -16
  750. package/dist/types/percentage-BqsvW0Zw.d.ts.map +0 -1
  751. package/dist/types/relativeTime-mJaYEq7H.d.ts +0 -11
  752. package/dist/types/relativeTime-mJaYEq7H.d.ts.map +0 -1
  753. package/dist/types/removeContentNodeByKeyPath-CotCOOsD.d.ts +0 -8
  754. package/dist/types/removeContentNodeByKeyPath-CotCOOsD.d.ts.map +0 -1
  755. package/dist/types/renameContentNodeByKeyPath-BuyH5gOr.d.ts +0 -8
  756. package/dist/types/renameContentNodeByKeyPath-BuyH5gOr.d.ts.map +0 -1
  757. package/dist/types/renderer-C06x2Orf.d.ts +0 -22
  758. package/dist/types/renderer-C06x2Orf.d.ts.map +0 -1
  759. package/dist/types/rewriteUtils-Bd82NiGR.d.ts +0 -34
  760. package/dist/types/rewriteUtils-Bd82NiGR.d.ts.map +0 -1
  761. package/dist/types/splitAndJoinInsertion-bkuLa7o2.d.ts +0 -25
  762. package/dist/types/splitAndJoinInsertion-bkuLa7o2.d.ts.map +0 -1
  763. package/dist/types/translation-CiC-Avxc.d.ts +0 -33
  764. package/dist/types/translation-CiC-Avxc.d.ts.map +0 -1
  765. package/dist/types/types-C2Om0aEM.d.ts +0 -333
  766. package/dist/types/types-C2Om0aEM.d.ts.map +0 -1
  767. package/dist/types/units-CouGqa8j.d.ts +0 -16
  768. package/dist/types/units-CouGqa8j.d.ts.map +0 -1
  769. package/dist/types/updateNodeChildren-B5Tu1UBZ.d.ts +0 -7
  770. package/dist/types/updateNodeChildren-B5Tu1UBZ.d.ts.map +0 -1
  771. package/dist/types/utils-Dcmgh_80.d.ts +0 -140
  772. package/dist/types/utils-Dcmgh_80.d.ts.map +0 -1
  773. package/dist/types/validateHTML-U7UKTtFd.d.ts +0 -21
  774. package/dist/types/validateHTML-U7UKTtFd.d.ts.map +0 -1
  775. package/dist/types/validateMarkdown-BUaTDDIu.d.ts +0 -18
  776. package/dist/types/validateMarkdown-BUaTDDIu.d.ts.map +0 -1
  777. package/dist/types/validatePrefix-Dtmg7QLq.d.ts +0 -38
  778. package/dist/types/validatePrefix-Dtmg7QLq.d.ts.map +0 -1
  779. package/dist/types/vue-i18n-JtUB7N_m.d.ts +0 -9
  780. package/dist/types/vue-i18n-JtUB7N_m.d.ts.map +0 -1
@@ -1,2 +1,146 @@
1
- import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";import{NodeType as t}from"@intlayer/types/nodeType";import n from"@intlayer/config/built";const r=(e,t=[])=>typeof e!=`object`||!e||Array.isArray(e)?[]:Object.keys(e).flatMap(n=>{let i=[...t,n],a=e[n];return a===null?[i]:[i,...r(a,i)]}),i=(e,t=[])=>typeof e!=`object`||!e||Array.isArray(e)?[]:Object.keys(e).flatMap(n=>{let r=[...t,n],a=e[n];return a===null?[]:[r,...i(a,r)]}),a=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n||!(e in n))return!1;n=n[e]}return!0},o=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n||!(e in n))return!1;n=n[e]}return n!==null},s=(e,n)=>({id:`check-missing-locales-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===t.Translation,transform:(s,c,l)=>{let u=s[t.Translation],d=new Set,f=new Set;for(let t of e){let e=u[t];e&&typeof e==`object`&&!Array.isArray(e)&&(r(e).forEach(e=>{d.add(JSON.stringify(e))}),i(e).forEach(e=>{f.add(JSON.stringify(e))}))}let p=e.some(e=>u[e]!==void 0&&u[e]!==null);for(let t of e){let e=u[t];if(e===null){p&&n(t);continue}if(!e){n(t);continue}let r=!1;for(let i of d)if(!a(e,JSON.parse(i))){n(t),r=!0;break}if(!r){for(let r of f)if(!o(e,JSON.parse(r))){n(t);break}}}for(let e in u){let t=u[e];l(t,{...c,children:t})}return s}}),c=(t,r=n?.internationalization?.locales,i)=>{let a=new Set,o=[s(r,e=>a.add(e)),...i.plugins??[]];return e(t,{...i,plugins:o}),Array.from(a)},l=(e,t=n?.internationalization?.locales)=>c(e.content,t,{dictionaryKey:e.key,keyPath:[]});export{s as checkMissingLocalesPlugin,c as getMissingLocalesContent,l as getMissingLocalesContentFromDictionary};
1
+ import { deepTransformNode } from "../interpreter/getContent/deepTransform.mjs";
2
+ import * as NodeTypes from "@intlayer/types/nodeType";
3
+ import configuration from "@intlayer/config/built";
4
+
5
+ //#region src/deepTransformPlugins/getMissingLocalesContent.ts
6
+ /**
7
+ * Returns all key paths present in obj, INCLUDING those whose leaf value is null.
8
+ * Used for structural presence checks (a locale must have every key another locale has,
9
+ * even if the value is a null placeholder).
10
+ */
11
+ const getAllKeyPaths = (obj, prefix = []) => {
12
+ if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return [];
13
+ return Object.keys(obj).flatMap((key) => {
14
+ const newPath = [...prefix, key];
15
+ const value = obj[key];
16
+ if (value === null) return [newPath];
17
+ return [newPath, ...getAllKeyPaths(value, newPath)];
18
+ });
19
+ };
20
+ /**
21
+ * Returns key paths whose leaf value is non-null.
22
+ * Used for translation value checks (a locale must not have null where another locale
23
+ * already has a real translated value).
24
+ */
25
+ const getNonNullKeyPaths = (obj, prefix = []) => {
26
+ if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return [];
27
+ return Object.keys(obj).flatMap((key) => {
28
+ const newPath = [...prefix, key];
29
+ const value = obj[key];
30
+ if (value === null) return [];
31
+ return [newPath, ...getNonNullKeyPaths(value, newPath)];
32
+ });
33
+ };
34
+ /**
35
+ * Returns true if the key path EXISTS in obj (even if the terminal value is null).
36
+ * Used for the structural presence check.
37
+ */
38
+ const hasKey = (obj, keyPath) => {
39
+ let current = obj;
40
+ for (const key of keyPath) {
41
+ if (current === void 0 || current === null || typeof current !== "object") return false;
42
+ if (!(key in current)) return false;
43
+ current = current[key];
44
+ }
45
+ return true;
46
+ };
47
+ /**
48
+ * Returns true if the key path exists in obj AND the terminal value is non-null.
49
+ * Used for the translation value check.
50
+ */
51
+ const hasNonNullValue = (obj, keyPath) => {
52
+ let current = obj;
53
+ for (const key of keyPath) {
54
+ if (current === void 0 || current === null || typeof current !== "object") return false;
55
+ if (!(key in current)) return false;
56
+ current = current[key];
57
+ }
58
+ return current !== null;
59
+ };
60
+ /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
61
+ const checkMissingLocalesPlugin = (locales, onMissingLocale) => ({
62
+ id: "check-missing-locales-plugin",
63
+ canHandle: (node) => typeof node === "object" && node?.nodeType === NodeTypes.TRANSLATION,
64
+ transform: (node, props, deepTransformNode) => {
65
+ const translations = node[NodeTypes.TRANSLATION];
66
+ /**
67
+ * Two path sets built from all locales' content:
68
+ *
69
+ * presentPaths — every key path that exists in ANY locale, even those whose value
70
+ * is null. A locale that is missing a path from this set is structurally incomplete
71
+ * (the key doesn't exist at all).
72
+ *
73
+ * nonNullPaths — every key path that has a non-null value in at least one locale.
74
+ * A locale that has the key but with null, when another locale already has a real
75
+ * value, needs translation.
76
+ */
77
+ const presentPaths = /* @__PURE__ */ new Set();
78
+ const nonNullPaths = /* @__PURE__ */ new Set();
79
+ for (const locale of locales) {
80
+ const value = translations[locale];
81
+ if (value && typeof value === "object" && !Array.isArray(value)) {
82
+ getAllKeyPaths(value).forEach((path) => {
83
+ presentPaths.add(JSON.stringify(path));
84
+ });
85
+ getNonNullKeyPaths(value).forEach((path) => {
86
+ nonNullPaths.add(JSON.stringify(path));
87
+ });
88
+ }
89
+ }
90
+ const hasAnyDefinedValue = locales.some((locale) => translations[locale] !== void 0 && translations[locale] !== null);
91
+ for (const locale of locales) {
92
+ const value = translations[locale];
93
+ if (value === null) {
94
+ if (hasAnyDefinedValue) onMissingLocale(locale);
95
+ continue;
96
+ }
97
+ if (!value) {
98
+ onMissingLocale(locale);
99
+ continue;
100
+ }
101
+ let flagged = false;
102
+ for (const pathStr of presentPaths) if (!hasKey(value, JSON.parse(pathStr))) {
103
+ onMissingLocale(locale);
104
+ flagged = true;
105
+ break;
106
+ }
107
+ if (!flagged) {
108
+ for (const pathStr of nonNullPaths) if (!hasNonNullValue(value, JSON.parse(pathStr))) {
109
+ onMissingLocale(locale);
110
+ break;
111
+ }
112
+ }
113
+ }
114
+ for (const key in translations) {
115
+ const child = translations[key];
116
+ deepTransformNode(child, {
117
+ ...props,
118
+ children: child
119
+ });
120
+ }
121
+ return node;
122
+ }
123
+ });
124
+ /**
125
+ * Return the content of a node with only the translation plugin.
126
+ *
127
+ * @param node The node to transform.
128
+ * @param locales The locales to check for missing translations.
129
+ */
130
+ const getMissingLocalesContent = (node, locales = configuration?.internationalization?.locales, nodeProps) => {
131
+ const missingLocales = /* @__PURE__ */ new Set();
132
+ const plugins = [checkMissingLocalesPlugin(locales, (locale) => missingLocales.add(locale)), ...nodeProps.plugins ?? []];
133
+ deepTransformNode(node, {
134
+ ...nodeProps,
135
+ plugins
136
+ });
137
+ return Array.from(missingLocales);
138
+ };
139
+ const getMissingLocalesContentFromDictionary = (dictionary, locales = configuration?.internationalization?.locales) => getMissingLocalesContent(dictionary.content, locales, {
140
+ dictionaryKey: dictionary.key,
141
+ keyPath: []
142
+ });
143
+
144
+ //#endregion
145
+ export { checkMissingLocalesPlugin, getMissingLocalesContent, getMissingLocalesContentFromDictionary };
2
146
  //# sourceMappingURL=getMissingLocalesContent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getMissingLocalesContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getMissingLocalesContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport type { DeepTransformContent, NodeProps, Plugins } from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport type { TranslationContent } from '../transpiler';\n\n/**\n * Returns all key paths present in obj, INCLUDING those whose leaf value is null.\n * Used for structural presence checks (a locale must have every key another locale has,\n * even if the value is a null placeholder).\n */\nconst getAllKeyPaths = (obj: any, prefix: string[] = []): string[][] => {\n if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {\n return [];\n }\n\n return Object.keys(obj).flatMap((key) => {\n const newPath = [...prefix, key];\n const value = obj[key];\n // Stop recursing into null — include the path but don't descend further\n if (value === null) {\n return [newPath];\n }\n return [newPath, ...getAllKeyPaths(value, newPath)];\n });\n};\n\n/**\n * Returns key paths whose leaf value is non-null.\n * Used for translation value checks (a locale must not have null where another locale\n * already has a real translated value).\n */\nconst getNonNullKeyPaths = (obj: any, prefix: string[] = []): string[][] => {\n if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {\n return [];\n }\n\n return Object.keys(obj).flatMap((key) => {\n const newPath = [...prefix, key];\n const value = obj[key];\n // Skip null-valued keys entirely\n if (value === null) {\n return [];\n }\n return [newPath, ...getNonNullKeyPaths(value, newPath)];\n });\n};\n\n/**\n * Returns true if the key path EXISTS in obj (even if the terminal value is null).\n * Used for the structural presence check.\n */\nconst hasKey = (obj: any, keyPath: string[]): boolean => {\n let current = obj;\n for (const key of keyPath) {\n if (\n current === undefined ||\n current === null ||\n typeof current !== 'object'\n ) {\n return false;\n }\n if (!(key in current)) {\n return false;\n }\n current = current[key];\n }\n return true; // key exists; value may be null\n};\n\n/**\n * Returns true if the key path exists in obj AND the terminal value is non-null.\n * Used for the translation value check.\n */\nconst hasNonNullValue = (obj: any, keyPath: string[]): boolean => {\n let current = obj;\n for (const key of keyPath) {\n if (\n current === undefined ||\n current === null ||\n typeof current !== 'object'\n ) {\n return false;\n }\n if (!(key in current)) {\n return false;\n }\n current = current[key];\n }\n // null is treated as a missing translation (e.g., i18next-scanner sets null for untranslated keys)\n return current !== null;\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const checkMissingLocalesPlugin = (\n locales: Locale[],\n onMissingLocale: (locale: Locale) => void\n): Plugins => ({\n id: 'check-missing-locales-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const translations = node[NodeType.Translation] as Record<string, any>;\n\n /**\n * Two path sets built from all locales' content:\n *\n * presentPaths — every key path that exists in ANY locale, even those whose value\n * is null. A locale that is missing a path from this set is structurally incomplete\n * (the key doesn't exist at all).\n *\n * nonNullPaths — every key path that has a non-null value in at least one locale.\n * A locale that has the key but with null, when another locale already has a real\n * value, needs translation.\n */\n const presentPaths = new Set<string>();\n const nonNullPaths = new Set<string>();\n\n for (const locale of locales) {\n const value = translations[locale];\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n getAllKeyPaths(value).forEach((path) => {\n presentPaths.add(JSON.stringify(path));\n });\n\n getNonNullKeyPaths(value).forEach((path) => {\n nonNullPaths.add(JSON.stringify(path));\n });\n }\n }\n\n // If no locale has any content at all (all are null/undefined), the key is\n // universally pending — don't flag anyone.\n const hasAnyDefinedValue = locales.some(\n (locale) =>\n translations[locale] !== undefined && translations[locale] !== null\n );\n\n for (const locale of locales) {\n const value = translations[locale];\n\n if (value === null) {\n // Entire locale content is a null placeholder.\n // Flag only when some other locale already has real content.\n if (hasAnyDefinedValue) {\n onMissingLocale(locale);\n }\n continue;\n }\n\n if (!value) {\n // undefined / entirely absent\n onMissingLocale(locale);\n continue;\n }\n\n let flagged = false;\n\n // Structural check: every key that exists in any locale must also exist here\n // (even if the local value is null — at least the key must be present).\n for (const pathStr of presentPaths) {\n if (!hasKey(value, JSON.parse(pathStr))) {\n onMissingLocale(locale);\n flagged = true;\n break;\n }\n }\n\n if (!flagged) {\n // Value check: every key that has a non-null value in some locale must also\n // be non-null here (null = untranslated, needs filling).\n for (const pathStr of nonNullPaths) {\n if (!hasNonNullValue(value, JSON.parse(pathStr))) {\n onMissingLocale(locale);\n break;\n }\n }\n }\n }\n\n // Continue traversal inside the translation values\n for (const key in translations) {\n const child = translations[key];\n deepTransformNode(child, {\n ...props,\n children: child,\n });\n }\n\n // Return the original node; the return value is ignored by the caller\n return node;\n },\n});\n\n/**\n * Return the content of a node with only the translation plugin.\n *\n * @param node The node to transform.\n * @param locales The locales to check for missing translations.\n */\nexport const getMissingLocalesContent = <T extends ContentNode>(\n node: T,\n locales: LocalesValues[] = configuration?.internationalization?.locales,\n nodeProps: NodeProps\n): Locale[] => {\n const missingLocales = new Set<Locale>();\n\n const plugins: Plugins[] = [\n checkMissingLocalesPlugin(locales as Locale[], (locale) =>\n missingLocales.add(locale)\n ),\n ...(nodeProps.plugins ?? []),\n ];\n\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n\n return Array.from(missingLocales);\n};\n\nexport const getMissingLocalesContentFromDictionary = (\n dictionary: Dictionary,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n) =>\n getMissingLocalesContent(dictionary.content, locales, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n });\n"],"mappings":"0KAcA,MAAM,GAAkB,EAAU,EAAmB,EAAE,GACjD,OAAO,GAAQ,WAAY,GAAgB,MAAM,QAAQ,EAAI,CACxD,EAAE,CAGJ,OAAO,KAAK,EAAI,CAAC,QAAS,GAAQ,CACvC,IAAM,EAAU,CAAC,GAAG,EAAQ,EAAI,CAC1B,EAAQ,EAAI,GAKlB,OAHI,IAAU,KACL,CAAC,EAAQ,CAEX,CAAC,EAAS,GAAG,EAAe,EAAO,EAAQ,CAAC,EACnD,CAQE,GAAsB,EAAU,EAAmB,EAAE,GACrD,OAAO,GAAQ,WAAY,GAAgB,MAAM,QAAQ,EAAI,CACxD,EAAE,CAGJ,OAAO,KAAK,EAAI,CAAC,QAAS,GAAQ,CACvC,IAAM,EAAU,CAAC,GAAG,EAAQ,EAAI,CAC1B,EAAQ,EAAI,GAKlB,OAHI,IAAU,KACL,EAAE,CAEJ,CAAC,EAAS,GAAG,EAAmB,EAAO,EAAQ,CAAC,EACvD,CAOE,GAAU,EAAU,IAA+B,CACvD,IAAI,EAAU,EACd,IAAK,IAAM,KAAO,EAAS,CAQzB,GAJE,OAAO,GAAY,WAFnB,GAME,EAAE,KAAO,GACX,MAAO,GAET,EAAU,EAAQ,GAEpB,MAAO,IAOH,GAAmB,EAAU,IAA+B,CAChE,IAAI,EAAU,EACd,IAAK,IAAM,KAAO,EAAS,CAQzB,GAJE,OAAO,GAAY,WAFnB,GAME,EAAE,KAAO,GACX,MAAO,GAET,EAAU,EAAQ,GAGpB,OAAO,IAAY,MAIR,GACX,EACA,KACa,CACb,GAAI,+BACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,YAC1D,WAAY,EAA0B,EAAO,IAAsB,CACjE,IAAM,EAAe,EAAK,EAAS,aAa7B,EAAe,IAAI,IACnB,EAAe,IAAI,IAEzB,IAAK,IAAM,KAAU,EAAS,CAC5B,IAAM,EAAQ,EAAa,GACvB,GAAS,OAAO,GAAU,UAAY,CAAC,MAAM,QAAQ,EAAM,GAC7D,EAAe,EAAM,CAAC,QAAS,GAAS,CACtC,EAAa,IAAI,KAAK,UAAU,EAAK,CAAC,EACtC,CAEF,EAAmB,EAAM,CAAC,QAAS,GAAS,CAC1C,EAAa,IAAI,KAAK,UAAU,EAAK,CAAC,EACtC,EAMN,IAAM,EAAqB,EAAQ,KAChC,GACC,EAAa,KAAY,IAAA,IAAa,EAAa,KAAY,KAClE,CAED,IAAK,IAAM,KAAU,EAAS,CAC5B,IAAM,EAAQ,EAAa,GAE3B,GAAI,IAAU,KAAM,CAGd,GACF,EAAgB,EAAO,CAEzB,SAGF,GAAI,CAAC,EAAO,CAEV,EAAgB,EAAO,CACvB,SAGF,IAAI,EAAU,GAId,IAAK,IAAM,KAAW,EACpB,GAAI,CAAC,EAAO,EAAO,KAAK,MAAM,EAAQ,CAAC,CAAE,CACvC,EAAgB,EAAO,CACvB,EAAU,GACV,MAIJ,GAAI,CAAC,OAGE,IAAM,KAAW,EACpB,GAAI,CAAC,EAAgB,EAAO,KAAK,MAAM,EAAQ,CAAC,CAAE,CAChD,EAAgB,EAAO,CACvB,QAOR,IAAK,IAAM,KAAO,EAAc,CAC9B,IAAM,EAAQ,EAAa,GAC3B,EAAkB,EAAO,CACvB,GAAG,EACH,SAAU,EACX,CAAC,CAIJ,OAAO,GAEV,EAQY,GACX,EACA,EAA2B,GAAe,sBAAsB,QAChE,IACa,CACb,IAAM,EAAiB,IAAI,IAErB,EAAqB,CACzB,EAA0B,EAAsB,GAC9C,EAAe,IAAI,EAAO,CAC3B,CACD,GAAI,EAAU,SAAW,EAAE,CAC5B,CAOD,OALA,EAAkB,EAAM,CACtB,GAAG,EACH,UACD,CAAC,CAEK,MAAM,KAAK,EAAe,EAGtB,GACX,EACA,EAA2B,GAAe,sBAAsB,UAEhE,EAAyB,EAAW,QAAS,EAAS,CACpD,cAAe,EAAW,IAC1B,QAAS,EAAE,CACZ,CAAC"}
1
+ {"version":3,"file":"getMissingLocalesContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getMissingLocalesContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type { DeepTransformContent, NodeProps, Plugins } from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport type { TranslationContent } from '../transpiler';\n\n/**\n * Returns all key paths present in obj, INCLUDING those whose leaf value is null.\n * Used for structural presence checks (a locale must have every key another locale has,\n * even if the value is a null placeholder).\n */\nconst getAllKeyPaths = (obj: any, prefix: string[] = []): string[][] => {\n if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {\n return [];\n }\n\n return Object.keys(obj).flatMap((key) => {\n const newPath = [...prefix, key];\n const value = obj[key];\n // Stop recursing into null — include the path but don't descend further\n if (value === null) {\n return [newPath];\n }\n return [newPath, ...getAllKeyPaths(value, newPath)];\n });\n};\n\n/**\n * Returns key paths whose leaf value is non-null.\n * Used for translation value checks (a locale must not have null where another locale\n * already has a real translated value).\n */\nconst getNonNullKeyPaths = (obj: any, prefix: string[] = []): string[][] => {\n if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {\n return [];\n }\n\n return Object.keys(obj).flatMap((key) => {\n const newPath = [...prefix, key];\n const value = obj[key];\n // Skip null-valued keys entirely\n if (value === null) {\n return [];\n }\n return [newPath, ...getNonNullKeyPaths(value, newPath)];\n });\n};\n\n/**\n * Returns true if the key path EXISTS in obj (even if the terminal value is null).\n * Used for the structural presence check.\n */\nconst hasKey = (obj: any, keyPath: string[]): boolean => {\n let current = obj;\n for (const key of keyPath) {\n if (\n current === undefined ||\n current === null ||\n typeof current !== 'object'\n ) {\n return false;\n }\n if (!(key in current)) {\n return false;\n }\n current = current[key];\n }\n return true; // key exists; value may be null\n};\n\n/**\n * Returns true if the key path exists in obj AND the terminal value is non-null.\n * Used for the translation value check.\n */\nconst hasNonNullValue = (obj: any, keyPath: string[]): boolean => {\n let current = obj;\n for (const key of keyPath) {\n if (\n current === undefined ||\n current === null ||\n typeof current !== 'object'\n ) {\n return false;\n }\n if (!(key in current)) {\n return false;\n }\n current = current[key];\n }\n // null is treated as a missing translation (e.g., i18next-scanner sets null for untranslated keys)\n return current !== null;\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const checkMissingLocalesPlugin = (\n locales: Locale[],\n onMissingLocale: (locale: Locale) => void\n): Plugins => ({\n id: 'check-missing-locales-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const translations = node[NodeTypes.TRANSLATION] as Record<string, any>;\n\n /**\n * Two path sets built from all locales' content:\n *\n * presentPaths — every key path that exists in ANY locale, even those whose value\n * is null. A locale that is missing a path from this set is structurally incomplete\n * (the key doesn't exist at all).\n *\n * nonNullPaths — every key path that has a non-null value in at least one locale.\n * A locale that has the key but with null, when another locale already has a real\n * value, needs translation.\n */\n const presentPaths = new Set<string>();\n const nonNullPaths = new Set<string>();\n\n for (const locale of locales) {\n const value = translations[locale];\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n getAllKeyPaths(value).forEach((path) => {\n presentPaths.add(JSON.stringify(path));\n });\n\n getNonNullKeyPaths(value).forEach((path) => {\n nonNullPaths.add(JSON.stringify(path));\n });\n }\n }\n\n // If no locale has any content at all (all are null/undefined), the key is\n // universally pending — don't flag anyone.\n const hasAnyDefinedValue = locales.some(\n (locale) =>\n translations[locale] !== undefined && translations[locale] !== null\n );\n\n for (const locale of locales) {\n const value = translations[locale];\n\n if (value === null) {\n // Entire locale content is a null placeholder.\n // Flag only when some other locale already has real content.\n if (hasAnyDefinedValue) {\n onMissingLocale(locale);\n }\n continue;\n }\n\n if (!value) {\n // undefined / entirely absent\n onMissingLocale(locale);\n continue;\n }\n\n let flagged = false;\n\n // Structural check: every key that exists in any locale must also exist here\n // (even if the local value is null — at least the key must be present).\n for (const pathStr of presentPaths) {\n if (!hasKey(value, JSON.parse(pathStr))) {\n onMissingLocale(locale);\n flagged = true;\n break;\n }\n }\n\n if (!flagged) {\n // Value check: every key that has a non-null value in some locale must also\n // be non-null here (null = untranslated, needs filling).\n for (const pathStr of nonNullPaths) {\n if (!hasNonNullValue(value, JSON.parse(pathStr))) {\n onMissingLocale(locale);\n break;\n }\n }\n }\n }\n\n // Continue traversal inside the translation values\n for (const key in translations) {\n const child = translations[key];\n deepTransformNode(child, {\n ...props,\n children: child,\n });\n }\n\n // Return the original node; the return value is ignored by the caller\n return node;\n },\n});\n\n/**\n * Return the content of a node with only the translation plugin.\n *\n * @param node The node to transform.\n * @param locales The locales to check for missing translations.\n */\nexport const getMissingLocalesContent = <T extends ContentNode>(\n node: T,\n locales: LocalesValues[] = configuration?.internationalization?.locales,\n nodeProps: NodeProps\n): Locale[] => {\n const missingLocales = new Set<Locale>();\n\n const plugins: Plugins[] = [\n checkMissingLocalesPlugin(locales as Locale[], (locale) =>\n missingLocales.add(locale)\n ),\n ...(nodeProps.plugins ?? []),\n ];\n\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n\n return Array.from(missingLocales);\n};\n\nexport const getMissingLocalesContentFromDictionary = (\n dictionary: Dictionary,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n) =>\n getMissingLocalesContent(dictionary.content, locales, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n });\n"],"mappings":"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"}
@@ -1,2 +1,87 @@
1
- import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";import{t}from"../transpiler/translation/translation.mjs";const n=n=>{if(!n.locale)return n;let r=n.locale,i=e(JSON.parse(JSON.stringify(n.content)),{dictionaryKey:n.key,keyPath:[],plugins:[{id:`traverse-typed-node-plugin`,canHandle:e=>typeof e==`object`&&typeof e?.nodeType==`string`,transform:(e,t,n)=>{let r=e.nodeType,i=structuredClone(e[r]);if(typeof i!=`object`||!i){let a=n(i,{...t,children:i,keyPath:[...t.keyPath,{type:r,key:r}]});return{...e,[r]:a}}for(let e in i){let a={...t,children:i[e],keyPath:[...t.keyPath,{type:r,key:e}]};i[e]=n(i[e],a)}return{...e,[r]:i}}},{id:`wrap-primitive-in-translation`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,transform:e=>t({[r]:e})}]}),{locale:a,...o}=n;return{...o,content:i}};export{n as getMultilingualDictionary};
1
+ import { deepTransformNode } from "../interpreter/getContent/deepTransform.mjs";
2
+ import { t as translation } from "../transpiler/translation/translation.mjs";
3
+
4
+ //#region src/deepTransformPlugins/getMultilingualDictionary.ts
5
+ /**
6
+ * Transform a per-locale dictionary into a multilingual dictionary.
7
+ *
8
+ * Example:
9
+ * ```json
10
+ * {
11
+ * "key": "about-page",
12
+ * "locale": "en",
13
+ * "content": {
14
+ * "myContent": "English content"
15
+ * }
16
+ * }
17
+ * ```
18
+ *
19
+ * ```json
20
+ * {
21
+ * "key": "about-page",
22
+ * "content": {
23
+ * "myContent": t({
24
+ * "en": "English content",
25
+ * })
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ const getMultilingualDictionary = (dictionary) => {
31
+ if (!dictionary.locale) return dictionary;
32
+ const locale = dictionary.locale;
33
+ const transformedContent = deepTransformNode(JSON.parse(JSON.stringify(dictionary.content)), {
34
+ dictionaryKey: dictionary.key,
35
+ keyPath: [],
36
+ plugins: [{
37
+ id: "traverse-typed-node-plugin",
38
+ canHandle: (node) => typeof node === "object" && typeof node?.nodeType === "string",
39
+ transform: (node, props, transformFn) => {
40
+ const nodeType = node.nodeType;
41
+ const inner = structuredClone(node[nodeType]);
42
+ if (typeof inner !== "object" || inner === null) {
43
+ const transformed = transformFn(inner, {
44
+ ...props,
45
+ children: inner,
46
+ keyPath: [...props.keyPath, {
47
+ type: nodeType,
48
+ key: nodeType
49
+ }]
50
+ });
51
+ return {
52
+ ...node,
53
+ [nodeType]: transformed
54
+ };
55
+ }
56
+ for (const key in inner) {
57
+ const childProps = {
58
+ ...props,
59
+ children: inner[key],
60
+ keyPath: [...props.keyPath, {
61
+ type: nodeType,
62
+ key
63
+ }]
64
+ };
65
+ inner[key] = transformFn(inner[key], childProps);
66
+ }
67
+ return {
68
+ ...node,
69
+ [nodeType]: inner
70
+ };
71
+ }
72
+ }, {
73
+ id: "wrap-primitive-in-translation",
74
+ canHandle: (node) => typeof node === "string" || typeof node === "number" || typeof node === "boolean",
75
+ transform: (node) => translation({ [locale]: node })
76
+ }]
77
+ });
78
+ const { locale: _omitLocale, ...rest } = dictionary;
79
+ return {
80
+ ...rest,
81
+ content: transformedContent
82
+ };
83
+ };
84
+
85
+ //#endregion
86
+ export { getMultilingualDictionary };
2
87
  //# sourceMappingURL=getMultilingualDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getMultilingualDictionary.mjs","names":["t"],"sources":["../../../src/deepTransformPlugins/getMultilingualDictionary.ts"],"sourcesContent":["import type { Dictionary, TypedNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { t } from '../transpiler';\n\n/**\n * Transform a per-locale dictionary into a multilingual dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"myContent\": \"English content\"\n * }\n * }\n * ```\n *\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"content\": {\n * \"myContent\": t({\n * \"en\": \"English content\",\n * })\n * }\n * }\n * ```\n */\nexport const getMultilingualDictionary = (\n dictionary: Dictionary\n): Dictionary => {\n if (!dictionary.locale) {\n return dictionary;\n }\n\n const locale = dictionary.locale;\n\n const wrapPrimitiveInTranslationPlugin: Plugins = {\n id: 'wrap-primitive-in-translation',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: (node) => t({ [locale]: node } as Record<string, unknown>),\n };\n\n const traverseTypedNodePlugin: Plugins = {\n id: 'traverse-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof (node as any)?.nodeType === 'string',\n transform: (node: TypedNode, props, transformFn) => {\n const nodeType = (node as any).nodeType as NodeType;\n const inner = structuredClone(\n (node as any)[nodeType as unknown as keyof TypedNode] as any\n );\n\n if (typeof inner !== 'object' || inner === null) {\n const transformed = transformFn(inner, {\n ...props,\n children: inner,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformed,\n };\n }\n\n for (const key in inner) {\n const childProps: NodeProps = {\n ...props,\n children: inner[key as unknown as keyof typeof inner],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n inner[key as unknown as keyof typeof inner] = transformFn(\n inner[key as unknown as keyof typeof inner],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: inner };\n },\n };\n\n const transformedContent = deepTransformNode(\n JSON.parse(JSON.stringify(dictionary.content)),\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [traverseTypedNodePlugin, wrapPrimitiveInTranslationPlugin],\n }\n );\n\n const { locale: _omitLocale, ...rest } = dictionary as any;\n return {\n ...rest,\n content: transformedContent,\n } as Dictionary;\n};\n"],"mappings":"yIAmCA,MAAa,EACX,GACe,CACf,GAAI,CAAC,EAAW,OACd,OAAO,EAGT,IAAM,EAAS,EAAW,OAoDpB,EAAqB,EACzB,KAAK,MAAM,KAAK,UAAU,EAAW,QAAQ,CAAC,CAC9C,CACE,cAAe,EAAW,IAC1B,QAAS,EAAE,CACX,QAAS,CA9C4B,CACvC,GAAI,6BACJ,UAAY,GACV,OAAO,GAAS,UAAY,OAAQ,GAAc,UAAa,SACjE,WAAY,EAAiB,EAAO,IAAgB,CAClD,IAAM,EAAY,EAAa,SACzB,EAAQ,gBACX,EAAa,GACf,CAED,GAAI,OAAO,GAAU,WAAY,EAAgB,CAC/C,IAAM,EAAc,EAAY,EAAO,CACrC,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAU,IAAK,EAAU,CAClC,CACF,CAAC,CACF,MAAO,CACL,GAAG,GACF,GAAyC,EAC3C,CAGH,IAAK,IAAM,KAAO,EAAO,CACvB,IAAM,EAAwB,CAC5B,GAAG,EACH,SAAU,EAAM,GAChB,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAU,MAAK,CAAY,CAChE,CACD,EAAM,GAAwC,EAC5C,EAAM,GACN,EACD,CAGH,MAAO,CAAE,GAAG,GAAO,GAAyC,EAAO,EAEtE,CAhDiD,CAChD,GAAI,gCACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,UAClB,UAAY,GAASA,EAAE,EAAG,GAAS,EAAM,CAA4B,CACtE,CAgDuE,CACrE,CACF,CAEK,CAAE,OAAQ,EAAa,GAAG,GAAS,EACzC,MAAO,CACL,GAAG,EACH,QAAS,EACV"}
1
+ {"version":3,"file":"getMultilingualDictionary.mjs","names":["t"],"sources":["../../../src/deepTransformPlugins/getMultilingualDictionary.ts"],"sourcesContent":["import type { Dictionary, TypedNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { t } from '../transpiler';\n\n/**\n * Transform a per-locale dictionary into a multilingual dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"myContent\": \"English content\"\n * }\n * }\n * ```\n *\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"content\": {\n * \"myContent\": t({\n * \"en\": \"English content\",\n * })\n * }\n * }\n * ```\n */\nexport const getMultilingualDictionary = (\n dictionary: Dictionary\n): Dictionary => {\n if (!dictionary.locale) {\n return dictionary;\n }\n\n const locale = dictionary.locale;\n\n const wrapPrimitiveInTranslationPlugin: Plugins = {\n id: 'wrap-primitive-in-translation',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: (node) => t({ [locale]: node } as Record<string, unknown>),\n };\n\n const traverseTypedNodePlugin: Plugins = {\n id: 'traverse-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof (node as any)?.nodeType === 'string',\n transform: (node: TypedNode, props, transformFn) => {\n const nodeType = (node as any).nodeType as NodeType;\n const inner = structuredClone(\n (node as any)[nodeType as unknown as keyof TypedNode] as any\n );\n\n if (typeof inner !== 'object' || inner === null) {\n const transformed = transformFn(inner, {\n ...props,\n children: inner,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformed,\n };\n }\n\n for (const key in inner) {\n const childProps: NodeProps = {\n ...props,\n children: inner[key as unknown as keyof typeof inner],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n inner[key as unknown as keyof typeof inner] = transformFn(\n inner[key as unknown as keyof typeof inner],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: inner };\n },\n };\n\n const transformedContent = deepTransformNode(\n JSON.parse(JSON.stringify(dictionary.content)),\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [traverseTypedNodePlugin, wrapPrimitiveInTranslationPlugin],\n }\n );\n\n const { locale: _omitLocale, ...rest } = dictionary as any;\n return {\n ...rest,\n content: transformedContent,\n } as Dictionary;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,6BACX,eACe;AACf,KAAI,CAAC,WAAW,OACd,QAAO;CAGT,MAAM,SAAS,WAAW;CAoD1B,MAAM,qBAAqB,kBACzB,KAAK,MAAM,KAAK,UAAU,WAAW,QAAQ,CAAC,EAC9C;EACE,eAAe,WAAW;EAC1B,SAAS,EAAE;EACX,SAAS,CA9C4B;GACvC,IAAI;GACJ,YAAY,SACV,OAAO,SAAS,YAAY,OAAQ,MAAc,aAAa;GACjE,YAAY,MAAiB,OAAO,gBAAgB;IAClD,MAAM,WAAY,KAAa;IAC/B,MAAM,QAAQ,gBACX,KAAa,UACf;AAED,QAAI,OAAO,UAAU,YAAY,UAAU,MAAM;KAC/C,MAAM,cAAc,YAAY,OAAO;MACrC,GAAG;MACH,UAAU;MACV,SAAS,CACP,GAAG,MAAM,SACT;OAAE,MAAM;OAAU,KAAK;OAAU,CAClC;MACF,CAAC;AACF,YAAO;MACL,GAAG;OACF,WAAyC;MAC3C;;AAGH,SAAK,MAAM,OAAO,OAAO;KACvB,MAAM,aAAwB;MAC5B,GAAG;MACH,UAAU,MAAM;MAChB,SAAS,CAAC,GAAG,MAAM,SAAS;OAAE,MAAM;OAAU;OAAK,CAAY;MAChE;AACD,WAAM,OAAwC,YAC5C,MAAM,MACN,WACD;;AAGH,WAAO;KAAE,GAAG;MAAO,WAAyC;KAAO;;GAEtE,EAhDiD;GAChD,IAAI;GACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;GAClB,YAAY,SAASA,YAAE,GAAG,SAAS,MAAM,CAA4B;GACtE,CAgDuE;EACrE,CACF;CAED,MAAM,EAAE,QAAQ,aAAa,GAAG,SAAS;AACzC,QAAO;EACL,GAAG;EACH,SAAS;EACV"}
@@ -1,2 +1,60 @@
1
- import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";const t=e=>({id:`replace-values-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,transform:()=>e}),n={id:`skip-typed-node-plugin`,canHandle:e=>typeof e==`object`&&typeof e?.nodeType==`string`,transform:(e,t,n)=>{let r=e.nodeType,i=structuredClone(e[r]);if(typeof i!=`object`||!i){let a=n(i,{...t,children:i,keyPath:[...t.keyPath,{type:r,key:r}]});return{...e,[r]:a}}for(let e in i){let a={...t,children:i[e],keyPath:[...t.keyPath,{type:r,key:e}]};i[e]=n(i[e],a)}return{...e,[r]:i}}},r=(r,i,a)=>{let o=[n,t(i),...a.plugins??[]];return e(JSON.parse(JSON.stringify(r)),{...a,plugins:o})};export{r as getReplacedValuesContent};
1
+ import { deepTransformNode } from "../interpreter/getContent/deepTransform.mjs";
2
+
3
+ //#region src/deepTransformPlugins/getReplacedValuesContent.ts
4
+ const replaceValuesPlugin = (value) => ({
5
+ id: "replace-values-plugin",
6
+ canHandle: (node) => typeof node === "string" || typeof node === "number" || typeof node === "boolean",
7
+ transform: () => value
8
+ });
9
+ const skipTypedNodePlugin = {
10
+ id: "skip-typed-node-plugin",
11
+ canHandle: (node) => typeof node === "object" && typeof node?.nodeType === "string",
12
+ transform: (node, props, deepTransformNode) => {
13
+ const nodeType = node.nodeType;
14
+ const result = structuredClone(node[nodeType]);
15
+ if (typeof result !== "object" || result === null) {
16
+ const transformedResult = deepTransformNode(result, {
17
+ ...props,
18
+ children: result,
19
+ keyPath: [...props.keyPath, {
20
+ type: nodeType,
21
+ key: nodeType
22
+ }]
23
+ });
24
+ return {
25
+ ...node,
26
+ [nodeType]: transformedResult
27
+ };
28
+ }
29
+ for (const key in result) {
30
+ const childProps = {
31
+ ...props,
32
+ children: result[key],
33
+ keyPath: [...props.keyPath, {
34
+ type: nodeType,
35
+ key
36
+ }]
37
+ };
38
+ result[key] = deepTransformNode(result[key], childProps);
39
+ }
40
+ return {
41
+ ...node,
42
+ [nodeType]: result
43
+ };
44
+ }
45
+ };
46
+ const getReplacedValuesContent = (node, value, nodeProps) => {
47
+ const plugins = [
48
+ skipTypedNodePlugin,
49
+ replaceValuesPlugin(value),
50
+ ...nodeProps.plugins ?? []
51
+ ];
52
+ return deepTransformNode(JSON.parse(JSON.stringify(node)), {
53
+ ...nodeProps,
54
+ plugins
55
+ });
56
+ };
57
+
58
+ //#endregion
59
+ export { getReplacedValuesContent };
2
60
  //# sourceMappingURL=getReplacedValuesContent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getReplacedValuesContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getReplacedValuesContent.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\n\nconst replaceValuesPlugin = (value: string | number | boolean): Plugins => ({\n id: 'replace-values-plugin',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: () => value,\n});\n\nconst skipTypedNodePlugin: Plugins = {\n id: 'skip-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node: TypedNode, props, deepTransformNode) => {\n const nodeType = node.nodeType as NodeType;\n const result = structuredClone(\n node[nodeType as unknown as keyof TypedNode] as any\n );\n\n // If the result is a primitive value (string, number, boolean),\n // we need to transform it directly instead of iterating over its properties\n if (typeof result !== 'object' || result === null) {\n const transformedResult = deepTransformNode(result, {\n ...props,\n children: result,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformedResult,\n };\n }\n\n // For objects and arrays, iterate over their properties\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: result };\n },\n};\n\nexport const getReplacedValuesContent = (\n node: ContentNode,\n value: string | number | boolean,\n nodeProps: NodeProps\n) => {\n const plugins: Plugins[] = [\n skipTypedNodePlugin,\n replaceValuesPlugin(value),\n ...(nodeProps.plugins ?? []),\n ];\n\n const JSONNode = JSON.parse(JSON.stringify(node));\n\n return deepTransformNode(JSONNode, {\n ...nodeProps,\n plugins,\n });\n};\n"],"mappings":"gFASA,MAAM,EAAuB,IAA+C,CAC1E,GAAI,wBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,UAClB,cAAiB,EAClB,EAEK,EAA+B,CACnC,GAAI,yBACJ,UAAY,GACV,OAAO,GAAS,UAAY,OAAO,GAAM,UAAa,SACxD,WAAY,EAAiB,EAAO,IAAsB,CACxD,IAAM,EAAW,EAAK,SAChB,EAAS,gBACb,EAAK,GACN,CAID,GAAI,OAAO,GAAW,WAAY,EAAiB,CACjD,IAAM,EAAoB,EAAkB,EAAQ,CAClD,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAU,IAAK,EAAU,CAClC,CACF,CAAC,CACF,MAAO,CACL,GAAG,GACF,GAAyC,EAC3C,CAIH,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAO,GACjB,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAU,MAAK,CAAY,CAChE,CACD,EAAO,GAAyC,EAC9C,EAAO,GACP,EACD,CAGH,MAAO,CAAE,GAAG,GAAO,GAAyC,EAAQ,EAEvE,CAEY,GACX,EACA,EACA,IACG,CACH,IAAM,EAAqB,CACzB,EACA,EAAoB,EAAM,CAC1B,GAAI,EAAU,SAAW,EAAE,CAC5B,CAID,OAAO,EAFU,KAAK,MAAM,KAAK,UAAU,EAAK,CAAC,CAEd,CACjC,GAAG,EACH,UACD,CAAC"}
1
+ {"version":3,"file":"getReplacedValuesContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getReplacedValuesContent.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\n\nconst replaceValuesPlugin = (value: string | number | boolean): Plugins => ({\n id: 'replace-values-plugin',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: () => value,\n});\n\nconst skipTypedNodePlugin: Plugins = {\n id: 'skip-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node: TypedNode, props, deepTransformNode) => {\n const nodeType = node.nodeType as NodeType;\n const result = structuredClone(\n node[nodeType as unknown as keyof TypedNode] as any\n );\n\n // If the result is a primitive value (string, number, boolean),\n // we need to transform it directly instead of iterating over its properties\n if (typeof result !== 'object' || result === null) {\n const transformedResult = deepTransformNode(result, {\n ...props,\n children: result,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformedResult,\n };\n }\n\n // For objects and arrays, iterate over their properties\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: result };\n },\n};\n\nexport const getReplacedValuesContent = (\n node: ContentNode,\n value: string | number | boolean,\n nodeProps: NodeProps\n) => {\n const plugins: Plugins[] = [\n skipTypedNodePlugin,\n replaceValuesPlugin(value),\n ...(nodeProps.plugins ?? []),\n ];\n\n const JSONNode = JSON.parse(JSON.stringify(node));\n\n return deepTransformNode(JSONNode, {\n ...nodeProps,\n plugins,\n });\n};\n"],"mappings":";;;AASA,MAAM,uBAAuB,WAA+C;CAC1E,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,iBAAiB;CAClB;AAED,MAAM,sBAA+B;CACnC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,OAAO,MAAM,aAAa;CACxD,YAAY,MAAiB,OAAO,sBAAsB;EACxD,MAAM,WAAW,KAAK;EACtB,MAAM,SAAS,gBACb,KAAK,UACN;AAID,MAAI,OAAO,WAAW,YAAY,WAAW,MAAM;GACjD,MAAM,oBAAoB,kBAAkB,QAAQ;IAClD,GAAG;IACH,UAAU;IACV,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM;KAAU,KAAK;KAAU,CAClC;IACF,CAAC;AACF,UAAO;IACL,GAAG;KACF,WAAyC;IAC3C;;AAIH,OAAK,MAAM,OAAO,QAAQ;GACxB,MAAM,aAAa;IACjB,GAAG;IACH,UAAU,OAAO;IACjB,SAAS,CAAC,GAAG,MAAM,SAAS;KAAE,MAAM;KAAU;KAAK,CAAY;IAChE;AACD,UAAO,OAAyC,kBAC9C,OAAO,MACP,WACD;;AAGH,SAAO;GAAE,GAAG;IAAO,WAAyC;GAAQ;;CAEvE;AAED,MAAa,4BACX,MACA,OACA,cACG;CACH,MAAM,UAAqB;EACzB;EACA,oBAAoB,MAAM;EAC1B,GAAI,UAAU,WAAW,EAAE;EAC5B;AAID,QAAO,kBAFU,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,EAEd;EACjC,GAAG;EACH;EACD,CAAC"}
@@ -1,2 +1,120 @@
1
- import{NodeType as e}from"@intlayer/types/nodeType";const t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=e=>t(e)&&typeof e.nodeType==`string`,r=(e,i)=>{if(e===void 0)return i;if(i===void 0)return e;if(Array.isArray(e)&&Array.isArray(i))return[...e,...i];if(t(e)&&t(i)&&!n(e)&&!n(i)){let t={...e};for(let e of Object.keys(i))t[e]=r(t[e],i[e]);return t}return i},i=(e,t)=>{let n={...e};n.common=r(e.common,t.common);let i=new Set([...Object.keys(e).filter(e=>e!==`common`),...Object.keys(t).filter(e=>e!==`common`)]);for(let a of i)n[a]=r(e[a],t[a]);return n},a=o=>{if(t(o)&&o?.nodeType===e.Translation){let t=o[e.Translation],n={};for(let e of Object.keys(t)){let i=t[e],o=a(i),s=r(o.common,void 0),c;for(let e of Object.keys(o))e!==`common`&&(c=r(c,o[e]));let l=r(s,c);l!==void 0&&(n[e]=l)}return n}if(Array.isArray(o)){let e=[],t={};o.forEach(n=>{let r=a(n);r.common!==void 0&&e.push(r.common);for(let e of Object.keys(r)){if(e===`common`)continue;t[e]||(t[e]=[]);let n=r[e];n!==void 0&&t[e].push(n)}});let n={};e.length>0&&(n.common=e);for(let e of Object.keys(t))n[e]=t[e];return n}if(t(o)&&!n(o)){let e={};for(let t of Object.keys(o)){let n=a(o[t]);n.common!==void 0&&(e=i(e,{common:{[t]:n.common}}));for(let r of Object.keys(n))r!==`common`&&(e=i(e,{[r]:{[t]:n[r]}}))}return e}return{common:o}},o=e=>{let t=a(e),n={};t.common!==void 0&&(n.common=t.common);for(let e of Object.keys(t)){if(e===`common`)continue;let r=t[e];r!==void 0&&(n[e]=r)}return n},s=e=>o(e.content);export{o as getSplittedContent,s as getSplittedDictionaryContent};
1
+ import * as NodeTypes from "@intlayer/types/nodeType";
2
+
3
+ //#region src/deepTransformPlugins/getSplittedContent.ts
4
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5
+ const hasNodeType = (value) => isObject(value) && typeof value.nodeType === "string";
6
+ const mergeValues = (a, b) => {
7
+ if (a === void 0) return b;
8
+ if (b === void 0) return a;
9
+ if (Array.isArray(a) && Array.isArray(b)) return [...a, ...b];
10
+ if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {
11
+ const result = { ...a };
12
+ for (const key of Object.keys(b)) result[key] = mergeValues(result[key], b[key]);
13
+ return result;
14
+ }
15
+ return b;
16
+ };
17
+ const mergeSplitResults = (base, addition) => {
18
+ const result = { ...base };
19
+ result.common = mergeValues(base.common, addition.common);
20
+ const localeKeys = new Set([...Object.keys(base).filter((k) => k !== "common"), ...Object.keys(addition).filter((k) => k !== "common")]);
21
+ for (const key of localeKeys) result[key] = mergeValues(base[key], addition[key]);
22
+ return result;
23
+ };
24
+ const splitNode = (node) => {
25
+ if (isObject(node) && node?.nodeType === NodeTypes.TRANSLATION) {
26
+ const translations = node[NodeTypes.TRANSLATION];
27
+ const result = {};
28
+ for (const locale of Object.keys(translations)) {
29
+ const child = translations[locale];
30
+ const childSplit = splitNode(child);
31
+ const mergedForLocale = mergeValues(childSplit.common, void 0);
32
+ let recomposed;
33
+ for (const key of Object.keys(childSplit)) {
34
+ if (key === "common") continue;
35
+ recomposed = mergeValues(recomposed, childSplit[key]);
36
+ }
37
+ const finalLocaleNode = mergeValues(mergedForLocale, recomposed);
38
+ if (finalLocaleNode !== void 0) result[locale] = finalLocaleNode;
39
+ }
40
+ return result;
41
+ }
42
+ if (Array.isArray(node)) {
43
+ const commonArray = [];
44
+ const perLocaleArrays = {};
45
+ node.forEach((child) => {
46
+ const childSplit = splitNode(child);
47
+ if (childSplit.common !== void 0) commonArray.push(childSplit.common);
48
+ for (const key of Object.keys(childSplit)) {
49
+ if (key === "common") continue;
50
+ if (!perLocaleArrays[key]) perLocaleArrays[key] = [];
51
+ const value = childSplit[key];
52
+ if (value !== void 0) perLocaleArrays[key].push(value);
53
+ }
54
+ });
55
+ const result = {};
56
+ if (commonArray.length > 0) result.common = commonArray;
57
+ for (const key of Object.keys(perLocaleArrays)) result[key] = perLocaleArrays[key];
58
+ return result;
59
+ }
60
+ if (isObject(node) && !hasNodeType(node)) {
61
+ let accumulated = {};
62
+ for (const key of Object.keys(node)) {
63
+ const childSplit = splitNode(node[key]);
64
+ if (childSplit.common !== void 0) accumulated = mergeSplitResults(accumulated, { common: { [key]: childSplit.common } });
65
+ for (const locale of Object.keys(childSplit)) {
66
+ if (locale === "common") continue;
67
+ accumulated = mergeSplitResults(accumulated, { [locale]: { [key]: childSplit[locale] } });
68
+ }
69
+ }
70
+ return accumulated;
71
+ }
72
+ return { common: node };
73
+ };
74
+ const getSplittedContent = (content) => {
75
+ const split = splitNode(content);
76
+ const output = {};
77
+ if (split.common !== void 0) output.common = split.common;
78
+ for (const key of Object.keys(split)) {
79
+ if (key === "common") continue;
80
+ const value = split[key];
81
+ if (value !== void 0) output[key] = value;
82
+ }
83
+ return output;
84
+ };
85
+ /**
86
+ * Splits the `content` field of a Dictionary into "common" and per-locale buckets.
87
+ *
88
+ * Given a dictionary like:
89
+ * ```js
90
+ * {
91
+ * key: "my-key",
92
+ * content: {
93
+ * commonContent: "common content",
94
+ * multilingualContent: t({
95
+ * en: "english content",
96
+ * fr: "french content",
97
+ * de: "german content",
98
+ * }),
99
+ * },
100
+ * }
101
+ * ```
102
+ *
103
+ * It produces:
104
+ * ```js
105
+ * {
106
+ * common: { commonContent: "common content" },
107
+ * en: { multilingualContent: "english content" },
108
+ * fr: { multilingualContent: "french content" },
109
+ * de: { multilingualContent: "german content" },
110
+ * }
111
+ * ```
112
+ *
113
+ * @param dictionary - The input dictionary object with possible multilingual or common content.
114
+ * @returns An object mapping "common" and each locale to their corresponding content subtrees.
115
+ */
116
+ const getSplittedDictionaryContent = (dictionary) => getSplittedContent(dictionary.content);
117
+
118
+ //#endregion
119
+ export { getSplittedContent, getSplittedDictionaryContent };
2
120
  //# sourceMappingURL=getSplittedContent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSplittedContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\n\ntype SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {\n common: T;\n};\n\ntype SplitResult = Record<string, ContentNode | undefined> & {\n common?: ContentNode;\n};\n\nconst isObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst hasNodeType = (value: unknown): value is { nodeType: string } =>\n isObject(value) && typeof (value as any).nodeType === 'string';\n\nconst mergeValues = (\n a: ContentNode | undefined,\n b: ContentNode | undefined\n): ContentNode | undefined => {\n if (a === undefined) return b;\n if (b === undefined) return a;\n\n if (Array.isArray(a) && Array.isArray(b)) {\n // Concatenate arrays when merging sibling results\n return [...a, ...b] as unknown as ContentNode;\n }\n\n if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {\n const result: Record<string, any> = { ...a };\n for (const key of Object.keys(b)) {\n result[key] = mergeValues(\n result[key] as unknown as ContentNode | undefined,\n (b as Record<string, any>)[key] as unknown as ContentNode | undefined\n );\n }\n return result as ContentNode;\n }\n\n // For primitives or differing structures, prefer b (more recent)\n return b;\n};\n\nconst mergeSplitResults = (\n base: SplitResult,\n addition: SplitResult\n): SplitResult => {\n const result: SplitResult = { ...base };\n\n // Merge common\n result.common = mergeValues(base.common, addition.common);\n\n // Merge each locale key present in either side\n const localeKeys = new Set<string>([\n ...Object.keys(base).filter((k) => k !== 'common'),\n ...Object.keys(addition).filter((k) => k !== 'common'),\n ]);\n\n for (const key of localeKeys) {\n // @ts-ignore: dynamic keys for locales\n result[key] = mergeValues(\n base[key] as ContentNode | undefined,\n addition[key] as ContentNode | undefined\n );\n }\n\n return result;\n};\n\nconst splitNode = (node: ContentNode): SplitResult => {\n // Translation node: allocate entirely to per-locale buckets\n if (isObject(node) && (node as any)?.nodeType === NodeType.Translation) {\n const translations = (node as any)[NodeType.Translation] as Record<\n string,\n ContentNode\n >;\n\n const result: SplitResult = {};\n for (const locale of Object.keys(translations)) {\n const child = translations[locale];\n const childSplit = splitNode(child);\n\n // The content under a translation belongs to the locale, not common\n // Merge common portion of the child (if any) into the locale as well\n const mergedForLocale = mergeValues(childSplit.common, undefined);\n\n // Compose locale content: prefer the fully rebuilt child by resolving deeper translations recursively\n // which are already split inside childSplit. We need to recompose a single node for this locale.\n // Recompose by merging all keys in childSplit except 'common' into a single node, then merge child's common.\n let recomposed: ContentNode | undefined;\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n recomposed = mergeValues(\n recomposed,\n childSplit[key] as ContentNode | undefined\n );\n }\n const finalLocaleNode = mergeValues(mergedForLocale, recomposed);\n\n if (finalLocaleNode !== undefined) {\n // @ts-ignore dynamic locale key\n result[locale] = finalLocaleNode;\n }\n }\n\n return result;\n }\n\n // Arrays: split each element and merge results index-wise\n if (Array.isArray(node)) {\n const commonArray: any[] = [];\n const perLocaleArrays: Record<string, any[]> = {};\n\n node.forEach((child) => {\n const childSplit = splitNode(child as ContentNode);\n\n if (childSplit.common !== undefined) {\n commonArray.push(childSplit.common);\n }\n\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n if (!perLocaleArrays[key]) perLocaleArrays[key] = [];\n const value = childSplit[key];\n if (value !== undefined) perLocaleArrays[key].push(value);\n }\n });\n\n const result: SplitResult = {};\n if (commonArray.length > 0)\n result.common = commonArray as unknown as ContentNode;\n for (const key of Object.keys(perLocaleArrays)) {\n // @ts-ignore dynamic locale key\n result[key] = perLocaleArrays[key] as unknown as ContentNode;\n }\n return result;\n }\n\n // Objects (non-typed): recursively split properties\n if (isObject(node) && !hasNodeType(node)) {\n let accumulated: SplitResult = {};\n\n for (const key of Object.keys(node)) {\n const childSplit = splitNode((node as any)[key] as ContentNode);\n\n // Assign property into common\n if (childSplit.common !== undefined) {\n accumulated = mergeSplitResults(accumulated, {\n common: { [key]: childSplit.common } as unknown as ContentNode,\n });\n }\n\n // Assign property into each locale bucket\n for (const locale of Object.keys(childSplit)) {\n if (locale === 'common') continue;\n accumulated = mergeSplitResults(accumulated, {\n // @ts-ignore dynamic locale key\n [locale]: { [key]: childSplit[locale] } as unknown as ContentNode,\n });\n }\n }\n\n return accumulated;\n }\n\n // Primitives or typed nodes (non-translation): entirely common\n return { common: node } as SplitResult;\n};\n\nexport const getSplittedContent = (\n content: ContentNode\n): SplittedContentOutput => {\n const split = splitNode(content);\n\n // Build final output with only defined sections\n const output: Record<string, ContentNode> = {};\n if (split.common !== undefined) {\n output.common = split.common;\n }\n for (const key of Object.keys(split)) {\n if (key === 'common') continue;\n const value = split[key] as ContentNode | undefined;\n if (value !== undefined) {\n output[key] = value;\n }\n }\n\n return output as unknown as SplittedContentOutput;\n};\n\n/**\n * Splits the `content` field of a Dictionary into \"common\" and per-locale buckets.\n *\n * Given a dictionary like:\n * ```js\n * {\n * key: \"my-key\",\n * content: {\n * commonContent: \"common content\",\n * multilingualContent: t({\n * en: \"english content\",\n * fr: \"french content\",\n * de: \"german content\",\n * }),\n * },\n * }\n * ```\n *\n * It produces:\n * ```js\n * {\n * common: { commonContent: \"common content\" },\n * en: { multilingualContent: \"english content\" },\n * fr: { multilingualContent: \"french content\" },\n * de: { multilingualContent: \"german content\" },\n * }\n * ```\n *\n * @param dictionary - The input dictionary object with possible multilingual or common content.\n * @returns An object mapping \"common\" and each locale to their corresponding content subtrees.\n */\nexport const getSplittedDictionaryContent = (\n dictionary: Dictionary\n): SplittedContentOutput<Dictionary['content']> =>\n getSplittedContent(dictionary.content);\n"],"mappings":"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"}
1
+ {"version":3,"file":"getSplittedContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\ntype SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {\n common: T;\n};\n\ntype SplitResult = Record<string, ContentNode | undefined> & {\n common?: ContentNode;\n};\n\nconst isObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst hasNodeType = (value: unknown): value is { nodeType: string } =>\n isObject(value) && typeof (value as any).nodeType === 'string';\n\nconst mergeValues = (\n a: ContentNode | undefined,\n b: ContentNode | undefined\n): ContentNode | undefined => {\n if (a === undefined) return b;\n if (b === undefined) return a;\n\n if (Array.isArray(a) && Array.isArray(b)) {\n // Concatenate arrays when merging sibling results\n return [...a, ...b] as unknown as ContentNode;\n }\n\n if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {\n const result: Record<string, any> = { ...a };\n for (const key of Object.keys(b)) {\n result[key] = mergeValues(\n result[key] as unknown as ContentNode | undefined,\n (b as Record<string, any>)[key] as unknown as ContentNode | undefined\n );\n }\n return result as ContentNode;\n }\n\n // For primitives or differing structures, prefer b (more recent)\n return b;\n};\n\nconst mergeSplitResults = (\n base: SplitResult,\n addition: SplitResult\n): SplitResult => {\n const result: SplitResult = { ...base };\n\n // Merge common\n result.common = mergeValues(base.common, addition.common);\n\n // Merge each locale key present in either side\n const localeKeys = new Set<string>([\n ...Object.keys(base).filter((k) => k !== 'common'),\n ...Object.keys(addition).filter((k) => k !== 'common'),\n ]);\n\n for (const key of localeKeys) {\n // @ts-ignore: dynamic keys for locales\n result[key] = mergeValues(\n base[key] as ContentNode | undefined,\n addition[key] as ContentNode | undefined\n );\n }\n\n return result;\n};\n\nconst splitNode = (node: ContentNode): SplitResult => {\n // Translation node: allocate entirely to per-locale buckets\n if (isObject(node) && (node as any)?.nodeType === NodeTypes.TRANSLATION) {\n const translations = (node as any)[NodeTypes.TRANSLATION] as Record<\n string,\n ContentNode\n >;\n\n const result: SplitResult = {};\n for (const locale of Object.keys(translations)) {\n const child = translations[locale];\n const childSplit = splitNode(child);\n\n // The content under a translation belongs to the locale, not common\n // Merge common portion of the child (if any) into the locale as well\n const mergedForLocale = mergeValues(childSplit.common, undefined);\n\n // Compose locale content: prefer the fully rebuilt child by resolving deeper translations recursively\n // which are already split inside childSplit. We need to recompose a single node for this locale.\n // Recompose by merging all keys in childSplit except 'common' into a single node, then merge child's common.\n let recomposed: ContentNode | undefined;\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n recomposed = mergeValues(\n recomposed,\n childSplit[key] as ContentNode | undefined\n );\n }\n const finalLocaleNode = mergeValues(mergedForLocale, recomposed);\n\n if (finalLocaleNode !== undefined) {\n // @ts-ignore dynamic locale key\n result[locale] = finalLocaleNode;\n }\n }\n\n return result;\n }\n\n // Arrays: split each element and merge results index-wise\n if (Array.isArray(node)) {\n const commonArray: any[] = [];\n const perLocaleArrays: Record<string, any[]> = {};\n\n node.forEach((child) => {\n const childSplit = splitNode(child as ContentNode);\n\n if (childSplit.common !== undefined) {\n commonArray.push(childSplit.common);\n }\n\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n if (!perLocaleArrays[key]) perLocaleArrays[key] = [];\n const value = childSplit[key];\n if (value !== undefined) perLocaleArrays[key].push(value);\n }\n });\n\n const result: SplitResult = {};\n if (commonArray.length > 0)\n result.common = commonArray as unknown as ContentNode;\n for (const key of Object.keys(perLocaleArrays)) {\n // @ts-ignore dynamic locale key\n result[key] = perLocaleArrays[key] as unknown as ContentNode;\n }\n return result;\n }\n\n // Objects (non-typed): recursively split properties\n if (isObject(node) && !hasNodeType(node)) {\n let accumulated: SplitResult = {};\n\n for (const key of Object.keys(node)) {\n const childSplit = splitNode((node as any)[key] as ContentNode);\n\n // Assign property into common\n if (childSplit.common !== undefined) {\n accumulated = mergeSplitResults(accumulated, {\n common: { [key]: childSplit.common } as unknown as ContentNode,\n });\n }\n\n // Assign property into each locale bucket\n for (const locale of Object.keys(childSplit)) {\n if (locale === 'common') continue;\n accumulated = mergeSplitResults(accumulated, {\n // @ts-ignore dynamic locale key\n [locale]: { [key]: childSplit[locale] } as unknown as ContentNode,\n });\n }\n }\n\n return accumulated;\n }\n\n // Primitives or typed nodes (non-translation): entirely common\n return { common: node } as SplitResult;\n};\n\nexport const getSplittedContent = (\n content: ContentNode\n): SplittedContentOutput => {\n const split = splitNode(content);\n\n // Build final output with only defined sections\n const output: Record<string, ContentNode> = {};\n if (split.common !== undefined) {\n output.common = split.common;\n }\n for (const key of Object.keys(split)) {\n if (key === 'common') continue;\n const value = split[key] as ContentNode | undefined;\n if (value !== undefined) {\n output[key] = value;\n }\n }\n\n return output as unknown as SplittedContentOutput;\n};\n\n/**\n * Splits the `content` field of a Dictionary into \"common\" and per-locale buckets.\n *\n * Given a dictionary like:\n * ```js\n * {\n * key: \"my-key\",\n * content: {\n * commonContent: \"common content\",\n * multilingualContent: t({\n * en: \"english content\",\n * fr: \"french content\",\n * de: \"german content\",\n * }),\n * },\n * }\n * ```\n *\n * It produces:\n * ```js\n * {\n * common: { commonContent: \"common content\" },\n * en: { multilingualContent: \"english content\" },\n * fr: { multilingualContent: \"french content\" },\n * de: { multilingualContent: \"german content\" },\n * }\n * ```\n *\n * @param dictionary - The input dictionary object with possible multilingual or common content.\n * @returns An object mapping \"common\" and each locale to their corresponding content subtrees.\n */\nexport const getSplittedDictionaryContent = (\n dictionary: Dictionary\n): SplittedContentOutput<Dictionary['content']> =>\n getSplittedContent(dictionary.content);\n"],"mappings":"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"}
@@ -1 +1,12 @@
1
- import{getFilteredLocalesContent as e,getFilteredLocalesDictionary as t}from"./getFilteredLocalesContent.mjs";import{filterMissingTranslationsOnlyPlugin as n,getFilterMissingTranslationsContent as r,getFilterMissingTranslationsDictionary as i}from"./getFilterMissingTranslationsContent.mjs";import{filterTranslationsOnlyPlugin as a,getFilterTranslationsOnlyContent as o,getFilterTranslationsOnlyDictionary as s}from"./getFilterTranslationsOnlyContent.mjs";import{getLocalizedContent as c,getPerLocaleDictionary as l}from"./getLocalizedContent.mjs";import{buildMaskPlugin as u,getMaskContent as d}from"./getMaskContent.mjs";import{checkMissingLocalesPlugin as f,getMissingLocalesContent as p,getMissingLocalesContentFromDictionary as m}from"./getMissingLocalesContent.mjs";import{getMultilingualDictionary as h}from"./getMultilingualDictionary.mjs";import{getReplacedValuesContent as g}from"./getReplacedValuesContent.mjs";import{getSplittedContent as _,getSplittedDictionaryContent as v}from"./getSplittedContent.mjs";import{insertContentInDictionary as y}from"./insertContentInDictionary.mjs";export{u as buildMaskPlugin,f as checkMissingLocalesPlugin,n as filterMissingTranslationsOnlyPlugin,a as filterTranslationsOnlyPlugin,r as getFilterMissingTranslationsContent,i as getFilterMissingTranslationsDictionary,o as getFilterTranslationsOnlyContent,s as getFilterTranslationsOnlyDictionary,e as getFilteredLocalesContent,t as getFilteredLocalesDictionary,c as getLocalizedContent,d as getMaskContent,p as getMissingLocalesContent,m as getMissingLocalesContentFromDictionary,h as getMultilingualDictionary,l as getPerLocaleDictionary,g as getReplacedValuesContent,_ as getSplittedContent,v as getSplittedDictionaryContent,y as insertContentInDictionary};
1
+ import { getFilteredLocalesContent, getFilteredLocalesDictionary } from "./getFilteredLocalesContent.mjs";
2
+ import { filterMissingTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary } from "./getFilterMissingTranslationsContent.mjs";
3
+ import { filterTranslationsOnlyPlugin, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary } from "./getFilterTranslationsOnlyContent.mjs";
4
+ import { getLocalizedContent, getPerLocaleDictionary } from "./getLocalizedContent.mjs";
5
+ import { buildMaskPlugin, getMaskContent } from "./getMaskContent.mjs";
6
+ import { checkMissingLocalesPlugin, getMissingLocalesContent, getMissingLocalesContentFromDictionary } from "./getMissingLocalesContent.mjs";
7
+ import { getMultilingualDictionary } from "./getMultilingualDictionary.mjs";
8
+ import { getReplacedValuesContent } from "./getReplacedValuesContent.mjs";
9
+ import { getSplittedContent, getSplittedDictionaryContent } from "./getSplittedContent.mjs";
10
+ import { insertContentInDictionary } from "./insertContentInDictionary.mjs";
11
+
12
+ export { buildMaskPlugin, checkMissingLocalesPlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getLocalizedContent, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getPerLocaleDictionary, getReplacedValuesContent, getSplittedContent, getSplittedDictionaryContent, insertContentInDictionary };