react-intlayer 2.0.0 → 2.0.2

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 (125) hide show
  1. package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -1
  2. package/dist/cjs/client/{IntlayerClientProvider.cjs → IntlayerProvider.cjs} +14 -11
  3. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -0
  4. package/dist/cjs/client/{IntlayerClientProvider.d.ts → IntlayerProvider.d.ts} +5 -3
  5. package/dist/cjs/client/getBrowserLocale.cjs +7 -14
  6. package/dist/cjs/client/getBrowserLocale.cjs.map +1 -1
  7. package/dist/cjs/client/index.cjs +6 -6
  8. package/dist/cjs/client/index.cjs.map +1 -1
  9. package/dist/cjs/client/index.d.ts +3 -2
  10. package/dist/cjs/client/useContent.d.ts +1 -1
  11. package/dist/cjs/client/useIntlayer.cjs +2 -2
  12. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  13. package/dist/cjs/client/useIntlayer.d.ts +3 -1
  14. package/dist/cjs/client/useLocale.cjs +2 -2
  15. package/dist/cjs/client/useLocale.cjs.map +1 -1
  16. package/dist/cjs/client/useLocaleBase.cjs +2 -2
  17. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  18. package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
  19. package/dist/cjs/client/useTraduction.cjs +2 -2
  20. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  21. package/dist/cjs/index.cjs +4 -4
  22. package/dist/cjs/index.cjs.map +1 -1
  23. package/dist/cjs/index.d.ts +3 -2
  24. package/dist/cjs/processDictionary/contentDictionary.cjs.map +1 -1
  25. package/dist/cjs/processDictionary/contentDictionary.d.ts +9 -9
  26. package/dist/cjs/processDictionary/index.cjs +69 -53
  27. package/dist/cjs/processDictionary/index.cjs.map +1 -1
  28. package/dist/cjs/processDictionary/index.d.ts +4 -4
  29. package/dist/cjs/server/IntlayerServerProvider.cjs +3 -4
  30. package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
  31. package/dist/cjs/server/IntlayerServerProvider.d.ts +6 -7
  32. package/dist/cjs/server/index.d.ts +1 -0
  33. package/dist/cjs/server/serverContext.cjs +1 -2
  34. package/dist/cjs/server/serverContext.cjs.map +1 -1
  35. package/dist/cjs/server/useIntlayer.d.ts +3 -1
  36. package/dist/cjs/useIntlayerBase.cjs +26 -1
  37. package/dist/cjs/useIntlayerBase.cjs.map +1 -1
  38. package/dist/cjs/useIntlayerBase.d.ts +62 -4
  39. package/dist/esm/{chunk-ZNCO4QRF.mjs → chunk-ZD7AOCMD.mjs} +1 -1
  40. package/dist/esm/client/ContentEditionLayout.mjs +1 -1
  41. package/dist/esm/client/ContentEditionLayout.mjs.map +1 -1
  42. package/dist/esm/client/{IntlayerClientProvider.d.mts → IntlayerProvider.d.mts} +5 -3
  43. package/dist/esm/client/{IntlayerClientProvider.mjs → IntlayerProvider.mjs} +11 -8
  44. package/dist/esm/client/IntlayerProvider.mjs.map +1 -0
  45. package/dist/esm/client/getBrowserLocale.mjs +8 -15
  46. package/dist/esm/client/getBrowserLocale.mjs.map +1 -1
  47. package/dist/esm/client/index.d.mts +3 -2
  48. package/dist/esm/client/index.mjs +5 -5
  49. package/dist/esm/client/index.mjs.map +1 -1
  50. package/dist/esm/client/useContent.d.mts +1 -1
  51. package/dist/esm/client/useContent.mjs +1 -1
  52. package/dist/esm/client/useIntlayer.d.mts +3 -1
  53. package/dist/esm/client/useIntlayer.mjs +2 -2
  54. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  55. package/dist/esm/client/useLocale.mjs +2 -2
  56. package/dist/esm/client/useLocale.mjs.map +1 -1
  57. package/dist/esm/client/useLocaleBase.mjs +2 -2
  58. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  59. package/dist/esm/client/useLocaleCookie.mjs +1 -1
  60. package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
  61. package/dist/esm/client/useTraduction.mjs +2 -2
  62. package/dist/esm/client/useTraduction.mjs.map +1 -1
  63. package/dist/esm/craco/craco.config.mjs +1 -1
  64. package/dist/esm/craco/intlayerCracoPlugin.mjs +1 -1
  65. package/dist/esm/getEnumeration.mjs +1 -1
  66. package/dist/esm/getTranslation.mjs +1 -1
  67. package/dist/esm/index.d.mts +3 -2
  68. package/dist/esm/index.mjs +5 -5
  69. package/dist/esm/index.mjs.map +1 -1
  70. package/dist/esm/processDictionary/contentDictionary.d.mts +9 -9
  71. package/dist/esm/processDictionary/index.d.mts +4 -4
  72. package/dist/esm/processDictionary/index.mjs +70 -54
  73. package/dist/esm/processDictionary/index.mjs.map +1 -1
  74. package/dist/esm/server/IntlayerServerProvider.d.mts +6 -7
  75. package/dist/esm/server/IntlayerServerProvider.mjs +4 -5
  76. package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
  77. package/dist/esm/server/getLocaleTranslation.mjs +1 -1
  78. package/dist/esm/server/index.d.mts +1 -0
  79. package/dist/esm/server/index.mjs +1 -1
  80. package/dist/esm/server/serverContext.mjs +2 -3
  81. package/dist/esm/server/serverContext.mjs.map +1 -1
  82. package/dist/esm/server/useIntlayer.d.mts +3 -1
  83. package/dist/esm/server/useIntlayer.mjs +1 -1
  84. package/dist/esm/server/useTraduction.mjs +1 -1
  85. package/dist/esm/useIntlayerBase.d.mts +62 -4
  86. package/dist/esm/useIntlayerBase.mjs +26 -2
  87. package/dist/esm/useIntlayerBase.mjs.map +1 -1
  88. package/dist/esm/vite/intlayerPlugin.mjs +1 -1
  89. package/package.json +18 -19
  90. package/src/index.ts +4 -3
  91. package/dist/cjs/IntlayerProvider.cjs +0 -37
  92. package/dist/cjs/IntlayerProvider.cjs.map +0 -1
  93. package/dist/cjs/IntlayerProvider.d.ts +0 -9
  94. package/dist/cjs/client/IntlayerClientProvider.cjs.map +0 -1
  95. package/dist/esm/IntlayerProvider.d.mts +0 -9
  96. package/dist/esm/IntlayerProvider.mjs +0 -18
  97. package/dist/esm/IntlayerProvider.mjs.map +0 -1
  98. package/dist/esm/client/IntlayerClientProvider.mjs.map +0 -1
  99. package/src/IntlayerProvider.tsx +0 -24
  100. package/src/cli/react-intlayer.ts +0 -60
  101. package/src/client/ContentEditionLayout.tsx +0 -15
  102. package/src/client/IntlayerClientProvider.tsx +0 -83
  103. package/src/client/getBrowserLocale.tsx +0 -192
  104. package/src/client/index.ts +0 -16
  105. package/src/client/useContent.ts +0 -20
  106. package/src/client/useIntlayer.ts +0 -25
  107. package/src/client/useLocale.ts +0 -23
  108. package/src/client/useLocaleBase.ts +0 -24
  109. package/src/client/useLocaleCookie.ts +0 -32
  110. package/src/client/useTraduction.ts +0 -33
  111. package/src/craco/craco.config.ts +0 -11
  112. package/src/craco/intlayerCracoPlugin.ts +0 -89
  113. package/src/getEnumeration.ts +0 -41
  114. package/src/getTranslation.ts +0 -37
  115. package/src/processDictionary/contentDictionary.ts +0 -28
  116. package/src/processDictionary/index.ts +0 -231
  117. package/src/server/IntlayerServerProvider.tsx +0 -36
  118. package/src/server/getLocaleTranslation.ts +0 -22
  119. package/src/server/index.ts +0 -8
  120. package/src/server/serverContext.ts +0 -85
  121. package/src/server/useIntlayer.ts +0 -23
  122. package/src/server/useTraduction.ts +0 -34
  123. package/src/useIntlayerBase.ts +0 -38
  124. package/src/vite/intlayerPlugin.ts +0 -59
  125. /package/dist/esm/{chunk-ZNCO4QRF.mjs.map → chunk-ZD7AOCMD.mjs.map} +0 -0
@@ -1,4 +1,4 @@
1
- import "../chunk-ZNCO4QRF.mjs";
1
+ import "../chunk-ZD7AOCMD.mjs";
2
2
  import { getConfiguration } from "@intlayer/config/client";
3
3
  import { localeList } from "@intlayer/core";
4
4
  var LanguageDetector = /* @__PURE__ */ ((LanguageDetector2) => {
@@ -26,8 +26,7 @@ const getDefaultsOptions = () => {
26
26
  };
27
27
  const isLocalStorageAvailable = () => {
28
28
  try {
29
- if (typeof window === "undefined")
30
- return false;
29
+ if (typeof window === "undefined") return false;
31
30
  const testKey = "intlayer.translate.boo";
32
31
  window.localStorage.setItem(testKey, "foo");
33
32
  window.localStorage.removeItem(testKey);
@@ -38,8 +37,7 @@ const isLocalStorageAvailable = () => {
38
37
  };
39
38
  const isSessionStorageAvailable = () => {
40
39
  try {
41
- if (typeof window === "undefined")
42
- return false;
40
+ if (typeof window === "undefined") return false;
43
41
  const testKey = "intlayer.translate.boo";
44
42
  window.sessionStorage.setItem(testKey, "foo");
45
43
  window.sessionStorage.removeItem(testKey);
@@ -51,8 +49,7 @@ const isSessionStorageAvailable = () => {
51
49
  const detectLanguage = (order, options) => {
52
50
  const detected = {};
53
51
  const queryStringDetector = () => {
54
- if (typeof window === "undefined")
55
- return;
52
+ if (typeof window === "undefined") return;
56
53
  const search = window.location.search || "";
57
54
  const params = new URLSearchParams(search);
58
55
  const value = params.get(options.lookupQuerystring ?? "");
@@ -61,8 +58,7 @@ const detectLanguage = (order, options) => {
61
58
  }
62
59
  };
63
60
  const cookieDetector = () => {
64
- if (typeof document === "undefined")
65
- return;
61
+ if (typeof document === "undefined") return;
66
62
  const cookies = document.cookie.split(";");
67
63
  const cookieName = `${options.lookupCookie ?? ""}=`;
68
64
  const cookie = cookies.find((c) => c.trim().startsWith(cookieName));
@@ -72,16 +68,14 @@ const detectLanguage = (order, options) => {
72
68
  }
73
69
  };
74
70
  const localStorageDetector = () => {
75
- if (!isLocalStorageAvailable())
76
- return;
71
+ if (!isLocalStorageAvailable()) return;
77
72
  const value = window.localStorage.getItem(options.lookupLocalStorage ?? "");
78
73
  if (value) {
79
74
  detected["localStorage" /* LocalStorage */] = value;
80
75
  }
81
76
  };
82
77
  const sessionStorageDetector = () => {
83
- if (!isSessionStorageAvailable())
84
- return;
78
+ if (!isSessionStorageAvailable()) return;
85
79
  const value = window.sessionStorage.getItem(
86
80
  options.lookupSessionStorage ?? ""
87
81
  );
@@ -90,8 +84,7 @@ const detectLanguage = (order, options) => {
90
84
  }
91
85
  };
92
86
  const navigatorDetector = () => {
93
- if (typeof navigator === "undefined")
94
- return;
87
+ if (typeof navigator === "undefined") return;
95
88
  if (navigator.language) {
96
89
  detected["navigator" /* Navigator */] = navigator.language;
97
90
  }
@@ -1 +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":";AAAA,SAAS,wBAAsC;AAC/C,SAAS,kBAAkB;AAEpB,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,iBAAc;AACd,EAAAA,kBAAA,YAAS;AACT,EAAAA,kBAAA,kBAAe;AACf,EAAAA,kBAAA,oBAAiB;AACjB,EAAAA,kBAAA,eAAY;AACZ,EAAAA,kBAAA,aAAU;AANA,SAAAA;AAAA,GAAA;AAoBZ,MAAM,qBAAqB,MAA+B;AACxD,QAAM,EAAE,WAAW,IAAI,iBAAiB;AAExC,SAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,IACnB,cAAc,WAAW;AAAA,IACzB,SAAS,SAAS;AAAA,EACpB;AACF;AAGA,MAAM,0BAA0B,MAAe;AAC7C,MAAI;AACF,QAAI,OAAO,WAAW;AAAa,aAAO;AAC1C,UAAM,UAAU;AAChB,WAAO,aAAa,QAAQ,SAAS,KAAK;AAC1C,WAAO,aAAa,WAAW,OAAO;AACtC,WAAO;AAAA,EAC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MO,MAAM,mBAAmB,CAC9B,cAAmD,CAAC,MACxC;AACZ,QAAM,UAAU,EAAE,GAAG,mBAAmB,GAAG,GAAG,YAAY;AAE1D,QAAM,UAAU,eAAe,QAAQ,SAAS,CAAC,GAAG,OAAO;AAE3D,SAAO,wBAAwB,SAAS,QAAQ,SAAS,CAAC,CAAC;AAC7D;","names":["LanguageDetector"]}
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":";AAAA,SAAS,wBAAsC;AAC/C,SAAS,kBAAkB;AAEpB,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,iBAAc;AACd,EAAAA,kBAAA,YAAS;AACT,EAAAA,kBAAA,kBAAe;AACf,EAAAA,kBAAA,oBAAiB;AACjB,EAAAA,kBAAA,eAAY;AACZ,EAAAA,kBAAA,aAAU;AANA,SAAAA;AAAA,GAAA;AAoBZ,MAAM,qBAAqB,MAA+B;AACxD,QAAM,EAAE,WAAW,IAAI,iBAAiB;AAExC,SAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,IACnB,cAAc,WAAW;AAAA,IACzB,SAAS,SAAS;AAAA,EACpB;AACF;AAGA,MAAM,0BAA0B,MAAe;AAC7C,MAAI;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M,GAAG,EAAE,CAAC;AAAA,MACrB,GACA;AACA,eAAO,OAAO,MAAM,GAAG,EAAE,CAAC;AAAA,MAC5B;AAAA,IACF;AAAA,EACF;AAEA,SAAO,qBAAqB;AAC9B;AAMO,MAAM,mBAAmB,CAC9B,cAAmD,CAAC,MACxC;AACZ,QAAM,UAAU,EAAE,GAAG,mBAAmB,GAAG,GAAG,YAAY;AAE1D,QAAM,UAAU,eAAe,QAAQ,SAAS,CAAC,GAAG,OAAO;AAE3D,SAAO,wBAAwB,SAAS,QAAQ,SAAS,CAAC,CAAC;AAC7D;","names":["LanguageDetector"]}
@@ -1,4 +1,4 @@
1
- export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps, useIntlayerContext } from './IntlayerClientProvider.mjs';
1
+ export { IntlayerClientContext, IntlayerProvider, IntlayerProviderProps, useIntlayerContext } from './IntlayerProvider.mjs';
2
2
  export { useIntlayer } from './useIntlayer.mjs';
3
3
  export { useLocaleBase } from './useLocaleBase.mjs';
4
4
  export { useLocale } from './useLocale.mjs';
@@ -8,5 +8,6 @@ export { getBrowserLocale } from './getBrowserLocale.mjs';
8
8
  import 'react';
9
9
  import '@intlayer/config/client';
10
10
  import '../useIntlayerBase.mjs';
11
- import 'intlayer';
11
+ import '@intlayer/config';
12
12
  import '@intlayer/core';
13
+ import 'intlayer';
@@ -1,9 +1,9 @@
1
- import "../chunk-ZNCO4QRF.mjs";
1
+ import "../chunk-ZD7AOCMD.mjs";
2
2
  import {
3
3
  IntlayerClientContext,
4
4
  useIntlayerContext,
5
- IntlayerClientProvider
6
- } from './IntlayerClientProvider.mjs';
5
+ IntlayerProvider
6
+ } from './IntlayerProvider.mjs';
7
7
  import { useIntlayer } from './useIntlayer.mjs';
8
8
  import { useLocaleBase } from './useLocaleBase.mjs';
9
9
  import { useLocale } from './useLocale.mjs';
@@ -15,8 +15,8 @@ import {
15
15
  } from './useLocaleCookie.mjs';
16
16
  import { getBrowserLocale } from './getBrowserLocale.mjs';
17
17
  export {
18
- IntlayerClientContext as IntlayerClient,
19
- IntlayerClientProvider,
18
+ IntlayerClientContext,
19
+ IntlayerProvider,
20
20
  getBrowserLocale,
21
21
  localeCookie,
22
22
  setLocaleCookie,
@@ -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 { 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
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayerContext,\n IntlayerProvider,\n} from './IntlayerProvider';\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,EAEE;AAAA,EACA;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":[]}
@@ -7,7 +7,7 @@ import { LanguageContent } from '@intlayer/core';
7
7
  declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
8
8
  locale: intlayer.Locales;
9
9
  content: Content;
10
- t: <Content_1 = string>(languageContent: Partial<Record<intlayer.LocalesValues, Content_1>>) => Content_1;
10
+ t: <Content_1 = string>(languageContent: LanguageContent<Content_1>) => Content_1;
11
11
  };
12
12
 
13
13
  export { useContent };
@@ -1,4 +1,4 @@
1
- import "../chunk-ZNCO4QRF.mjs";
1
+ import "../chunk-ZD7AOCMD.mjs";
2
2
  import { useLocaleBase } from './useLocaleBase.mjs';
3
3
  import { useTraduction } from './useTraduction.mjs';
4
4
  const useContent = (languageContent) => {
@@ -1,6 +1,8 @@
1
1
  import { UseIntlayer } from '../useIntlayerBase.mjs';
2
- import '@intlayer/config/client';
2
+ import '@intlayer/config';
3
+ import '@intlayer/core';
3
4
  import 'intlayer';
5
+ import 'react';
4
6
 
5
7
  /**
6
8
  * On the client side, Hook that picking one dictionary by its id and return the content
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import "../chunk-ZNCO4QRF.mjs";
2
+ import "../chunk-ZD7AOCMD.mjs";
3
3
  import { useContext } from "react";
4
4
  import {
5
5
  useIntlayerBase
6
6
  } from '../useIntlayerBase.mjs';
7
- import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
7
+ import { IntlayerClientContext } from './IntlayerProvider.mjs';
8
8
  const useIntlayer = (id, locale) => {
9
9
  const { locale: currentLocale } = useContext(IntlayerClientContext);
10
10
  const localeTarget = locale ?? currentLocale;
@@ -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 './IntlayerProvider';\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,9 +1,9 @@
1
1
  "use client";
2
- import "../chunk-ZNCO4QRF.mjs";
2
+ import "../chunk-ZD7AOCMD.mjs";
3
3
  import { getConfiguration } from "@intlayer/config/client";
4
4
  import { localeList } from "@intlayer/core";
5
5
  import { useContext } from "react";
6
- import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
6
+ import { IntlayerClientContext } from './IntlayerProvider.mjs';
7
7
  const useLocale = () => {
8
8
  const { defaultLocale, locales: availableLocales } = getConfiguration().internationalization;
9
9
  const { locale, setLocale } = useContext(IntlayerClientContext);
@@ -1 +1 @@
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":[]}
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 './IntlayerProvider';\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":[]}
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import "../chunk-ZNCO4QRF.mjs";
2
+ import "../chunk-ZD7AOCMD.mjs";
3
3
  import { getConfiguration } from "@intlayer/config/client";
4
4
  import { localeList } from "@intlayer/core";
5
5
  import { useContext } from "react";
6
- import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
6
+ import { IntlayerClientContext } from './IntlayerProvider.mjs';
7
7
  const { defaultLocale, locales: availableLocales } = getConfiguration().internationalization;
8
8
  const useLocaleBase = () => {
9
9
  const { locale, setLocale } = useContext(IntlayerClientContext);
@@ -1 +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
+ {"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 './IntlayerProvider';\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,4 +1,4 @@
1
- import "../chunk-ZNCO4QRF.mjs";
1
+ import "../chunk-ZD7AOCMD.mjs";
2
2
  import { getConfiguration } from "@intlayer/config/client";
3
3
  import Cookies from "js-cookie";
4
4
  const { cookieName } = getConfiguration().middleware;
@@ -1 +1 @@
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":[]}
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 unknown as\n | Locales\n | 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;AAO3C,MAAM,kBAAkB,CAAC,WAAoB;AAClD,UAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
- import "../chunk-ZNCO4QRF.mjs";
1
+ import "../chunk-ZD7AOCMD.mjs";
2
2
  import { useContext } from "react";
3
3
  import { getTranslation } from '../getTranslation.mjs';
4
- import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
4
+ import { IntlayerClientContext } from './IntlayerProvider.mjs';
5
5
  const useTraduction = (languageContent) => {
6
6
  const { locale } = useContext(IntlayerClientContext);
7
7
  return getTranslation(languageContent, locale);
@@ -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 * ```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":[]}
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 './IntlayerProvider';\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":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __commonJS
3
- } from '../chunk-ZNCO4QRF.mjs';
3
+ } from '../chunk-ZD7AOCMD.mjs';
4
4
  import * as intlayerPlugin from './intlayerCracoPlugin.mjs';
5
5
  var require_craco_config = __commonJS({
6
6
  "src/craco/craco.config.ts"(exports, module) {
@@ -1,4 +1,4 @@
1
- import "../chunk-ZNCO4QRF.mjs";
1
+ import "../chunk-ZD7AOCMD.mjs";
2
2
  import { resolve, relative, join } from "path";
3
3
  import { getConfiguration, formatEnvVariable } from "@intlayer/config";
4
4
  import { IntLayerPlugin as IntLayerWebpackPlugin } from "@intlayer/webpack";
@@ -1,4 +1,4 @@
1
- import "./chunk-ZNCO4QRF.mjs";
1
+ import "./chunk-ZD7AOCMD.mjs";
2
2
  import { getEnumerationContent } from "@intlayer/core";
3
3
  const getEnumeration = (enumerationContent, quantity) => {
4
4
  const result = getEnumerationContent(
@@ -1,4 +1,4 @@
1
- import "./chunk-ZNCO4QRF.mjs";
1
+ import "./chunk-ZD7AOCMD.mjs";
2
2
  import { getConfiguration } from "@intlayer/config/client";
3
3
  import { getTranslationContent } from "@intlayer/core";
4
4
  const getTranslation = (languageContent, locale) => {
@@ -1,13 +1,14 @@
1
1
  export { getTranslation } from './getTranslation.mjs';
2
- export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps } from './client/IntlayerClientProvider.mjs';
2
+ export { IntlayerClientContext, IntlayerProvider, IntlayerProviderProps } from './client/IntlayerProvider.mjs';
3
3
  export { useIntlayer } from './client/useIntlayer.mjs';
4
4
  export { useLocaleBase } from './client/useLocaleBase.mjs';
5
5
  export { useLocale } from './client/useLocale.mjs';
6
6
  export { useTraduction } from './client/useTraduction.mjs';
7
7
  export { localeCookie, setLocaleCookie, useLocaleCookie } from './client/useLocaleCookie.mjs';
8
8
  export { getBrowserLocale } from './client/getBrowserLocale.mjs';
9
+ export { IntlayerNode } from './useIntlayerBase.mjs';
9
10
  import '@intlayer/config/client';
10
11
  import '@intlayer/core';
11
12
  import 'react';
12
- import './useIntlayerBase.mjs';
13
+ import '@intlayer/config';
13
14
  import 'intlayer';
@@ -1,8 +1,8 @@
1
- import "./chunk-ZNCO4QRF.mjs";
1
+ import "./chunk-ZD7AOCMD.mjs";
2
2
  import { getTranslation } from './getTranslation.mjs';
3
3
  import {
4
- IntlayerClientProvider,
5
- IntlayerClient,
4
+ IntlayerProvider,
5
+ IntlayerClientContext,
6
6
  useIntlayer,
7
7
  useLocale,
8
8
  useTraduction,
@@ -13,8 +13,8 @@ import {
13
13
  useLocaleBase
14
14
  } from './client/index.mjs';
15
15
  export {
16
- IntlayerClient,
17
- IntlayerClientProvider,
16
+ IntlayerClientContext,
17
+ IntlayerProvider,
18
18
  getBrowserLocale,
19
19
  getTranslation,
20
20
  localeCookie,
@@ -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 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":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n IntlayerProvider,\n type IntlayerProviderProps,\n IntlayerClientContext,\n useIntlayer,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n getBrowserLocale,\n useLocaleBase,\n} from './client/index';\nexport type { IntlayerNode } from './useIntlayerBase';\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":[]}
@@ -1,16 +1,16 @@
1
- import { TranslationContent } from '@intlayer/core';
1
+ import { KeyPath, Locales } from '@intlayer/core';
2
2
  import { ReactNode } from 'react';
3
3
 
4
- type ContentValue = string | {
5
- [key: string]: ContentValue;
6
- } | TranslationContent<unknown>;
7
- type Content = Record<string, ContentValue | undefined>;
8
4
  type TransformedContentValue = string | ReactNode | {
9
5
  [key: string]: TransformedContentValue;
10
6
  } | undefined | ((quantity: number) => TransformedContentValue);
11
- type TransformedContent = Record<string, TransformedContentValue | undefined> | ReactNode;
12
- type ContentDictionary = Content & {
13
- id: string;
7
+ type TransformedContentObject = {
8
+ dictionaryId: string;
9
+ dictionaryPath: string;
10
+ keyPath: KeyPath[];
11
+ locale: Locales;
12
+ content: TransformedContentValue | TransformedContentValue[] | undefined;
14
13
  };
14
+ type TransformedContent = Record<string, TransformedContentValue | TransformedContentValue[] | TransformedContentObject | undefined> | ReactNode;
15
15
 
16
- export type { Content, ContentDictionary, ContentValue, TransformedContent, TransformedContentValue };
16
+ export type { TransformedContent, TransformedContentObject, TransformedContentValue };
@@ -1,12 +1,12 @@
1
1
  import { Locales } from '@intlayer/config/client';
2
- import { KeyPath } from '@intlayer/core';
3
- import { ContentValue, TransformedContentValue, Content, TransformedContent } from './contentDictionary.mjs';
2
+ import { DictionaryValue, KeyPath, Dictionary } from '@intlayer/core';
3
+ import { TransformedContentValue, TransformedContent } from './contentDictionary.mjs';
4
4
  import 'react';
5
5
 
6
- declare const processNode: (field: ContentValue | undefined, locale: Locales, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[]) => TransformedContentValue;
6
+ declare const processNode: (field: DictionaryValue | undefined, locale: Locales, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[]) => TransformedContentValue;
7
7
  /**
8
8
  * Function that process a dictionary and return the result to be used in the application.
9
9
  */
10
- declare const processDictionary: (content: Content, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[], locale?: Locales) => TransformedContent;
10
+ declare const processDictionary: (content: Dictionary | DictionaryValue, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[], locale?: Locales) => TransformedContent;
11
11
 
12
12
  export { processDictionary, processNode };
@@ -1,10 +1,9 @@
1
- import "../chunk-ZNCO4QRF.mjs";
1
+ import "../chunk-ZD7AOCMD.mjs";
2
2
  import { getConfiguration } from "@intlayer/config/client";
3
3
  import {
4
4
  NodeType,
5
5
  findMatchingCondition
6
6
  } from "@intlayer/core";
7
- import { renderContentEditor } from "intlayer-editor/client";
8
7
  import { createElement } from "react";
9
8
  import { getEnumeration } from '../getEnumeration.mjs';
10
9
  import { getTranslation } from '../getTranslation.mjs';
@@ -28,35 +27,33 @@ const processTranslation = (languageContent, locale, dictionaryId, dictionaryPat
28
27
  locale
29
28
  );
30
29
  };
31
- const processEnumeration = (enumerationContent, locale, dictionaryId, dictionaryPath, keyPath = []) => {
32
- return (quantity) => {
33
- const enumerationResult = getEnumeration(
34
- enumerationContent,
35
- quantity
36
- );
37
- const matchingCondition = findMatchingCondition(
38
- enumerationContent,
39
- quantity
40
- );
41
- const resultKeyPath = [
42
- ...keyPath,
43
- { type: NodeType.Enumeration, key: matchingCondition.toString() }
44
- ];
45
- return processDictionary(
46
- enumerationResult,
47
- dictionaryId,
48
- dictionaryPath,
49
- resultKeyPath,
50
- locale
51
- );
52
- };
30
+ const processEnumeration = (enumerationContent, locale, dictionaryId, dictionaryPath, keyPath = []) => (quantity) => {
31
+ const enumerationResult = getEnumeration(
32
+ enumerationContent,
33
+ quantity
34
+ );
35
+ const matchingCondition = findMatchingCondition(
36
+ enumerationContent,
37
+ quantity
38
+ );
39
+ const resultKeyPath = [
40
+ ...keyPath,
41
+ { type: NodeType.Enumeration, key: matchingCondition.toString() }
42
+ ];
43
+ return processDictionary(
44
+ enumerationResult,
45
+ dictionaryId,
46
+ dictionaryPath,
47
+ resultKeyPath,
48
+ locale
49
+ );
53
50
  };
54
51
  const isReactNode = (node) => typeof node?.key !== "undefined" && typeof node?.props !== "undefined";
55
52
  const processNode = (field, locale, dictionaryId, dictionaryPath, keyPath = []) => {
56
53
  if (typeof field === "object") {
57
54
  if (field.nodeType === NodeType.Translation) {
58
55
  return processTranslation(
59
- field,
56
+ field[NodeType.Translation],
60
57
  locale,
61
58
  dictionaryId,
62
59
  dictionaryPath,
@@ -65,7 +62,7 @@ const processNode = (field, locale, dictionaryId, dictionaryPath, keyPath = [])
65
62
  }
66
63
  if (field.nodeType === NodeType.Enumeration) {
67
64
  return processEnumeration(
68
- field,
65
+ field[NodeType.Enumeration],
69
66
  locale,
70
67
  dictionaryId,
71
68
  dictionaryPath,
@@ -106,7 +103,7 @@ const createReactElement = (element) => {
106
103
  const { type, props } = fixedElement;
107
104
  return createElement(type ?? "div", props, ...props.children);
108
105
  };
109
- const traceKeys = ["filePath", "id", "nodeType"];
106
+ const traceKeys = ["filePath", "nodeType"];
110
107
  const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [], locale = defaultLocale) => {
111
108
  if (isReactNode(content)) {
112
109
  return createReactElement(
@@ -114,40 +111,59 @@ const processDictionary = (content, dictionaryId, dictionaryPath, keyPath = [],
114
111
  );
115
112
  }
116
113
  if (content && typeof content === "object") {
117
- const result = {};
118
- for (const key of Object.keys(content)) {
119
- const field = content[key];
120
- if (traceKeys.includes(key)) {
121
- result[key] = field;
122
- continue;
123
- }
124
- const resultKeyPath = [
125
- ...keyPath,
126
- { type: "ObjectExpression", key }
127
- ];
128
- result[key] = processNode(
129
- field,
130
- locale,
131
- dictionaryId,
132
- dictionaryPath,
133
- resultKeyPath
134
- );
135
- }
136
- return result;
137
- }
138
- if (typeof content === "string") {
139
- try {
140
- return renderContentEditor(
114
+ const isArray = Array.isArray(content);
115
+ let result = {};
116
+ if (typeof content.nodeType !== "undefined") {
117
+ return processNode(
141
118
  content,
119
+ locale,
142
120
  dictionaryId,
143
121
  dictionaryPath,
144
122
  keyPath
145
123
  );
146
- } catch (e) {
147
- return content;
124
+ } else if (isArray) {
125
+ result = content.map((field, key) => {
126
+ const resultKeyPath = [
127
+ ...keyPath,
128
+ { type: "ArrayExpression", key }
129
+ ];
130
+ return processNode(
131
+ field,
132
+ locale,
133
+ dictionaryId,
134
+ dictionaryPath,
135
+ resultKeyPath
136
+ );
137
+ });
138
+ } else {
139
+ for (const key of Object.keys(content)) {
140
+ const field = content[key];
141
+ if (traceKeys.includes(key)) {
142
+ result[key] = field;
143
+ continue;
144
+ }
145
+ const resultKeyPath = [
146
+ ...keyPath,
147
+ { type: "ObjectExpression", key }
148
+ ];
149
+ const nodeResult = processNode(
150
+ field,
151
+ locale,
152
+ dictionaryId,
153
+ dictionaryPath,
154
+ resultKeyPath
155
+ );
156
+ result[key] = nodeResult;
157
+ }
148
158
  }
159
+ return result;
149
160
  }
150
- return content;
161
+ return {
162
+ content,
163
+ keyPath,
164
+ dictionaryId,
165
+ dictionaryPath
166
+ };
151
167
  };
152
168
  export {
153
169
  processDictionary,