react-intlayer 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/cjs/IntlayerProvider.cjs +1 -1
  2. package/dist/cjs/IntlayerProvider.cjs.map +1 -1
  3. package/dist/cjs/cli/react-intlayer.cjs +68 -0
  4. package/dist/cjs/cli/react-intlayer.cjs.map +1 -0
  5. package/dist/cjs/cli/react-intlayer.d.ts +1 -0
  6. package/dist/cjs/{ContentEditor/contentRender.cjs → client/ContentEditionLayout.cjs} +9 -14
  7. package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -0
  8. package/dist/cjs/client/ContentEditionLayout.d.ts +6 -0
  9. package/dist/cjs/client/IntlayerClientProvider.cjs +35 -2
  10. package/dist/cjs/client/IntlayerClientProvider.cjs.map +1 -1
  11. package/dist/cjs/client/IntlayerClientProvider.d.ts +2 -1
  12. package/dist/cjs/client/getBrowserLocale.cjs +170 -0
  13. package/dist/cjs/client/getBrowserLocale.cjs.map +1 -0
  14. package/dist/cjs/client/getBrowserLocale.d.ts +26 -0
  15. package/dist/cjs/client/index.cjs +6 -0
  16. package/dist/cjs/client/index.cjs.map +1 -1
  17. package/dist/cjs/client/index.d.ts +2 -0
  18. package/dist/cjs/client/useContent.cjs +2 -2
  19. package/dist/cjs/client/useContent.cjs.map +1 -1
  20. package/dist/cjs/client/useContent.d.ts +1 -2
  21. package/dist/cjs/client/useLocale.cjs +5 -3
  22. package/dist/cjs/client/useLocale.cjs.map +1 -1
  23. package/dist/cjs/client/useLocale.d.ts +1 -0
  24. package/dist/cjs/client/useLocaleBase.cjs +49 -0
  25. package/dist/cjs/client/useLocaleBase.cjs.map +1 -0
  26. package/dist/cjs/client/useLocaleBase.d.ts +14 -0
  27. package/dist/cjs/client/useLocaleCookie.cjs +1 -1
  28. package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
  29. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  30. package/dist/cjs/client/useTraduction.d.ts +6 -5
  31. package/dist/cjs/craco/craco.config.cjs +32 -0
  32. package/dist/cjs/craco/craco.config.cjs.map +1 -0
  33. package/dist/cjs/craco/craco.config.d.ts +2 -0
  34. package/dist/cjs/craco/intlayerCracoPlugin.cjs +89 -0
  35. package/dist/cjs/craco/intlayerCracoPlugin.cjs.map +1 -0
  36. package/dist/cjs/craco/intlayerCracoPlugin.d.ts +26 -0
  37. package/dist/cjs/getEnumeration.cjs +0 -4
  38. package/dist/cjs/getEnumeration.cjs.map +1 -1
  39. package/dist/cjs/getEnumeration.d.ts +8 -5
  40. package/dist/cjs/getTranslation.cjs +1 -5
  41. package/dist/cjs/getTranslation.cjs.map +1 -1
  42. package/dist/cjs/getTranslation.d.ts +3 -2
  43. package/dist/cjs/index.cjs +4 -0
  44. package/dist/cjs/index.cjs.map +1 -1
  45. package/dist/cjs/index.d.ts +2 -0
  46. package/dist/cjs/processDictionary/{contentDictionary.d.cjs → contentDictionary.cjs} +3 -3
  47. package/dist/cjs/processDictionary/contentDictionary.cjs.map +1 -0
  48. package/dist/cjs/processDictionary/contentDictionary.d.ts +16 -0
  49. package/dist/cjs/processDictionary/index.cjs +118 -21
  50. package/dist/cjs/processDictionary/index.cjs.map +1 -1
  51. package/dist/cjs/processDictionary/index.d.ts +5 -4
  52. package/dist/cjs/server/IntlayerServerProvider.cjs +1 -1
  53. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  54. package/dist/cjs/server/getLocaleTranslation.cjs +1 -1
  55. package/dist/cjs/server/getLocaleTranslation.cjs.map +1 -1
  56. package/dist/cjs/server/useTraduction.cjs.map +1 -1
  57. package/dist/cjs/server/useTraduction.d.ts +4 -3
  58. package/dist/cjs/useIntlayerBase.cjs +3 -0
  59. package/dist/cjs/useIntlayerBase.cjs.map +1 -1
  60. package/dist/cjs/vite/intlayerPlugin.cjs +60 -0
  61. package/dist/cjs/vite/intlayerPlugin.cjs.map +1 -0
  62. package/dist/cjs/vite/intlayerPlugin.d.ts +17 -0
  63. package/dist/esm/IntlayerProvider.mjs +3 -2
  64. package/dist/esm/IntlayerProvider.mjs.map +1 -1
  65. package/dist/esm/chunk-ZNCO4QRF.mjs +9 -0
  66. package/dist/esm/cli/react-intlayer.d.mts +1 -0
  67. package/dist/esm/cli/react-intlayer.mjs +45 -0
  68. package/dist/esm/cli/react-intlayer.mjs.map +1 -0
  69. package/dist/esm/client/ContentEditionLayout.d.mts +6 -0
  70. package/dist/esm/client/ContentEditionLayout.mjs +11 -0
  71. package/dist/esm/client/ContentEditionLayout.mjs.map +1 -0
  72. package/dist/esm/client/IntlayerClientProvider.d.mts +2 -1
  73. package/dist/esm/client/IntlayerClientProvider.mjs +42 -7
  74. package/dist/esm/client/IntlayerClientProvider.mjs.map +1 -1
  75. package/dist/esm/client/getBrowserLocale.d.mts +26 -0
  76. package/dist/esm/client/getBrowserLocale.mjs +146 -0
  77. package/dist/esm/client/getBrowserLocale.mjs.map +1 -0
  78. package/dist/esm/client/index.d.mts +2 -0
  79. package/dist/esm/client/index.mjs +5 -0
  80. package/dist/esm/client/index.mjs.map +1 -1
  81. package/dist/esm/client/useContent.d.mts +1 -2
  82. package/dist/esm/client/useContent.mjs +3 -2
  83. package/dist/esm/client/useContent.mjs.map +1 -1
  84. package/dist/esm/client/useIntlayer.mjs +1 -0
  85. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  86. package/dist/esm/client/useLocale.d.mts +1 -0
  87. package/dist/esm/client/useLocale.mjs +7 -4
  88. package/dist/esm/client/useLocale.mjs.map +1 -1
  89. package/dist/esm/client/useLocaleBase.d.mts +14 -0
  90. package/dist/esm/client/useLocaleBase.mjs +26 -0
  91. package/dist/esm/client/useLocaleBase.mjs.map +1 -0
  92. package/dist/esm/client/useLocaleCookie.mjs +3 -4
  93. package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
  94. package/dist/esm/client/useTraduction.d.mts +6 -5
  95. package/dist/esm/client/useTraduction.mjs +1 -0
  96. package/dist/esm/client/useTraduction.mjs.map +1 -1
  97. package/dist/esm/craco/craco.config.d.mts +2 -0
  98. package/dist/esm/craco/craco.config.mjs +17 -0
  99. package/dist/esm/craco/craco.config.mjs.map +1 -0
  100. package/dist/esm/craco/intlayerCracoPlugin.d.mts +26 -0
  101. package/dist/esm/craco/intlayerCracoPlugin.mjs +54 -0
  102. package/dist/esm/craco/intlayerCracoPlugin.mjs.map +1 -0
  103. package/dist/esm/getEnumeration.d.mts +8 -5
  104. package/dist/esm/getEnumeration.mjs +1 -4
  105. package/dist/esm/getEnumeration.mjs.map +1 -1
  106. package/dist/esm/getTranslation.d.mts +3 -2
  107. package/dist/esm/getTranslation.mjs +3 -8
  108. package/dist/esm/getTranslation.mjs.map +1 -1
  109. package/dist/esm/index.d.mts +2 -0
  110. package/dist/esm/index.mjs +6 -1
  111. package/dist/esm/index.mjs.map +1 -1
  112. package/dist/esm/processDictionary/contentDictionary.d.mts +16 -0
  113. package/dist/esm/processDictionary/contentDictionary.mjs +1 -0
  114. package/dist/esm/processDictionary/contentDictionary.mjs.map +1 -0
  115. package/dist/esm/processDictionary/index.d.mts +5 -4
  116. package/dist/esm/processDictionary/index.mjs +122 -25
  117. package/dist/esm/processDictionary/index.mjs.map +1 -1
  118. package/dist/esm/server/IntlayerServerProvider.mjs +3 -4
  119. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  120. package/dist/esm/server/getLocaleTranslation.mjs +3 -2
  121. package/dist/esm/server/getLocaleTranslation.mjs.map +1 -1
  122. package/dist/esm/server/index.mjs +1 -0
  123. package/dist/esm/server/index.mjs.map +1 -1
  124. package/dist/esm/server/serverContext.mjs +1 -0
  125. package/dist/esm/server/serverContext.mjs.map +1 -1
  126. package/dist/esm/server/useIntlayer.mjs +1 -0
  127. package/dist/esm/server/useIntlayer.mjs.map +1 -1
  128. package/dist/esm/server/useTraduction.d.mts +4 -3
  129. package/dist/esm/server/useTraduction.mjs +1 -0
  130. package/dist/esm/server/useTraduction.mjs.map +1 -1
  131. package/dist/esm/useIntlayerBase.mjs +4 -0
  132. package/dist/esm/useIntlayerBase.mjs.map +1 -1
  133. package/dist/esm/vite/intlayerPlugin.d.mts +17 -0
  134. package/dist/esm/vite/intlayerPlugin.mjs +36 -0
  135. package/dist/esm/vite/intlayerPlugin.mjs.map +1 -0
  136. package/package.json +37 -6
  137. package/src/IntlayerProvider.tsx +2 -2
  138. package/src/cli/react-intlayer.ts +60 -0
  139. package/src/client/ContentEditionLayout.tsx +15 -0
  140. package/src/client/IntlayerClientProvider.tsx +50 -12
  141. package/src/client/getBrowserLocale.tsx +192 -0
  142. package/src/client/index.ts +2 -0
  143. package/src/client/useContent.ts +2 -2
  144. package/src/client/useLocale.ts +5 -4
  145. package/src/client/useLocaleBase.ts +24 -0
  146. package/src/client/useLocaleCookie.ts +2 -5
  147. package/src/client/useTraduction.ts +6 -5
  148. package/src/craco/craco.config.ts +11 -0
  149. package/src/craco/intlayerCracoPlugin.ts +89 -0
  150. package/src/getEnumeration.ts +8 -10
  151. package/src/getTranslation.ts +5 -12
  152. package/src/index.ts +2 -1
  153. package/src/processDictionary/{contentDictionary.d.ts → contentDictionary.ts} +6 -5
  154. package/src/processDictionary/index.ts +159 -25
  155. package/src/server/IntlayerServerProvider.tsx +2 -5
  156. package/src/server/getLocaleTranslation.ts +2 -2
  157. package/src/server/useTraduction.ts +4 -3
  158. package/src/useIntlayerBase.ts +3 -0
  159. package/src/vite/intlayerPlugin.ts +59 -0
  160. package/dist/cjs/ContentEditor/ContentEditor.cjs +0 -110
  161. package/dist/cjs/ContentEditor/ContentEditor.cjs.map +0 -1
  162. package/dist/cjs/ContentEditor/ContentEditor.d.ts +0 -8
  163. package/dist/cjs/ContentEditor/contentRender.cjs.map +0 -1
  164. package/dist/cjs/ContentEditor/contentRender.d.ts +0 -3
  165. package/dist/cjs/ContentEditor/index.cjs +0 -25
  166. package/dist/cjs/ContentEditor/index.cjs.map +0 -1
  167. package/dist/cjs/ContentEditor/index.d.ts +0 -3
  168. package/dist/cjs/processDictionary/contentDictionary.d.cjs.map +0 -1
  169. package/dist/cjs/processDictionary/contentDictionary.d.d.ts +0 -29
  170. package/dist/esm/ContentEditor/ContentEditor.d.mts +0 -8
  171. package/dist/esm/ContentEditor/ContentEditor.mjs +0 -91
  172. package/dist/esm/ContentEditor/ContentEditor.mjs.map +0 -1
  173. package/dist/esm/ContentEditor/contentRender.d.mts +0 -3
  174. package/dist/esm/ContentEditor/contentRender.mjs +0 -13
  175. package/dist/esm/ContentEditor/contentRender.mjs.map +0 -1
  176. package/dist/esm/ContentEditor/index.d.mts +0 -3
  177. package/dist/esm/ContentEditor/index.mjs +0 -3
  178. package/dist/esm/ContentEditor/index.mjs.map +0 -1
  179. package/dist/esm/processDictionary/contentDictionary.d.d.mts +0 -29
  180. package/dist/esm/processDictionary/contentDictionary.d.mjs +0 -1
  181. package/src/ContentEditor/ContentEditor.tsx +0 -116
  182. package/src/ContentEditor/contentRender.tsx +0 -11
  183. package/src/ContentEditor/index.tsx +0 -2
  184. /package/dist/esm/{processDictionary/contentDictionary.d.mjs.map → chunk-ZNCO4QRF.mjs.map} +0 -0
@@ -1,9 +1,11 @@
1
+ import "../chunk-ZNCO4QRF.mjs";
1
2
  import {
2
3
  IntlayerClientContext,
3
4
  useIntlayerContext,
4
5
  IntlayerClientProvider
5
6
  } from './IntlayerClientProvider.mjs';
6
7
  import { useIntlayer } from './useIntlayer.mjs';
8
+ import { useLocaleBase } from './useLocaleBase.mjs';
7
9
  import { useLocale } from './useLocale.mjs';
8
10
  import { useTraduction } from './useTraduction.mjs';
9
11
  import {
@@ -11,14 +13,17 @@ import {
11
13
  localeCookie,
12
14
  setLocaleCookie
13
15
  } from './useLocaleCookie.mjs';
16
+ import { getBrowserLocale } from './getBrowserLocale.mjs';
14
17
  export {
15
18
  IntlayerClientContext as IntlayerClient,
16
19
  IntlayerClientProvider,
20
+ getBrowserLocale,
17
21
  localeCookie,
18
22
  setLocaleCookie,
19
23
  useIntlayer,
20
24
  useIntlayerContext,
21
25
  useLocale,
26
+ useLocaleBase,
22
27
  useLocaleCookie,
23
28
  useTraduction
24
29
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export type { IntlayerClientProviderProps } from './IntlayerClientProvider';\nexport {\n IntlayerClientContext as IntlayerClient,\n useIntlayerContext,\n IntlayerClientProvider,\n} from './IntlayerClientProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":"AACA;AAAA,EAC2B;AAAA,EACzB;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export type { IntlayerClientProviderProps } from './IntlayerClientProvider';\nexport {\n IntlayerClientContext as IntlayerClient,\n useIntlayerContext,\n IntlayerClientProvider,\n} from './IntlayerClientProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useLocaleBase } from './useLocaleBase';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\nexport { getBrowserLocale } from './getBrowserLocale';\n"],"mappings":";AACA;AAAA,EAC2B;AAAA,EACzB;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;","names":[]}
@@ -1,4 +1,3 @@
1
- import * as _intlayer_config_client from '@intlayer/config/client';
2
1
  import * as intlayer from 'intlayer';
3
2
  import { LanguageContent } from '@intlayer/core';
4
3
 
@@ -8,7 +7,7 @@ import { LanguageContent } from '@intlayer/core';
8
7
  declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
9
8
  locale: intlayer.Locales;
10
9
  content: Content;
11
- t: <Content_1 = string>(languageContent: Partial<Record<_intlayer_config_client.LocalesValues, Content_1>>) => Content_1;
10
+ t: <Content_1 = string>(languageContent: Partial<Record<intlayer.LocalesValues, Content_1>>) => Content_1;
12
11
  };
13
12
 
14
13
  export { useContent };
@@ -1,7 +1,8 @@
1
- import { useLocale } from './useLocale.mjs';
1
+ import "../chunk-ZNCO4QRF.mjs";
2
+ import { useLocaleBase } from './useLocaleBase.mjs';
2
3
  import { useTraduction } from './useTraduction.mjs';
3
4
  const useContent = (languageContent) => {
4
- const { locale } = useLocale();
5
+ const { locale } = useLocaleBase();
5
6
  const content = useTraduction(languageContent);
6
7
  return {
7
8
  locale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useLocale } from './useLocale';\nimport { useTraduction } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const { locale } = useLocale();\n\n const content = useTraduction(languageContent);\n\n return {\n locale,\n content,\n t: useTraduction,\n };\n};\n"],"mappings":"AACA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAKvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,UAAU,cAAc,eAAe;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTraduction } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTraduction(languageContent);\n\n return {\n locale,\n content,\n t: useTraduction,\n };\n};\n"],"mappings":";AACA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAKvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,IAAI,cAAc;AAEjC,QAAM,UAAU,cAAc,eAAe;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":[]}
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import "../chunk-ZNCO4QRF.mjs";
2
3
  import { useContext } from "react";
3
4
  import {
4
5
  useIntlayerBase
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useContext } from 'react';\nimport {\n type DictionaryKeys,\n useIntlayerBase,\n type UseIntlayer,\n} from '../useIntlayerBase';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayer: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return useIntlayerBase(id, localeTarget);\n};\n"],"mappings":";AAGA,SAAS,kBAAkB;AAC3B;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,6BAA6B;AAO/B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,gBAAgB,IAAI,YAAY;AACzC;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport type { Locales } from '@intlayer/config/client';\nimport { useContext } from 'react';\nimport {\n type DictionaryKeys,\n useIntlayerBase,\n type UseIntlayer,\n} from '../useIntlayerBase';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useIntlayer: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return useIntlayerBase(id, localeTarget);\n};\n"],"mappings":";;AAGA,SAAS,kBAAkB;AAC3B;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,6BAA6B;AAO/B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,qBAAqB;AAClE,QAAM,eAAe,UAAU;AAE/B,SAAO,gBAAgB,IAAI,YAAY;AACzC;","names":[]}
@@ -8,6 +8,7 @@ declare const useLocale: () => {
8
8
  defaultLocale: _intlayer_config_client.Locales;
9
9
  availableLocales: _intlayer_config_client.Locales[];
10
10
  localeList: _intlayer_config_client.Locales[];
11
+ setLocale: (newLocale: _intlayer_config_client.Locales) => void;
11
12
  };
12
13
 
13
14
  export { useLocale };
@@ -1,11 +1,12 @@
1
1
  "use client";
2
- import { intlayerIntlConfiguration } from "@intlayer/config/client";
2
+ import "../chunk-ZNCO4QRF.mjs";
3
+ import { getConfiguration } from "@intlayer/config/client";
3
4
  import { localeList } from "@intlayer/core";
4
5
  import { useContext } from "react";
5
6
  import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
6
- const { defaultLocale, locales: availableLocales } = intlayerIntlConfiguration;
7
7
  const useLocale = () => {
8
- const { locale } = useContext(IntlayerClientContext);
8
+ const { defaultLocale, locales: availableLocales } = getConfiguration().internationalization;
9
+ const { locale, setLocale } = useContext(IntlayerClientContext);
9
10
  return {
10
11
  locale,
11
12
  // Current locale
@@ -13,8 +14,10 @@ const useLocale = () => {
13
14
  // Principal locale defined in config
14
15
  availableLocales,
15
16
  // List of the available locales defined in config
16
- localeList
17
+ localeList,
17
18
  // List of all available locales
19
+ setLocale
20
+ // Function to set the locale
18
21
  };
19
22
  };
20
23
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { intlayerIntlConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\nconst { defaultLocale, locales: availableLocales } = intlayerIntlConfiguration;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = () => {\n const { locale } = useContext(IntlayerClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n localeList, // List of all available locales\n };\n};\n"],"mappings":";AAEA,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAEtC,MAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAK9C,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocale = () => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n const { locale, setLocale } = useContext(IntlayerClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n localeList, // List of all available locales\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;AAEA,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAK/B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,iBAAiB,EAAE;AACrB,QAAM,EAAE,QAAQ,UAAU,IAAI,WAAW,qBAAqB;AAE9D,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,14 @@
1
+ import * as _intlayer_config_client from '@intlayer/config/client';
2
+
3
+ /**
4
+ * On the client side, hook to get the current locale and all related fields
5
+ */
6
+ declare const useLocaleBase: () => {
7
+ locale: _intlayer_config_client.Locales;
8
+ defaultLocale: _intlayer_config_client.Locales;
9
+ availableLocales: _intlayer_config_client.Locales[];
10
+ localeList: _intlayer_config_client.Locales[];
11
+ setLocale: (newLocale: _intlayer_config_client.Locales) => void;
12
+ };
13
+
14
+ export { useLocaleBase };
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import "../chunk-ZNCO4QRF.mjs";
3
+ import { getConfiguration } from "@intlayer/config/client";
4
+ import { localeList } from "@intlayer/core";
5
+ import { useContext } from "react";
6
+ import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
7
+ const { defaultLocale, locales: availableLocales } = getConfiguration().internationalization;
8
+ const useLocaleBase = () => {
9
+ const { locale, setLocale } = useContext(IntlayerClientContext);
10
+ return {
11
+ locale,
12
+ // Current locale
13
+ defaultLocale,
14
+ // Principal locale defined in config
15
+ availableLocales,
16
+ // List of the available locales defined in config
17
+ localeList,
18
+ // List of all available locales
19
+ setLocale
20
+ // Function to set the locale
21
+ };
22
+ };
23
+ export {
24
+ useLocaleBase
25
+ };
26
+ //# sourceMappingURL=useLocaleBase.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\nconst { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n localeList, // List of all available locales\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;AAEA,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AAEtC,MAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,iBAAiB,EAAE;AAKd,MAAM,gBAAgB,MAAM;AACjC,QAAM,EAAE,QAAQ,UAAU,IAAI,WAAW,qBAAqB;AAE9D,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
@@ -1,8 +1,7 @@
1
- import {
2
- intlayerMiddlewareConfiguration
3
- } from "@intlayer/config/client";
1
+ import "../chunk-ZNCO4QRF.mjs";
2
+ import { getConfiguration } from "@intlayer/config/client";
4
3
  import Cookies from "js-cookie";
5
- const { cookieName } = intlayerMiddlewareConfiguration;
4
+ const { cookieName } = getConfiguration().middleware;
6
5
  const cookieAttributes = {
7
6
  path: "/",
8
7
  expires: void 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocaleCookie.ts"],"sourcesContent":["import {\n type Locales,\n intlayerMiddlewareConfiguration,\n} from '@intlayer/config/client';\nimport Cookies from 'js-cookie';\n\nconst { cookieName } = intlayerMiddlewareConfiguration;\n\nconst cookieAttributes: Cookies.CookieAttributes = {\n path: '/',\n expires: undefined,\n domain: undefined,\n secure: false,\n sameSite: 'strict',\n};\n\n/**\n * Get the locale cookie\n */\nexport const localeCookie = Cookies.get(cookieName) as Locales | undefined;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleCookie = (locale: Locales) => {\n Cookies.set(cookieName, locale, cookieAttributes);\n};\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = () => ({\n localeCookie,\n setLocaleCookie,\n});\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,OACK;AACP,OAAO,aAAa;AAEpB,MAAM,EAAE,WAAW,IAAI;AAEvB,MAAM,mBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AACZ;AAKO,MAAM,eAAe,QAAQ,IAAI,UAAU;AAK3C,MAAM,kBAAkB,CAAC,WAAoB;AAClD,UAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocaleCookie.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport Cookies from 'js-cookie';\n\nconst { cookieName } = getConfiguration().middleware;\n\nconst cookieAttributes: Cookies.CookieAttributes = {\n path: '/',\n expires: undefined,\n domain: undefined,\n secure: false,\n sameSite: 'strict',\n};\n\n/**\n * Get the locale cookie\n */\nexport const localeCookie = Cookies.get(cookieName) as Locales | undefined;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleCookie = (locale: Locales) => {\n Cookies.set(cookieName, locale, cookieAttributes);\n};\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = () => ({\n localeCookie,\n setLocaleCookie,\n});\n"],"mappings":";AAAA,SAAuB,wBAAwB;AAC/C,OAAO,aAAa;AAEpB,MAAM,EAAE,WAAW,IAAI,iBAAiB,EAAE;AAE1C,MAAM,mBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AACZ;AAKO,MAAM,eAAe,QAAQ,IAAI,UAAU;AAK3C,MAAM,kBAAkB,CAAC,WAAoB;AAClD,UAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":[]}
@@ -9,12 +9,13 @@ import { LanguageContent } from '@intlayer/core';
9
9
  *
10
10
  * Usage:
11
11
  *
12
- * const content = getTranslation<string>({
13
- * en: 'Hello',
14
- * fr: 'Bonjour',
15
- * },
16
- * 'fr');
12
+ * ```tsx
13
+ * const content = useTraduction<string>({
14
+ * en: 'Hello',
15
+ * fr: 'Bonjour',
16
+ * }, 'fr');
17
17
  * // 'Bonjour'
18
+ * ```
18
19
  *
19
20
  * Using TypeScript:
20
21
  * - this function will require each locale to be defined if defined in the project configuration.
@@ -1,3 +1,4 @@
1
+ import "../chunk-ZNCO4QRF.mjs";
1
2
  import { useContext } from "react";
2
3
  import { getTranslation } from '../getTranslation.mjs';
3
4
  import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * const content = getTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * },\n * 'fr');\n * // 'Bonjour'\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":"AACA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AAsB/B,MAAM,gBAAgB,CAC3B,oBACY;AACZ,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO,eAAe,iBAAiB,MAAM;AAC/C;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useContext } from 'react';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerClientContext } from './IntlayerClientProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTraduction<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":";AACA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AAuB/B,MAAM,gBAAgB,CAC3B,oBACY;AACZ,QAAM,EAAE,OAAO,IAAI,WAAW,qBAAqB;AAEnD,SAAO,eAAe,iBAAiB,MAAM;AAC/C;","names":[]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,17 @@
1
+ import {
2
+ __commonJS
3
+ } from '../chunk-ZNCO4QRF.mjs';
4
+ import * as intlayerPlugin from './intlayerCracoPlugin.mjs';
5
+ var require_craco_config = __commonJS({
6
+ "src/craco/craco.config.ts"(exports, module) {
7
+ module.exports = {
8
+ plugins: [
9
+ {
10
+ plugin: intlayerPlugin
11
+ }
12
+ ]
13
+ };
14
+ }
15
+ });
16
+ export default require_craco_config();
17
+ //# sourceMappingURL=craco.config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/craco/craco.config.ts"],"sourcesContent":["import type { CracoConfig } from '@craco/types';\nimport * as intlayerPlugin from './intlayerCracoPlugin';\n\n// Usage Example\nmodule.exports = {\n plugins: [\n {\n plugin: intlayerPlugin,\n },\n ],\n} satisfies CracoConfig;\n"],"mappings":";;;AACA,YAAY,oBAAoB;AADhC;AAAA;AAIA,WAAO,UAAU;AAAA,MACf,SAAS;AAAA,QACP;AAAA,UACE,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA;AAAA;","names":[]}
@@ -0,0 +1,26 @@
1
+ import { WebpackConfigOverride, CracoConfigOverride, CracoConfig, CracoPlugin } from '@craco/types';
2
+ import { Configuration } from 'webpack';
3
+
4
+ declare const overrideWebpackConfig: ({ webpackConfig, }: WebpackConfigOverride) => Configuration;
5
+ declare const overrideCracoConfig: ({ cracoConfig, }: CracoConfigOverride) => CracoConfig;
6
+ /**
7
+ * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.
8
+ *
9
+ * Usage:
10
+ *
11
+ * ```ts
12
+ * const cracoConfig: CracoConfig = {
13
+ * plugins: [
14
+ * {
15
+ * plugin: intlayerCracoPlugin(),
16
+ * },
17
+ * ],
18
+ * };
19
+ *
20
+ * export default cracoConfig;
21
+ * ```
22
+ *
23
+ */
24
+ declare const plugin: CracoPlugin;
25
+
26
+ export { overrideCracoConfig, overrideWebpackConfig, plugin };
@@ -0,0 +1,54 @@
1
+ import "../chunk-ZNCO4QRF.mjs";
2
+ import { resolve, relative, join } from "path";
3
+ import { getConfiguration, formatEnvVariable } from "@intlayer/config";
4
+ import { IntLayerPlugin as IntLayerWebpackPlugin } from "@intlayer/webpack";
5
+ import webpack from "webpack";
6
+ const intlayerConfig = getConfiguration();
7
+ const env = formatEnvVariable("react_app");
8
+ const overrideWebpackConfig = ({
9
+ webpackConfig
10
+ }) => {
11
+ webpackConfig.externals = {
12
+ ...typeof webpackConfig.externals === "object" ? webpackConfig.externals : {},
13
+ esbuild: "esbuild",
14
+ module: "module",
15
+ fs: "fs",
16
+ vm: "vm"
17
+ };
18
+ (webpackConfig.module?.rules ?? []).push({
19
+ test: /\.node$/,
20
+ use: "node-loader"
21
+ });
22
+ return webpackConfig;
23
+ };
24
+ const overrideCracoConfig = ({
25
+ cracoConfig
26
+ }) => {
27
+ const { mainDir, baseDir } = intlayerConfig.content;
28
+ const dictionariesPath = join(mainDir, "dictionaries.mjs");
29
+ const relativeDictionariesPath = relative(baseDir, dictionariesPath);
30
+ return {
31
+ ...cracoConfig,
32
+ webpack: {
33
+ ...cracoConfig.webpack,
34
+ plugins: {
35
+ ...cracoConfig.webpack?.plugins,
36
+ add: [new webpack.EnvironmentPlugin(env), new IntLayerWebpackPlugin()]
37
+ },
38
+ alias: {
39
+ ...cracoConfig.webpack?.alias,
40
+ "@intlayer/dictionaries-entry": resolve("./", relativeDictionariesPath)
41
+ }
42
+ }
43
+ };
44
+ };
45
+ const plugin = {
46
+ overrideCracoConfig,
47
+ overrideWebpackConfig
48
+ };
49
+ export {
50
+ overrideCracoConfig,
51
+ overrideWebpackConfig,
52
+ plugin
53
+ };
54
+ //# sourceMappingURL=intlayerCracoPlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/craco/intlayerCracoPlugin.ts"],"sourcesContent":["import { resolve, relative, join } from 'path';\nimport type {\n CracoConfig,\n CracoConfigOverride,\n CracoPlugin,\n WebpackConfigOverride,\n} from '@craco/types';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { IntLayerPlugin as IntLayerWebpackPlugin } from '@intlayer/webpack';\nimport webpack, { type Configuration as WebpackConfig } from 'webpack';\n\n// Get IntLayer configuration\nconst intlayerConfig = getConfiguration();\n\n// Format environment variables\nconst env: Record<string, string> = formatEnvVariable('react_app');\n\n// Custom CRACO plugin function to override webpack configuration\nexport const overrideWebpackConfig = ({\n webpackConfig,\n}: WebpackConfigOverride): WebpackConfig => {\n webpackConfig.externals = {\n ...(typeof webpackConfig.externals === 'object'\n ? webpackConfig.externals\n : {}),\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n vm: 'vm',\n };\n\n (webpackConfig.module?.rules ?? []).push({\n test: /\\.node$/,\n use: 'node-loader',\n });\n\n // You can add any custom CRACO plugins here if needed\n // config.plugins.push(new CustomCracoPlugin());\n\n return webpackConfig;\n};\n\n// Return a CRACO configuration object\nexport const overrideCracoConfig = ({\n cracoConfig,\n}: CracoConfigOverride): CracoConfig => {\n const { mainDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n return {\n ...cracoConfig,\n webpack: {\n ...cracoConfig.webpack,\n plugins: {\n ...cracoConfig.webpack?.plugins,\n add: [new webpack.EnvironmentPlugin(env), new IntLayerWebpackPlugin()],\n },\n alias: {\n ...cracoConfig.webpack?.alias,\n '@intlayer/dictionaries-entry': resolve('./', relativeDictionariesPath),\n },\n },\n };\n};\n\n/**\n * A CRACO plugin that adds the IntLayer configuration to the webpack configuration and sets the environment variables.\n *\n * Usage:\n *\n * ```ts\n * const cracoConfig: CracoConfig = {\n * plugins: [\n * {\n * plugin: intlayerCracoPlugin(),\n * },\n * ],\n * };\n *\n * export default cracoConfig;\n * ```\n *\n */\nexport const plugin: CracoPlugin = {\n overrideCracoConfig,\n overrideWebpackConfig,\n};\n"],"mappings":";AAAA,SAAS,SAAS,UAAU,YAAY;AAOxC,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,kBAAkB,6BAA6B;AACxD,OAAO,aAAsD;AAG7D,MAAM,iBAAiB,iBAAiB;AAGxC,MAAM,MAA8B,kBAAkB,WAAW;AAG1D,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,MAA4C;AAC1C,gBAAc,YAAY;AAAA,IACxB,GAAI,OAAO,cAAc,cAAc,WACnC,cAAc,YACd,CAAC;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,IAAI;AAAA,IACJ,IAAI;AAAA,EACN;AAEA,GAAC,cAAc,QAAQ,SAAS,CAAC,GAAG,KAAK;AAAA,IACvC,MAAM;AAAA,IACN,KAAK;AAAA,EACP,CAAC;AAKD,SAAO;AACT;AAGO,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,MAAwC;AACtC,QAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAE5C,QAAM,mBAAmB,KAAK,SAAS,kBAAkB;AACzD,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AAEnE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,YAAY;AAAA,MACf,SAAS;AAAA,QACP,GAAG,YAAY,SAAS;AAAA,QACxB,KAAK,CAAC,IAAI,QAAQ,kBAAkB,GAAG,GAAG,IAAI,sBAAsB,CAAC;AAAA,MACvE;AAAA,MACA,OAAO;AAAA,QACL,GAAG,YAAY,SAAS;AAAA,QACxB,gCAAgC,QAAQ,MAAM,wBAAwB;AAAA,MACxE;AAAA,IACF;AAAA,EACF;AACF;AAoBO,MAAM,SAAsB;AAAA,EACjC;AAAA,EACA;AACF;","names":[]}
@@ -7,22 +7,25 @@ import { QuantityContent } from '@intlayer/core';
7
7
  *
8
8
  * Usage:
9
9
  *
10
+ * ```ts
10
11
  * const content = getEnumeration({
11
12
  * '<=-2.3': 'You have less than -2.3',
12
13
  * '<1': 'You have less than one',
13
14
  * '2': 'You have two',
14
15
  * '>=3': 'You have three or more',
15
- * },
16
- * 2);
16
+ * }, 2);
17
17
  * // 'You have two'
18
+ * ```
18
19
  *
19
20
  * The order of the keys will define the priority of the content.
20
21
  *
22
+ * ```ts
21
23
  * const content = getEnumeration({
22
- * '<4': 'You have less than four',
23
- * '2': 'You have two',
24
- * });
24
+ * '<4': 'You have less than four',
25
+ * '2': 'You have two',
26
+ * }, 2);
25
27
  * // 'You have less than four'
28
+ * ```
26
29
  *
27
30
  */
28
31
  declare const getEnumeration: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
@@ -1,13 +1,10 @@
1
+ import "./chunk-ZNCO4QRF.mjs";
1
2
  import { getEnumerationContent } from "@intlayer/core";
2
- import { contentRender } from './ContentEditor/contentRender.mjs';
3
3
  const getEnumeration = (enumerationContent, quantity) => {
4
4
  const result = getEnumerationContent(
5
5
  enumerationContent,
6
6
  quantity
7
7
  );
8
- if (typeof result === "string") {
9
- return contentRender(result);
10
- }
11
8
  return result;
12
9
  };
13
10
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * const content = getEnumeration({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * },\n * 2);\n * // 'You have two'\n *\n * The order of the keys will define the priority of the content.\n *\n * const content = getEnumeration({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * });\n * // 'You have less than four'\n *\n */\nexport const getEnumeration = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const result: Content = getEnumerationContent<Content>(\n enumerationContent,\n quantity\n );\n\n if (typeof result === 'string') {\n return contentRender(result) as Content;\n }\n\n return result;\n};\n"],"mappings":"AAAA,SAA+B,6BAA6B;AAC5D,SAAS,qBAAqB;AA2BvB,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO,cAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\n\n/**\n * Allow to pick a content based on a quantity.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = getEnumeration({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // 'You have two'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const content = getEnumeration({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // 'You have less than four'\n * ```\n *\n */\nexport const getEnumeration = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const result: Content = getEnumerationContent<Content>(\n enumerationContent,\n quantity\n );\n\n return result;\n};\n"],"mappings":";AAAA,SAA+B,6BAA6B;AA8BrD,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -10,12 +10,13 @@ import { LanguageContent } from '@intlayer/core';
10
10
  *
11
11
  * Usage:
12
12
  *
13
+ * ```ts
13
14
  * const content = getTranslation<string>({
14
15
  * en: 'Hello',
15
16
  * fr: 'Bonjour',
16
- * },
17
- * 'fr');
17
+ * }, 'fr');
18
18
  * // 'Bonjour'
19
+ * ```
19
20
  *
20
21
  * Using TypeScript:
21
22
  * - this function will require each locale to be defined if defined in the project configuration.
@@ -1,17 +1,12 @@
1
- import {
2
- intlayerIntlConfiguration
3
- } from "@intlayer/config/client";
1
+ import "./chunk-ZNCO4QRF.mjs";
2
+ import { getConfiguration } from "@intlayer/config/client";
4
3
  import { getTranslationContent } from "@intlayer/core";
5
- import { contentRender } from './ContentEditor/contentRender.mjs';
6
4
  const getTranslation = (languageContent, locale) => {
7
- const { defaultLocale } = intlayerIntlConfiguration;
5
+ const { defaultLocale } = getConfiguration().internationalization;
8
6
  const result = getTranslationContent(
9
7
  languageContent,
10
8
  locale ?? defaultLocale
11
9
  );
12
- if (typeof result === "string") {
13
- return contentRender(result);
14
- }
15
10
  return result;
16
11
  };
17
12
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import {\n type Locales,\n intlayerIntlConfiguration,\n} from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\n/**\n *\n * Allow to pick a content based on a locale.\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * const content = getTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * },\n * 'fr');\n * // 'Bonjour'\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const getTranslation = <Content = string>(\n languageContent: LanguageContent<Content>,\n locale?: Locales\n): Content => {\n const { defaultLocale } = intlayerIntlConfiguration;\n\n const result: Content = getTranslationContent<Content>(\n languageContent,\n locale ?? defaultLocale\n );\n\n if (typeof result === 'string') {\n return contentRender(result) as Content;\n }\n\n return result;\n};\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,OACK;AACP,SAA+B,6BAA6B;AAC5D,SAAS,qBAAqB;AAsBvB,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,IAAI;AAE1B,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO,cAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\n\n/**\n *\n * Allow to pick a content based on a locale.\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```ts\n * const content = getTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const getTranslation = <Content = string>(\n languageContent: LanguageContent<Content>,\n locale?: Locales\n): Content => {\n const { defaultLocale } = getConfiguration().internationalization;\n\n const result: Content = getTranslationContent<Content>(\n languageContent,\n locale ?? defaultLocale\n );\n\n return result;\n};\n"],"mappings":";AAAA,SAAuB,wBAAwB;AAC/C,SAA+B,6BAA6B;AAuBrD,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,IAAI,iBAAiB,EAAE;AAE7C,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
@@ -1,9 +1,11 @@
1
1
  export { getTranslation } from './getTranslation.mjs';
2
2
  export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps } from './client/IntlayerClientProvider.mjs';
3
3
  export { useIntlayer } from './client/useIntlayer.mjs';
4
+ export { useLocaleBase } from './client/useLocaleBase.mjs';
4
5
  export { useLocale } from './client/useLocale.mjs';
5
6
  export { useTraduction } from './client/useTraduction.mjs';
6
7
  export { localeCookie, setLocaleCookie, useLocaleCookie } from './client/useLocaleCookie.mjs';
8
+ export { getBrowserLocale } from './client/getBrowserLocale.mjs';
7
9
  import '@intlayer/config/client';
8
10
  import '@intlayer/core';
9
11
  import 'react';
@@ -1,3 +1,4 @@
1
+ import "./chunk-ZNCO4QRF.mjs";
1
2
  import { getTranslation } from './getTranslation.mjs';
2
3
  import {
3
4
  IntlayerClientProvider,
@@ -7,16 +8,20 @@ import {
7
8
  useTraduction,
8
9
  useLocaleCookie,
9
10
  localeCookie,
10
- setLocaleCookie
11
+ setLocaleCookie,
12
+ getBrowserLocale,
13
+ useLocaleBase
11
14
  } from './client/index.mjs';
12
15
  export {
13
16
  IntlayerClient,
14
17
  IntlayerClientProvider,
18
+ getBrowserLocale,
15
19
  getTranslation,
16
20
  localeCookie,
17
21
  setLocaleCookie,
18
22
  useIntlayer,
19
23
  useLocale,
24
+ useLocaleBase,
20
25
  useLocaleCookie,
21
26
  useTraduction
22
27
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n IntlayerClient,\n useIntlayer,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './client/index';\nexport {} from './client/useLocaleCookie';\n"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n IntlayerClient,\n useIntlayer,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n} from './client/index';\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -0,0 +1,16 @@
1
+ import { TranslationContent } from '@intlayer/core';
2
+ import { ReactNode } from 'react';
3
+
4
+ type ContentValue = string | {
5
+ [key: string]: ContentValue;
6
+ } | TranslationContent<unknown>;
7
+ type Content = Record<string, ContentValue | undefined>;
8
+ type TransformedContentValue = string | ReactNode | {
9
+ [key: string]: TransformedContentValue;
10
+ } | undefined | ((quantity: number) => TransformedContentValue);
11
+ type TransformedContent = Record<string, TransformedContentValue | undefined> | ReactNode;
12
+ type ContentDictionary = Content & {
13
+ id: string;
14
+ };
15
+
16
+ export type { Content, ContentDictionary, ContentValue, TransformedContent, TransformedContentValue };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=contentDictionary.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,11 +1,12 @@
1
1
  import { Locales } from '@intlayer/config/client';
2
- import { ContentValue, TransformedContentValue, Content, TransformedContent } from './contentDictionary.d.mjs';
3
- import '@intlayer/core';
2
+ import { KeyPath } from '@intlayer/core';
3
+ import { ContentValue, TransformedContentValue, Content, TransformedContent } from './contentDictionary.mjs';
4
+ import 'react';
4
5
 
5
- declare const processNode: (field: ContentValue | undefined, locale: Locales) => TransformedContentValue;
6
+ declare const processNode: (field: ContentValue | undefined, locale: Locales, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[]) => TransformedContentValue;
6
7
  /**
7
8
  * Function that process a dictionary and return the result to be used in the application.
8
9
  */
9
- declare const processDictionary: (content: Content, locale?: Locales) => TransformedContent;
10
+ declare const processDictionary: (content: Content, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[], locale?: Locales) => TransformedContent;
10
11
 
11
12
  export { processDictionary, processNode };