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
@@ -25,7 +25,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_client = require("@intlayer/config/client");
26
26
  var import_IntlayerClientProvider = require('./client/IntlayerClientProvider.cjs');
27
27
  var import_IntlayerServerProvider = require('./server/IntlayerServerProvider.cjs');
28
- const defaultLocale = import_client.intlayerIntlConfiguration.defaultLocale;
28
+ const { defaultLocale } = (0, import_client.getConfiguration)().internationalization;
29
29
  const IntlayerProvider = ({
30
30
  children,
31
31
  locale = defaultLocale
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/IntlayerProvider.tsx"],"sourcesContent":["import { intlayerIntlConfiguration } from '@intlayer/config/client';\nimport type { FC } from 'react';\nimport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/IntlayerClientProvider';\nimport {\n IntlayerServerProvider,\n type IntlayerServerProviderProps,\n} from './server/IntlayerServerProvider';\n\nconst defaultLocale = intlayerIntlConfiguration.defaultLocale;\n\ntype IntlayerProviderProps = IntlayerClientProviderProps &\n IntlayerServerProviderProps;\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerProvider locale={locale}>\n <IntlayerClientProvider locale={locale}>{children}</IntlayerClientProvider>\n </IntlayerServerProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBI;AArBJ,oBAA0C;AAE1C,oCAGO;AACP,oCAGO;AAEP,MAAM,gBAAgB,wCAA0B;AAKzC,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA,SAAS;AACX,MACE,4CAAC,wDAAuB,QACtB,sDAAC,wDAAuB,QAAiB,UAAS,GACpD;","names":[]}
1
+ {"version":3,"sources":["../../src/IntlayerProvider.tsx"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport type { FC } from 'react';\nimport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/IntlayerClientProvider';\nimport {\n IntlayerServerProvider,\n type IntlayerServerProviderProps,\n} from './server/IntlayerServerProvider';\n\nconst { defaultLocale } = getConfiguration().internationalization;\n\ntype IntlayerProviderProps = IntlayerClientProviderProps &\n IntlayerServerProviderProps;\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerProvider locale={locale}>\n <IntlayerClientProvider locale={locale}>{children}</IntlayerClientProvider>\n </IntlayerServerProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBI;AArBJ,oBAAiC;AAEjC,oCAGO;AACP,oCAGO;AAEP,MAAM,EAAE,cAAc,QAAI,gCAAiB,EAAE;AAKtC,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA,SAAS;AACX,MACE,4CAAC,wDAAuB,QACtB,sDAAC,wDAAuB,QAAiB,UAAS,GACpD;","names":[]}
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+ var import_cross_spawn = __toESM(require("cross-spawn"));
26
+ const args = process.argv.slice(2);
27
+ const scriptIndex = args.findIndex(
28
+ (x) => x === "build" || x === "start" || x === "test"
29
+ );
30
+ const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
31
+ switch (script) {
32
+ case "build":
33
+ case "start":
34
+ case "test": {
35
+ const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
36
+ const scriptPath = require.resolve(`@craco/craco/dist/scripts/${script}`);
37
+ const scriptArgs = args.slice(scriptIndex + 1);
38
+ const processArgs = nodeArgs.concat(scriptPath).concat([
39
+ ...scriptArgs,
40
+ "--config",
41
+ "./node_modules/react-intlayer/dist/cjs/craco/craco.config.cjs"
42
+ ]);
43
+ const child = import_cross_spawn.default.sync("node", processArgs, { stdio: "inherit" });
44
+ if (child.signal) {
45
+ if (child.signal === "SIGKILL") {
46
+ console.info(`
47
+ The build failed because the process exited too early.
48
+ This probably means the system ran out of memory or someone called
49
+ \`kill -9\` on the process.
50
+ `);
51
+ } else if (child.signal === "SIGTERM") {
52
+ console.info(`
53
+ The build failed because the process exited too early.
54
+ Someone might have called \`kill\` or \`killall\`, or the system could
55
+ be shutting down.
56
+ `);
57
+ }
58
+ process.exit(1);
59
+ }
60
+ process.exit(child.status ?? void 0);
61
+ break;
62
+ }
63
+ default:
64
+ console.info(`Unknown script "${script}".`);
65
+ console.info("Perhaps you need to update craco?");
66
+ break;
67
+ }
68
+ //# sourceMappingURL=react-intlayer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/cli/react-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport spawn from 'cross-spawn';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (x) => x === 'build' || x === 'start' || x === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\nswitch (script) {\n case 'build':\n case 'start':\n case 'test': {\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = require.resolve(`@craco/craco/dist/scripts/${script}`);\n const scriptArgs = args.slice(scriptIndex + 1);\n const processArgs = nodeArgs\n .concat(scriptPath)\n .concat([\n ...scriptArgs,\n '--config',\n './node_modules/react-intlayer/dist/cjs/craco/craco.config.cjs',\n ]);\n\n const child = spawn.sync('node', processArgs, { stdio: 'inherit' });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n console.info(`\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n \\`kill -9\\` on the process.\n `);\n } else if (child.signal === 'SIGTERM') {\n console.info(`\n The build failed because the process exited too early.\n Someone might have called \\`kill\\` or \\`killall\\`, or the system could\n be shutting down.\n `);\n }\n\n process.exit(1);\n }\n\n process.exit(child.status ?? undefined);\n break;\n }\n default:\n console.info(`Unknown script \"${script}\".`);\n console.info('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AASA,yBAAkB;AAElB,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,cAAc,KAAK;AAAA,EACvB,CAAC,MAAM,MAAM,WAAW,MAAM,WAAW,MAAM;AACjD;AACA,MAAM,SAAS,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,WAAW;AAE9D,QAAQ,QAAQ;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK,QAAQ;AACX,UAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,WAAW,IAAI,CAAC;AACjE,UAAM,aAAa,QAAQ,QAAQ,6BAA6B,MAAM,EAAE;AACxE,UAAM,aAAa,KAAK,MAAM,cAAc,CAAC;AAC7C,UAAM,cAAc,SACjB,OAAO,UAAU,EACjB,OAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAEH,UAAM,QAAQ,mBAAAA,QAAM,KAAK,QAAQ,aAAa,EAAE,OAAO,UAAU,CAAC;AAElE,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,gBAAQ,KAAK;AAAA;AAAA;AAAA;AAAA,aAIR;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,gBAAQ,KAAK;AAAA;AAAA;AAAA;AAAA,aAIR;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,YAAQ,KAAK,mBAAmB,MAAM,IAAI;AAC1C,YAAQ,KAAK,mCAAmC;AAChD;AACJ;","names":["spawn"]}
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -16,22 +16,17 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var contentRender_exports = {};
20
- __export(contentRender_exports, {
21
- contentRender: () => contentRender
19
+ var ContentEditionLayout_exports = {};
20
+ __export(ContentEditionLayout_exports, {
21
+ ContentEditionLayout: () => ContentEditionLayout
22
22
  });
23
- module.exports = __toCommonJS(contentRender_exports);
23
+ module.exports = __toCommonJS(ContentEditionLayout_exports);
24
24
  var import_jsx_runtime = require("react/jsx-runtime");
25
- var import_ContentEditor = require('./ContentEditor.cjs');
26
- const contentRender = (content) => {
27
- const isEditable = process.env.NODE_ENV === "development";
28
- if (isEditable && import_ContentEditor.ContentEditor) {
29
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ContentEditor.ContentEditor, { children: content });
30
- }
31
- return content;
32
- };
25
+ var import_client = require("intlayer-editor/client");
26
+ const BlankLayout = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
27
+ const ContentEditionLayout = typeof import_client.ContentEditionLayout === "undefined" ? BlankLayout : import_client.ContentEditionLayout;
33
28
  // Annotate the CommonJS export names for ESM import in node:
34
29
  0 && (module.exports = {
35
- contentRender
30
+ ContentEditionLayout
36
31
  });
37
- //# sourceMappingURL=contentRender.cjs.map
32
+ //# sourceMappingURL=ContentEditionLayout.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import {\n ContentEditionLayout as ContentEditionLayoutBase,\n type ContentEditionLayoutProps,\n} from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst BlankLayout: FC<ContentEditionLayoutProps> = ({ children }) => (\n <>{children}</>\n);\n\n// intlayer-editor is an optional dependency. If it's not installed, return the blank layout\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> =\n typeof ContentEditionLayoutBase === 'undefined'\n ? BlankLayout\n : (ContentEditionLayoutBase as typeof ContentEditionLayout);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOE;AAPF,oBAGO;AAGP,MAAM,cAA6C,CAAC,EAAE,SAAS,MAC7D,2EAAG,UAAS;AAIP,MAAM,uBACX,OAAO,cAAAA,yBAA6B,cAChC,cACC,cAAAA;","names":["ContentEditionLayoutBase"]}
@@ -0,0 +1,6 @@
1
+ import { ContentEditionLayoutProps } from 'intlayer-editor/client';
2
+ import { FC } from 'react';
3
+
4
+ declare const ContentEditionLayout: FC<ContentEditionLayoutProps>;
5
+
6
+ export { ContentEditionLayout };
@@ -27,15 +27,48 @@ module.exports = __toCommonJS(IntlayerClientProvider_exports);
27
27
  var import_jsx_runtime = require("react/jsx-runtime");
28
28
  var import_client = require("@intlayer/config/client");
29
29
  var import_react = require("react");
30
+ var import_ContentEditionLayout = require('./ContentEditionLayout.cjs');
30
31
  var import_useLocaleCookie = require('./useLocaleCookie.cjs');
31
32
  const IntlayerClientContext = (0, import_react.createContext)({
32
- locale: import_useLocaleCookie.localeCookie ?? import_client.intlayerIntlConfiguration.defaultLocale
33
+ locale: import_useLocaleCookie.localeCookie ?? (0, import_client.getConfiguration)().internationalization.defaultLocale,
34
+ setLocale: () => null
33
35
  });
34
36
  const useIntlayerContext = () => (0, import_react.useContext)(IntlayerClientContext);
35
37
  const IntlayerClientProvider = ({
36
38
  locale,
37
39
  children
38
- }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value: { locale }, children });
40
+ }) => {
41
+ const { defaultLocale, locales: availableLocales } = (0, import_client.getConfiguration)().internationalization;
42
+ const [currentLocale, setCurrentLocale] = (0, import_react.useState)(
43
+ locale ?? import_useLocaleCookie.localeCookie ?? defaultLocale
44
+ );
45
+ const setLocale = (0, import_react.useCallback)(
46
+ (newLocale) => {
47
+ if (currentLocale.toString() === newLocale.toString())
48
+ return;
49
+ if (!availableLocales.includes(newLocale)) {
50
+ console.error(`Locale ${locale} is not available`);
51
+ return;
52
+ }
53
+ setCurrentLocale(newLocale);
54
+ (0, import_useLocaleCookie.setLocaleCookie)(newLocale);
55
+ },
56
+ [availableLocales, currentLocale, locale]
57
+ );
58
+ const value = (0, import_react.useMemo)(
59
+ () => ({ locale: currentLocale, setLocale }),
60
+ [currentLocale, setLocale]
61
+ );
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
+ import_ContentEditionLayout.ContentEditionLayout,
64
+ {
65
+ locale: currentLocale,
66
+ setLocale,
67
+ localeList: availableLocales,
68
+ children
69
+ }
70
+ ) });
71
+ };
39
72
  // Annotate the CommonJS export names for ESM import in node:
40
73
  0 && (module.exports = {
41
74
  IntlayerClientContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n intlayerIntlConfiguration,\n type Locales,\n} from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n type FC,\n} from 'react';\nimport { localeCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? intlayerIntlConfiguration.defaultLocale,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerClientProviderProps = PropsWithChildren & {\n locale: Locales;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerClientProvider: FC<IntlayerClientProviderProps> = ({\n locale,\n children,\n}) => (\n <IntlayerClientContext.Provider value={{ locale }}>\n {children}\n </IntlayerClientContext.Provider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCE;AAvCF,oBAGO;AACP,mBAKO;AACP,6BAA6B;AAStB,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,uCAAgB,wCAA0B;AACpD,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;AASjE,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AACF,MACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAAO,EAAE,OAAO,GAC7C,UACH;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { ContentEditionLayout } from './ContentEditionLayout';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerClientProviderProps = PropsWithChildren & {\n locale?: Locales;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerClientProvider: FC<IntlayerClientProviderProps> = ({\n locale,\n children,\n}) => {\n const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocale = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <ContentEditionLayout\n locale={currentLocale}\n setLocale={setLocale}\n localeList={availableLocales}\n >\n {children}\n </ContentEditionLayout>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyEM;AAvEN,oBAA+C;AAC/C,mBAQO;AACP,kCAAqC;AACrC,6BAA8C;AAUvC,MAAM,4BAAwB,4BAA6B;AAAA,EAChE,QAAQ,2CAAgB,gCAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,UAAM,yBAAW,qBAAqB;AASjE,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,eAAe,SAAS,iBAAiB,QAC/C,gCAAiB,EAAE;AAErB,QAAM,CAAC,eAAe,gBAAgB,QAAI;AAAA,IACxC,UAAU,uCAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAY;AAAA,IAChB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS;AAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,kDAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAU;AAAA,IAC1C,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA,YAAY;AAAA,MAEX;AAAA;AAAA,EACH,GACF;AAEJ;","names":[]}
@@ -4,6 +4,7 @@ import { Locales } from '@intlayer/config/client';
4
4
 
5
5
  type IntlayerValue = {
6
6
  locale: Locales;
7
+ setLocale: (newLocale: Locales) => void;
7
8
  };
8
9
  /**
9
10
  * Context that store the current locale on the client side
@@ -14,7 +15,7 @@ declare const IntlayerClientContext: react.Context<IntlayerValue>;
14
15
  */
15
16
  declare const useIntlayerContext: () => IntlayerValue;
16
17
  type IntlayerClientProviderProps = PropsWithChildren & {
17
- locale: Locales;
18
+ locale?: Locales;
18
19
  };
19
20
  /**
20
21
  * Provider that store the current locale on the client side
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var getBrowserLocale_exports = {};
20
+ __export(getBrowserLocale_exports, {
21
+ LanguageDetector: () => LanguageDetector,
22
+ getBrowserLocale: () => getBrowserLocale
23
+ });
24
+ module.exports = __toCommonJS(getBrowserLocale_exports);
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_core = require("@intlayer/core");
27
+ var LanguageDetector = /* @__PURE__ */ ((LanguageDetector2) => {
28
+ LanguageDetector2["Querystring"] = "querystring";
29
+ LanguageDetector2["Cookie"] = "cookie";
30
+ LanguageDetector2["LocalStorage"] = "localStorage";
31
+ LanguageDetector2["SessionStorage"] = "sessionStorage";
32
+ LanguageDetector2["Navigator"] = "navigator";
33
+ LanguageDetector2["HtmlTag"] = "htmlTag";
34
+ return LanguageDetector2;
35
+ })(LanguageDetector || {});
36
+ const getDefaultsOptions = () => {
37
+ const { middleware } = (0, import_client.getConfiguration)();
38
+ return {
39
+ order: [
40
+ "querystring" /* Querystring */,
41
+ "cookie" /* Cookie */,
42
+ "navigator" /* Navigator */,
43
+ "htmlTag" /* HtmlTag */
44
+ ],
45
+ lookupQuerystring: "locale",
46
+ lookupCookie: middleware.cookieName,
47
+ htmlTag: document.documentElement
48
+ };
49
+ };
50
+ const isLocalStorageAvailable = () => {
51
+ try {
52
+ if (typeof window === "undefined")
53
+ return false;
54
+ const testKey = "intlayer.translate.boo";
55
+ window.localStorage.setItem(testKey, "foo");
56
+ window.localStorage.removeItem(testKey);
57
+ return true;
58
+ } catch {
59
+ return false;
60
+ }
61
+ };
62
+ const isSessionStorageAvailable = () => {
63
+ try {
64
+ if (typeof window === "undefined")
65
+ return false;
66
+ const testKey = "intlayer.translate.boo";
67
+ window.sessionStorage.setItem(testKey, "foo");
68
+ window.sessionStorage.removeItem(testKey);
69
+ return true;
70
+ } catch {
71
+ return false;
72
+ }
73
+ };
74
+ const detectLanguage = (order, options) => {
75
+ const detected = {};
76
+ const queryStringDetector = () => {
77
+ if (typeof window === "undefined")
78
+ return;
79
+ const search = window.location.search || "";
80
+ const params = new URLSearchParams(search);
81
+ const value = params.get(options.lookupQuerystring ?? "");
82
+ if (value) {
83
+ detected["querystring" /* Querystring */] = value;
84
+ }
85
+ };
86
+ const cookieDetector = () => {
87
+ if (typeof document === "undefined")
88
+ return;
89
+ const cookies = document.cookie.split(";");
90
+ const cookieName = `${options.lookupCookie ?? ""}=`;
91
+ const cookie = cookies.find((c) => c.trim().startsWith(cookieName));
92
+ if (cookie) {
93
+ const value = cookie.split("=")[1].trim();
94
+ detected["cookie" /* Cookie */] = value;
95
+ }
96
+ };
97
+ const localStorageDetector = () => {
98
+ if (!isLocalStorageAvailable())
99
+ return;
100
+ const value = window.localStorage.getItem(options.lookupLocalStorage ?? "");
101
+ if (value) {
102
+ detected["localStorage" /* LocalStorage */] = value;
103
+ }
104
+ };
105
+ const sessionStorageDetector = () => {
106
+ if (!isSessionStorageAvailable())
107
+ return;
108
+ const value = window.sessionStorage.getItem(
109
+ options.lookupSessionStorage ?? ""
110
+ );
111
+ if (value) {
112
+ detected["sessionStorage" /* SessionStorage */] = value;
113
+ }
114
+ };
115
+ const navigatorDetector = () => {
116
+ if (typeof navigator === "undefined")
117
+ return;
118
+ if (navigator.language) {
119
+ detected["navigator" /* Navigator */] = navigator.language;
120
+ }
121
+ };
122
+ const htmlTagDetector = () => {
123
+ const htmlTag = options.htmlTag;
124
+ if (htmlTag && typeof htmlTag.getAttribute === "function") {
125
+ const lang = htmlTag.getAttribute("lang");
126
+ if (lang) {
127
+ detected["htmlTag" /* HtmlTag */] = lang;
128
+ }
129
+ }
130
+ };
131
+ const detectors = {
132
+ ["querystring" /* Querystring */]: queryStringDetector,
133
+ ["cookie" /* Cookie */]: cookieDetector,
134
+ ["localStorage" /* LocalStorage */]: localStorageDetector,
135
+ ["sessionStorage" /* SessionStorage */]: sessionStorageDetector,
136
+ ["navigator" /* Navigator */]: navigatorDetector,
137
+ ["htmlTag" /* HtmlTag */]: htmlTagDetector
138
+ };
139
+ order.forEach((detectorName) => {
140
+ detectors[detectorName]?.();
141
+ });
142
+ return detected;
143
+ };
144
+ const getFirstAvailableLocale = (locales, order) => {
145
+ const { internationalization } = (0, import_client.getConfiguration)();
146
+ for (const detector of order) {
147
+ const localesArray = [locales[detector]].flat();
148
+ for (const locale of localesArray) {
149
+ if (locale && (internationalization.locales ?? import_core.localeList).includes(locale)) {
150
+ return locale;
151
+ } else if (locale?.includes("-") && (internationalization.locales ?? import_core.localeList).includes(
152
+ locale.split("-")[0]
153
+ )) {
154
+ return locale.split("-")[0];
155
+ }
156
+ }
157
+ }
158
+ return internationalization.defaultLocale;
159
+ };
160
+ const getBrowserLocale = (userOptions = {}) => {
161
+ const options = { ...getDefaultsOptions(), ...userOptions };
162
+ const locales = detectLanguage(options.order ?? [], options);
163
+ return getFirstAvailableLocale(locales, options.order ?? []);
164
+ };
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
167
+ LanguageDetector,
168
+ getBrowserLocale
169
+ });
170
+ //# sourceMappingURL=getBrowserLocale.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/getBrowserLocale.tsx"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\n\nexport enum LanguageDetector {\n Querystring = 'querystring',\n Cookie = 'cookie',\n LocalStorage = 'localStorage',\n SessionStorage = 'sessionStorage',\n Navigator = 'navigator',\n HtmlTag = 'htmlTag',\n}\n\n// Default settings for the language detector\ntype LanguageDetectorOptions = {\n order?: LanguageDetector[];\n lookupQuerystring?: string;\n lookupCookie?: string;\n lookupLocalStorage?: string;\n lookupSessionStorage?: string;\n excludeCacheFor?: string[];\n htmlTag?: HTMLElement | null;\n};\n\nconst getDefaultsOptions = (): LanguageDetectorOptions => {\n const { middleware } = getConfiguration();\n\n return {\n order: [\n LanguageDetector.Querystring,\n LanguageDetector.Cookie,\n LanguageDetector.Navigator,\n LanguageDetector.HtmlTag,\n ],\n lookupQuerystring: 'locale',\n lookupCookie: middleware.cookieName,\n htmlTag: document.documentElement,\n };\n};\n\n// Helper functions for various checks and operations\nconst isLocalStorageAvailable = (): boolean => {\n try {\n if (typeof window === 'undefined') return false;\n const testKey = 'intlayer.translate.boo';\n window.localStorage.setItem(testKey, 'foo');\n window.localStorage.removeItem(testKey);\n return true;\n } catch {\n return false;\n }\n};\n\nconst isSessionStorageAvailable = (): boolean => {\n try {\n if (typeof window === 'undefined') return false;\n const testKey = 'intlayer.translate.boo';\n window.sessionStorage.setItem(testKey, 'foo');\n window.sessionStorage.removeItem(testKey);\n return true;\n } catch {\n return false;\n }\n};\n\n// Function to detect language using different detectors\nconst detectLanguage = (\n order: string[],\n options: LanguageDetectorOptions\n): Record<LanguageDetector, Locales | Locales[]> => {\n const detected: Record<LanguageDetector, Locales | Locales[]> = {} as Record<\n LanguageDetector,\n Locales | Locales[]\n >;\n\n const queryStringDetector = () => {\n if (typeof window === 'undefined') return;\n const search = window.location.search || '';\n const params = new URLSearchParams(search);\n const value = params.get(options.lookupQuerystring ?? '');\n if (value) {\n detected[LanguageDetector.Querystring] = value as Locales;\n }\n };\n\n const cookieDetector = () => {\n if (typeof document === 'undefined') return;\n const cookies = document.cookie.split(';');\n const cookieName = `${options.lookupCookie ?? ''}=`;\n const cookie = cookies.find((c) => c.trim().startsWith(cookieName));\n if (cookie) {\n const value = cookie.split('=')[1].trim();\n\n detected[LanguageDetector.Cookie] = value as Locales;\n }\n };\n\n const localStorageDetector = () => {\n if (!isLocalStorageAvailable()) return;\n const value = window.localStorage.getItem(options.lookupLocalStorage ?? '');\n if (value) {\n detected[LanguageDetector.LocalStorage] = value as Locales;\n }\n };\n\n const sessionStorageDetector = () => {\n if (!isSessionStorageAvailable()) return;\n const value = window.sessionStorage.getItem(\n options.lookupSessionStorage ?? ''\n );\n if (value) {\n detected[LanguageDetector.SessionStorage] = value as Locales;\n }\n };\n\n const navigatorDetector = () => {\n if (typeof navigator === 'undefined') return;\n\n if (navigator.language) {\n detected[LanguageDetector.Navigator] = navigator.language as Locales;\n }\n };\n\n const htmlTagDetector = () => {\n const htmlTag = options.htmlTag;\n if (htmlTag && typeof htmlTag.getAttribute === 'function') {\n const lang = htmlTag.getAttribute('lang');\n if (lang) {\n detected[LanguageDetector.HtmlTag] = lang as Locales;\n }\n }\n };\n\n // Map detector names to their corresponding functions\n const detectors: Record<string, () => void> = {\n [LanguageDetector.Querystring]: queryStringDetector,\n [LanguageDetector.Cookie]: cookieDetector,\n [LanguageDetector.LocalStorage]: localStorageDetector,\n [LanguageDetector.SessionStorage]: sessionStorageDetector,\n [LanguageDetector.Navigator]: navigatorDetector,\n [LanguageDetector.HtmlTag]: htmlTagDetector,\n };\n\n // Use the provided order to run each detector\n order.forEach((detectorName) => {\n detectors[detectorName]?.();\n });\n\n return detected;\n};\n\nconst getFirstAvailableLocale = (\n locales: Record<LanguageDetector, Locales | Locales[]>,\n order: LanguageDetector[]\n): Locales => {\n const { internationalization } = getConfiguration();\n\n for (const detector of order) {\n const localesArray = [locales[detector]].flat() as Locales[];\n\n for (const locale of localesArray) {\n if (\n locale &&\n (internationalization.locales ?? localeList).includes(locale)\n ) {\n return locale;\n } else if (\n locale?.includes('-') &&\n (internationalization.locales ?? localeList).includes(\n locale.split('-')[0] as Locales\n )\n ) {\n return locale.split('-')[0] as Locales;\n }\n }\n }\n\n return internationalization.defaultLocale;\n};\n\n/**\n * Core language detector function\n * const detectedLanguages = detectLanguage(['LanguageDetector.Cookie', 'LanguageDetector.LocalStorage'], { lookupCookie: 'myCookie' });\n */\nexport const getBrowserLocale = (\n userOptions: LanguageDetectorOptions | undefined = {}\n): Locales => {\n const options = { ...getDefaultsOptions(), ...userOptions };\n\n const locales = detectLanguage(options.order ?? [], options);\n\n return getFirstAvailableLocale(locales, options.order ?? []);\n};\n"],"mappings":"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","names":["LanguageDetector"]}
@@ -0,0 +1,26 @@
1
+ import { Locales } from '@intlayer/config/client';
2
+
3
+ declare enum LanguageDetector {
4
+ Querystring = "querystring",
5
+ Cookie = "cookie",
6
+ LocalStorage = "localStorage",
7
+ SessionStorage = "sessionStorage",
8
+ Navigator = "navigator",
9
+ HtmlTag = "htmlTag"
10
+ }
11
+ type LanguageDetectorOptions = {
12
+ order?: LanguageDetector[];
13
+ lookupQuerystring?: string;
14
+ lookupCookie?: string;
15
+ lookupLocalStorage?: string;
16
+ lookupSessionStorage?: string;
17
+ excludeCacheFor?: string[];
18
+ htmlTag?: HTMLElement | null;
19
+ };
20
+ /**
21
+ * Core language detector function
22
+ * const detectedLanguages = detectLanguage(['LanguageDetector.Cookie', 'LanguageDetector.LocalStorage'], { lookupCookie: 'myCookie' });
23
+ */
24
+ declare const getBrowserLocale: (userOptions?: LanguageDetectorOptions | undefined) => Locales;
25
+
26
+ export { LanguageDetector, getBrowserLocale };
@@ -20,29 +20,35 @@ var client_exports = {};
20
20
  __export(client_exports, {
21
21
  IntlayerClient: () => import_IntlayerClientProvider.IntlayerClientContext,
22
22
  IntlayerClientProvider: () => import_IntlayerClientProvider.IntlayerClientProvider,
23
+ getBrowserLocale: () => import_getBrowserLocale.getBrowserLocale,
23
24
  localeCookie: () => import_useLocaleCookie.localeCookie,
24
25
  setLocaleCookie: () => import_useLocaleCookie.setLocaleCookie,
25
26
  useIntlayer: () => import_useIntlayer.useIntlayer,
26
27
  useIntlayerContext: () => import_IntlayerClientProvider.useIntlayerContext,
27
28
  useLocale: () => import_useLocale.useLocale,
29
+ useLocaleBase: () => import_useLocaleBase.useLocaleBase,
28
30
  useLocaleCookie: () => import_useLocaleCookie.useLocaleCookie,
29
31
  useTraduction: () => import_useTraduction.useTraduction
30
32
  });
31
33
  module.exports = __toCommonJS(client_exports);
32
34
  var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
33
35
  var import_useIntlayer = require('./useIntlayer.cjs');
36
+ var import_useLocaleBase = require('./useLocaleBase.cjs');
34
37
  var import_useLocale = require('./useLocale.cjs');
35
38
  var import_useTraduction = require('./useTraduction.cjs');
36
39
  var import_useLocaleCookie = require('./useLocaleCookie.cjs');
40
+ var import_getBrowserLocale = require('./getBrowserLocale.cjs');
37
41
  // Annotate the CommonJS export names for ESM import in node:
38
42
  0 && (module.exports = {
39
43
  IntlayerClient,
40
44
  IntlayerClientProvider,
45
+ getBrowserLocale,
41
46
  localeCookie,
42
47
  setLocaleCookie,
43
48
  useIntlayer,
44
49
  useIntlayerContext,
45
50
  useLocale,
51
+ useLocaleBase,
46
52
  useLocaleCookie,
47
53
  useTraduction
48
54
  });
@@ -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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAIO;AACP,yBAA4B;AAC5B,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAIO;","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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oCAIO;AACP,yBAA4B;AAC5B,2BAA8B;AAC9B,uBAA0B;AAC1B,2BAA8B;AAC9B,6BAIO;AACP,8BAAiC;","names":[]}
@@ -1,8 +1,10 @@
1
1
  export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps, useIntlayerContext } from './IntlayerClientProvider.js';
2
2
  export { useIntlayer } from './useIntlayer.js';
3
+ export { useLocaleBase } from './useLocaleBase.js';
3
4
  export { useLocale } from './useLocale.js';
4
5
  export { useTraduction } from './useTraduction.js';
5
6
  export { localeCookie, setLocaleCookie, useLocaleCookie } from './useLocaleCookie.js';
7
+ export { getBrowserLocale } from './getBrowserLocale.js';
6
8
  import 'react';
7
9
  import '@intlayer/config/client';
8
10
  import '../useIntlayerBase.js';
@@ -21,10 +21,10 @@ __export(useContent_exports, {
21
21
  useContent: () => useContent
22
22
  });
23
23
  module.exports = __toCommonJS(useContent_exports);
24
- var import_useLocale = require('./useLocale.cjs');
24
+ var import_useLocaleBase = require('./useLocaleBase.cjs');
25
25
  var import_useTraduction = require('./useTraduction.cjs');
26
26
  const useContent = (languageContent) => {
27
- const { locale } = (0, import_useLocale.useLocale)();
27
+ const { locale } = (0, import_useLocaleBase.useLocaleBase)();
28
28
  const content = (0, import_useTraduction.useTraduction)(languageContent);
29
29
  return {
30
30
  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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uBAA0B;AAC1B,2BAA8B;AAKvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,QAAI,4BAAU;AAE7B,QAAM,cAAU,oCAAc,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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,2BAA8B;AAC9B,2BAA8B;AAKvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,QAAI,oCAAc;AAEjC,QAAM,cAAU,oCAAc,eAAe;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","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 };
@@ -26,9 +26,9 @@ var import_client = require("@intlayer/config/client");
26
26
  var import_core = require("@intlayer/core");
27
27
  var import_react = require("react");
28
28
  var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
29
- const { defaultLocale, locales: availableLocales } = import_client.intlayerIntlConfiguration;
30
29
  const useLocale = () => {
31
- const { locale } = (0, import_react.useContext)(import_IntlayerClientProvider.IntlayerClientContext);
30
+ const { defaultLocale, locales: availableLocales } = (0, import_client.getConfiguration)().internationalization;
31
+ const { locale, setLocale } = (0, import_react.useContext)(import_IntlayerClientProvider.IntlayerClientContext);
32
32
  return {
33
33
  locale,
34
34
  // Current locale
@@ -36,8 +36,10 @@ const useLocale = () => {
36
36
  // Principal locale defined in config
37
37
  availableLocales,
38
38
  // List of the available locales defined in config
39
- localeList: import_core.localeList
39
+ localeList: import_core.localeList,
40
40
  // List of all available locales
41
+ setLocale
42
+ // Function to set the locale
41
43
  };
42
44
  };
43
45
  // Annotate the CommonJS export names for ESM import in node:
@@ -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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA0C;AAC1C,kBAA2B;AAC3B,mBAA2B;AAC3B,oCAAsC;AAEtC,MAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAK9C,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,OAAO,QAAI,yBAAW,mDAAqB;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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAiC;AACjC,kBAA2B;AAC3B,mBAA2B;AAC3B,oCAAsC;AAK/B,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,eAAe,SAAS,iBAAiB,QAC/C,gCAAiB,EAAE;AACrB,QAAM,EAAE,QAAQ,UAAU,QAAI,yBAAW,mDAAqB;AAE9D,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","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 };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var useLocaleBase_exports = {};
21
+ __export(useLocaleBase_exports, {
22
+ useLocaleBase: () => useLocaleBase
23
+ });
24
+ module.exports = __toCommonJS(useLocaleBase_exports);
25
+ var import_client = require("@intlayer/config/client");
26
+ var import_core = require("@intlayer/core");
27
+ var import_react = require("react");
28
+ var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
29
+ const { defaultLocale, locales: availableLocales } = (0, import_client.getConfiguration)().internationalization;
30
+ const useLocaleBase = () => {
31
+ const { locale, setLocale } = (0, import_react.useContext)(import_IntlayerClientProvider.IntlayerClientContext);
32
+ return {
33
+ locale,
34
+ // Current locale
35
+ defaultLocale,
36
+ // Principal locale defined in config
37
+ availableLocales,
38
+ // List of the available locales defined in config
39
+ localeList: import_core.localeList,
40
+ // List of all available locales
41
+ setLocale
42
+ // Function to set the locale
43
+ };
44
+ };
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ useLocaleBase
48
+ });
49
+ //# sourceMappingURL=useLocaleBase.cjs.map