react-intlayer 1.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 (163) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/ContentEditor/ContentEditor.cjs +113 -0
  3. package/dist/cjs/ContentEditor/ContentEditor.cjs.map +1 -0
  4. package/dist/cjs/ContentEditor/ContentEditor.d.ts +8 -0
  5. package/dist/cjs/ContentEditor/contentRender.cjs +45 -0
  6. package/dist/cjs/ContentEditor/contentRender.cjs.map +1 -0
  7. package/dist/cjs/ContentEditor/contentRender.d.ts +3 -0
  8. package/dist/cjs/ContentEditor/index.cjs +41 -0
  9. package/dist/cjs/ContentEditor/index.cjs.map +1 -0
  10. package/dist/cjs/ContentEditor/index.d.ts +3 -0
  11. package/dist/cjs/LocaleContextProvider.cjs +49 -0
  12. package/dist/cjs/LocaleContextProvider.cjs.map +1 -0
  13. package/dist/cjs/LocaleContextProvider.d.ts +10 -0
  14. package/dist/cjs/client/LocaleClientContextProvider.cjs +54 -0
  15. package/dist/cjs/client/LocaleClientContextProvider.cjs.map +1 -0
  16. package/dist/cjs/client/LocaleClientContextProvider.d.ts +20 -0
  17. package/dist/cjs/client/index.cjs +56 -0
  18. package/dist/cjs/client/index.cjs.map +1 -0
  19. package/dist/cjs/client/index.d.ts +19 -0
  20. package/dist/cjs/client/useContent.cjs +44 -0
  21. package/dist/cjs/client/useContent.cjs.map +1 -0
  22. package/dist/cjs/client/useContent.d.ts +12 -0
  23. package/dist/cjs/client/useIntlayer.cjs +44 -0
  24. package/dist/cjs/client/useIntlayer.cjs.map +1 -0
  25. package/dist/cjs/client/useIntlayer.d.ts +7 -0
  26. package/dist/cjs/client/useLocale.cjs +55 -0
  27. package/dist/cjs/client/useLocale.cjs.map +1 -0
  28. package/dist/cjs/client/useLocale.d.ts +10 -0
  29. package/dist/cjs/client/useLocaleCookie.cjs +70 -0
  30. package/dist/cjs/client/useLocaleCookie.cjs.map +1 -0
  31. package/dist/cjs/client/useLocaleCookie.d.ts +10 -0
  32. package/dist/cjs/client/useTraduction.cjs +42 -0
  33. package/dist/cjs/client/useTraduction.cjs.map +1 -0
  34. package/dist/cjs/client/useTraduction.d.ts +7 -0
  35. package/dist/cjs/getEnumeration.cjs +45 -0
  36. package/dist/cjs/getEnumeration.cjs.map +1 -0
  37. package/dist/cjs/getEnumeration.d.ts +8 -0
  38. package/dist/cjs/getTranslation.cjs +47 -0
  39. package/dist/cjs/getTranslation.cjs.map +1 -0
  40. package/dist/cjs/getTranslation.d.ts +9 -0
  41. package/dist/cjs/index.cjs +53 -0
  42. package/dist/cjs/index.cjs.map +1 -0
  43. package/dist/cjs/index.d.ts +20 -0
  44. package/dist/cjs/processDictionary/contentDictionary.d.cjs +21 -0
  45. package/dist/cjs/processDictionary/contentDictionary.d.cjs.map +1 -0
  46. package/dist/cjs/processDictionary/contentDictionary.d.d.ts +32 -0
  47. package/dist/cjs/processDictionary/index.cjs +82 -0
  48. package/dist/cjs/processDictionary/index.cjs.map +1 -0
  49. package/dist/cjs/processDictionary/index.d.ts +22 -0
  50. package/dist/cjs/server/LocaleServerContextProvider.cjs +49 -0
  51. package/dist/cjs/server/LocaleServerContextProvider.cjs.map +1 -0
  52. package/dist/cjs/server/LocaleServerContextProvider.d.ts +34 -0
  53. package/dist/cjs/server/getLocaleTranslation.cjs +50 -0
  54. package/dist/cjs/server/getLocaleTranslation.cjs.map +1 -0
  55. package/dist/cjs/server/getLocaleTranslation.d.ts +11 -0
  56. package/dist/cjs/server/index.cjs +49 -0
  57. package/dist/cjs/server/index.cjs.map +1 -0
  58. package/dist/cjs/server/index.d.ts +13 -0
  59. package/dist/cjs/server/serverContext.cjs +81 -0
  60. package/dist/cjs/server/serverContext.cjs.map +1 -0
  61. package/dist/cjs/server/serverContext.d.ts +43 -0
  62. package/dist/cjs/server/useIntlayer.cjs +44 -0
  63. package/dist/cjs/server/useIntlayer.cjs.map +1 -0
  64. package/dist/cjs/server/useIntlayer.d.ts +7 -0
  65. package/dist/cjs/server/useTraduction.cjs +42 -0
  66. package/dist/cjs/server/useTraduction.cjs.map +1 -0
  67. package/dist/cjs/server/useTraduction.d.ts +7 -0
  68. package/dist/cjs/useIntlayerBase.cjs +56 -0
  69. package/dist/cjs/useIntlayerBase.cjs.map +1 -0
  70. package/dist/cjs/useIntlayerBase.d.ts +23 -0
  71. package/dist/esm/ContentEditor/ContentEditor.d.mts +8 -0
  72. package/dist/esm/ContentEditor/ContentEditor.mjs +82 -0
  73. package/dist/esm/ContentEditor/ContentEditor.mjs.map +1 -0
  74. package/dist/esm/ContentEditor/contentRender.d.mts +3 -0
  75. package/dist/esm/ContentEditor/contentRender.mjs +11 -0
  76. package/dist/esm/ContentEditor/contentRender.mjs.map +1 -0
  77. package/dist/esm/ContentEditor/index.d.mts +3 -0
  78. package/dist/esm/ContentEditor/index.mjs +3 -0
  79. package/dist/esm/ContentEditor/index.mjs.map +1 -0
  80. package/dist/esm/LocaleContextProvider.d.mts +10 -0
  81. package/dist/esm/LocaleContextProvider.mjs +15 -0
  82. package/dist/esm/LocaleContextProvider.mjs.map +1 -0
  83. package/dist/esm/client/LocaleClientContextProvider.d.mts +20 -0
  84. package/dist/esm/client/LocaleClientContextProvider.mjs +16 -0
  85. package/dist/esm/client/LocaleClientContextProvider.mjs.map +1 -0
  86. package/dist/esm/client/index.d.mts +19 -0
  87. package/dist/esm/client/index.mjs +25 -0
  88. package/dist/esm/client/index.mjs.map +1 -0
  89. package/dist/esm/client/useContent.d.mts +12 -0
  90. package/dist/esm/client/useContent.mjs +13 -0
  91. package/dist/esm/client/useContent.mjs.map +1 -0
  92. package/dist/esm/client/useIntlayer.d.mts +7 -0
  93. package/dist/esm/client/useIntlayer.mjs +11 -0
  94. package/dist/esm/client/useIntlayer.mjs.map +1 -0
  95. package/dist/esm/client/useLocale.d.mts +10 -0
  96. package/dist/esm/client/useLocale.mjs +21 -0
  97. package/dist/esm/client/useLocale.mjs.map +1 -0
  98. package/dist/esm/client/useLocaleCookie.d.mts +10 -0
  99. package/dist/esm/client/useLocaleCookie.mjs +20 -0
  100. package/dist/esm/client/useLocaleCookie.mjs.map +1 -0
  101. package/dist/esm/client/useTraduction.d.mts +7 -0
  102. package/dist/esm/client/useTraduction.mjs +9 -0
  103. package/dist/esm/client/useTraduction.mjs.map +1 -0
  104. package/dist/esm/getEnumeration.d.mts +8 -0
  105. package/dist/esm/getEnumeration.mjs +11 -0
  106. package/dist/esm/getEnumeration.mjs.map +1 -0
  107. package/dist/esm/getTranslation.d.mts +9 -0
  108. package/dist/esm/getTranslation.mjs +16 -0
  109. package/dist/esm/getTranslation.mjs.map +1 -0
  110. package/dist/esm/index.d.mts +20 -0
  111. package/dist/esm/index.mjs +25 -0
  112. package/dist/esm/index.mjs.map +1 -0
  113. package/dist/esm/processDictionary/contentDictionary.d.d.mts +32 -0
  114. package/dist/esm/processDictionary/contentDictionary.d.mjs +1 -0
  115. package/dist/esm/processDictionary/contentDictionary.d.mjs.map +1 -0
  116. package/dist/esm/processDictionary/index.d.mts +22 -0
  117. package/dist/esm/processDictionary/index.mjs +43 -0
  118. package/dist/esm/processDictionary/index.mjs.map +1 -0
  119. package/dist/esm/server/LocaleServerContextProvider.d.mts +34 -0
  120. package/dist/esm/server/LocaleServerContextProvider.mjs +14 -0
  121. package/dist/esm/server/LocaleServerContextProvider.mjs.map +1 -0
  122. package/dist/esm/server/getLocaleTranslation.d.mts +11 -0
  123. package/dist/esm/server/getLocaleTranslation.mjs +17 -0
  124. package/dist/esm/server/getLocaleTranslation.mjs.map +1 -0
  125. package/dist/esm/server/index.d.mts +13 -0
  126. package/dist/esm/server/index.mjs +17 -0
  127. package/dist/esm/server/index.mjs.map +1 -0
  128. package/dist/esm/server/serverContext.d.mts +43 -0
  129. package/dist/esm/server/serverContext.mjs +33 -0
  130. package/dist/esm/server/serverContext.mjs.map +1 -0
  131. package/dist/esm/server/useIntlayer.d.mts +7 -0
  132. package/dist/esm/server/useIntlayer.mjs +9 -0
  133. package/dist/esm/server/useIntlayer.mjs.map +1 -0
  134. package/dist/esm/server/useTraduction.d.mts +7 -0
  135. package/dist/esm/server/useTraduction.mjs +9 -0
  136. package/dist/esm/server/useTraduction.mjs.map +1 -0
  137. package/dist/esm/useIntlayerBase.d.mts +23 -0
  138. package/dist/esm/useIntlayerBase.mjs +8 -0
  139. package/dist/esm/useIntlayerBase.mjs.map +1 -0
  140. package/package.json +95 -0
  141. package/src/ContentEditor/ContentEditor.tsx +116 -0
  142. package/src/ContentEditor/contentRender.tsx +11 -0
  143. package/src/ContentEditor/index.tsx +2 -0
  144. package/src/LocaleContextProvider.tsx +26 -0
  145. package/src/client/LocaleClientContextProvider.tsx +35 -0
  146. package/src/client/index.ts +14 -0
  147. package/src/client/useContent.ts +17 -0
  148. package/src/client/useIntlayer.ts +20 -0
  149. package/src/client/useLocale.ts +19 -0
  150. package/src/client/useLocaleCookie.ts +27 -0
  151. package/src/client/useTraduction.ts +12 -0
  152. package/src/getEnumeration.ts +18 -0
  153. package/src/getTranslation.ts +24 -0
  154. package/src/index.ts +14 -0
  155. package/src/processDictionary/contentDictionary.d.ts +27 -0
  156. package/src/processDictionary/index.ts +97 -0
  157. package/src/server/LocaleServerContextProvider.tsx +24 -0
  158. package/src/server/getLocaleTranslation.ts +19 -0
  159. package/src/server/index.ts +8 -0
  160. package/src/server/serverContext.ts +85 -0
  161. package/src/server/useIntlayer.ts +17 -0
  162. package/src/server/useTraduction.ts +13 -0
  163. package/src/useIntlayerBase.ts +32 -0
@@ -0,0 +1,15 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { intlayerIntlConfiguration } from "@intlayer/config/client";
3
+ import { LocaleClientContextProvider } from "./client/LocaleClientContextProvider.mjs";
4
+ import { LocaleServerContextProvider } from "./server/LocaleServerContextProvider.mjs";
5
+ const defaultLocale = intlayerIntlConfiguration.defaultLocale;
6
+ const LocaleContextProvider = ({ children, locale = defaultLocale }) =>
7
+ /* @__PURE__ */ jsx(LocaleServerContextProvider, {
8
+ locale,
9
+ children: /* @__PURE__ */ jsx(LocaleClientContextProvider, {
10
+ locale,
11
+ children,
12
+ }),
13
+ });
14
+ export { LocaleContextProvider };
15
+ //# sourceMappingURL=LocaleContextProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/LocaleContextProvider.tsx"],"sourcesContent":["import { intlayerIntlConfiguration } from '@intlayer/config/client';\nimport React, { type FC } from 'react';\nimport {\n LocaleClientContextProvider,\n type LocaleClientContextProviderProps,\n} from './client/LocaleClientContextProvider';\nimport {\n LocaleServerContextProvider,\n type LocaleServerContextProviderProps,\n} from './server/LocaleServerContextProvider';\n\nconst defaultLocale = intlayerIntlConfiguration.defaultLocale;\n\ntype LocaleContextProviderProps = LocaleClientContextProviderProps &\n LocaleServerContextProviderProps;\n\nexport const LocaleContextProvider: FC<LocaleContextProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <LocaleServerContextProvider locale={locale}>\n <LocaleClientContextProvider locale={locale}>\n {children}\n </LocaleClientContextProvider>\n </LocaleServerContextProvider>\n);\n"],"mappings":"AAqBI;AArBJ,SAAS,iCAAiC;AAE1C;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAEK;AAEP,MAAM,gBAAgB,0BAA0B;AAKzC,MAAM,wBAAwD,CAAC;AAAA,EACpE;AAAA,EACA,SAAS;AACX,MACE,oBAAC,+BAA4B,QAC3B,8BAAC,+BAA4B,QAC1B,UACH,GACF;","names":[]}
@@ -0,0 +1,20 @@
1
+ import * as react from "react";
2
+ import { PropsWithChildren, FC } from "react";
3
+ import { Locales } from "@intlayer/config/client";
4
+
5
+ type LocaleContextValue = {
6
+ locale: Locales;
7
+ };
8
+ declare const LocaleClientContext: react.Context<LocaleContextValue>;
9
+ declare const useLocaleContext: () => LocaleContextValue;
10
+ type LocaleClientContextProviderProps = PropsWithChildren & {
11
+ locale: Locales;
12
+ };
13
+ declare const LocaleClientContextProvider: FC<LocaleClientContextProviderProps>;
14
+
15
+ export {
16
+ LocaleClientContext,
17
+ LocaleClientContextProvider,
18
+ type LocaleClientContextProviderProps,
19
+ useLocaleContext,
20
+ };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { intlayerIntlConfiguration } from "@intlayer/config/client";
4
+ import { createContext, useContext } from "react";
5
+ import { localeCookie } from "./useLocaleCookie.mjs";
6
+ const LocaleClientContext = createContext({
7
+ locale: localeCookie ?? intlayerIntlConfiguration.defaultLocale,
8
+ });
9
+ const useLocaleContext = () => useContext(LocaleClientContext);
10
+ const LocaleClientContextProvider = ({ locale, children }) =>
11
+ /* @__PURE__ */ jsx(LocaleClientContext.Provider, {
12
+ value: { locale },
13
+ children,
14
+ });
15
+ export { LocaleClientContext, LocaleClientContextProvider, useLocaleContext };
16
+ //# sourceMappingURL=LocaleClientContextProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/LocaleClientContextProvider.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 LocaleContextValue = {\n locale: Locales;\n};\n\nexport const LocaleClientContext = createContext<LocaleContextValue>({\n locale: localeCookie ?? intlayerIntlConfiguration.defaultLocale,\n});\n\nexport const useLocaleContext = () => useContext(LocaleClientContext);\n\nexport type LocaleClientContextProviderProps = PropsWithChildren & {\n locale: Locales;\n};\n\nexport const LocaleClientContextProvider: FC<\n LocaleClientContextProviderProps\n> = ({ locale, children }) => (\n <LocaleClientContext.Provider value={{ locale }}>\n {children}\n </LocaleClientContext.Provider>\n);\n"],"mappings":";AA+BE;AA7BF;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB;AAMtB,MAAM,sBAAsB,cAAkC;AAAA,EACnE,QAAQ,gBAAgB,0BAA0B;AACpD,CAAC;AAEM,MAAM,mBAAmB,MAAM,WAAW,mBAAmB;AAM7D,MAAM,8BAET,CAAC,EAAE,QAAQ,SAAS,MACtB,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,EAAE,OAAO,GAC3C,UACH;","names":[]}
@@ -0,0 +1,19 @@
1
+ export {
2
+ LocaleClientContext,
3
+ LocaleClientContextProvider,
4
+ LocaleClientContextProviderProps,
5
+ useLocaleContext,
6
+ } from "./LocaleClientContextProvider.mjs";
7
+ export { useIntlayer } from "./useIntlayer.mjs";
8
+ export { useLocale } from "./useLocale.mjs";
9
+ export { useTraduction } from "./useTraduction.mjs";
10
+ export {
11
+ localeCookie,
12
+ setLocaleCookie,
13
+ useLocaleCookie,
14
+ } from "./useLocaleCookie.mjs";
15
+ import "react";
16
+ import "@intlayer/config/client";
17
+ import "../useIntlayerBase.mjs";
18
+ import "intlayer";
19
+ import "@intlayer/core";
@@ -0,0 +1,25 @@
1
+ import {
2
+ LocaleClientContext,
3
+ useLocaleContext,
4
+ LocaleClientContextProvider,
5
+ } from "./LocaleClientContextProvider.mjs";
6
+ import { useIntlayer } from "./useIntlayer.mjs";
7
+ import { useLocale } from "./useLocale.mjs";
8
+ import { useTraduction } from "./useTraduction.mjs";
9
+ import {
10
+ useLocaleCookie,
11
+ localeCookie,
12
+ setLocaleCookie,
13
+ } from "./useLocaleCookie.mjs";
14
+ export {
15
+ LocaleClientContext,
16
+ LocaleClientContextProvider,
17
+ localeCookie,
18
+ setLocaleCookie,
19
+ useIntlayer,
20
+ useLocale,
21
+ useLocaleContext,
22
+ useLocaleCookie,
23
+ useTraduction,
24
+ };
25
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export type { LocaleClientContextProviderProps } from './LocaleClientContextProvider';\nexport {\n LocaleClientContext,\n useLocaleContext,\n LocaleClientContextProvider,\n} from './LocaleClientContextProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -0,0 +1,12 @@
1
+ import * as intlayer from "intlayer";
2
+ import { LanguageContent } from "@intlayer/core";
3
+
4
+ declare const useContent: <Content>(
5
+ languageContent: LanguageContent<Content>
6
+ ) => {
7
+ locale: intlayer.Locales;
8
+ content: Content;
9
+ t: <Content_1>(languageContent: LanguageContent<Content_1>) => Content_1;
10
+ };
11
+
12
+ export { useContent };
@@ -0,0 +1,13 @@
1
+ import { useLocale } from "./useLocale.mjs";
2
+ import { useTraduction } from "./useTraduction.mjs";
3
+ const useContent = (languageContent) => {
4
+ const { locale } = useLocale();
5
+ const content = useTraduction(languageContent);
6
+ return {
7
+ locale,
8
+ content,
9
+ t: useTraduction,
10
+ };
11
+ };
12
+ export { useContent };
13
+ //# sourceMappingURL=useContent.mjs.map
@@ -0,0 +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\nexport const useContent = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const { locale } = useLocale();\n\n const content = useTraduction(languageContent);\n\n return {\n locale,\n content,\n t: useTraduction,\n };\n};\n"],"mappings":"AACA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAEvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,UAAU,cAAc,eAAe;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { UseIntlayer } from "../useIntlayerBase.mjs";
2
+ import "@intlayer/config/client";
3
+ import "intlayer";
4
+
5
+ declare const useIntlayer: UseIntlayer;
6
+
7
+ export { useIntlayer };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { useContext } from "react";
3
+ import { useIntlayerBase } from "../useIntlayerBase.mjs";
4
+ import { LocaleClientContext } from "./LocaleClientContextProvider.mjs";
5
+ const useIntlayer = (id, locale) => {
6
+ const { locale: currentLocale } = useContext(LocaleClientContext);
7
+ const localeTarget = locale ?? currentLocale;
8
+ return useIntlayerBase(id, localeTarget);
9
+ };
10
+ export { useIntlayer };
11
+ //# sourceMappingURL=useIntlayer.mjs.map
@@ -0,0 +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 { LocaleClientContext } from './LocaleClientContextProvider';\n\nexport const useIntlayer: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const { locale: currentLocale } = useContext(LocaleClientContext);\n const localeTarget = locale ?? currentLocale;\n\n return useIntlayerBase(id, localeTarget);\n};\n"],"mappings":";AAGA,SAAS,kBAAkB;AAC3B;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,2BAA2B;AAE7B,MAAM,cAA2B,CACtC,IACA,WACG;AACH,QAAM,EAAE,QAAQ,cAAc,IAAI,WAAW,mBAAmB;AAChE,QAAM,eAAe,UAAU;AAE/B,SAAO,gBAAgB,IAAI,YAAY;AACzC;","names":[]}
@@ -0,0 +1,10 @@
1
+ import * as _intlayer_config_client from "@intlayer/config/client";
2
+
3
+ declare const useLocale: () => {
4
+ locale: _intlayer_config_client.Locales;
5
+ defaultLocale: _intlayer_config_client.Locales;
6
+ availableLocales: _intlayer_config_client.Locales[];
7
+ localeList: _intlayer_config_client.Locales[];
8
+ };
9
+
10
+ export { useLocale };
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { intlayerIntlConfiguration } from "@intlayer/config/client";
3
+ import { localeList } from "@intlayer/core";
4
+ import { useContext } from "react";
5
+ import { LocaleClientContext } from "./LocaleClientContextProvider.mjs";
6
+ const { defaultLocale, locales: availableLocales } = intlayerIntlConfiguration;
7
+ const useLocale = () => {
8
+ const { locale } = useContext(LocaleClientContext);
9
+ return {
10
+ locale,
11
+ // Current locale
12
+ defaultLocale,
13
+ // Principal locale defined in config
14
+ availableLocales,
15
+ // List of the available locales defined in config
16
+ localeList,
17
+ // List of all available locales
18
+ };
19
+ };
20
+ export { useLocale };
21
+ //# sourceMappingURL=useLocale.mjs.map
@@ -0,0 +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 { LocaleClientContext } from './LocaleClientContextProvider';\n\nconst { defaultLocale, locales: availableLocales } = intlayerIntlConfiguration;\n\nexport const useLocale = () => {\n const { locale } = useContext(LocaleClientContext);\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n localeList, // List of all available locales\n };\n};\n"],"mappings":";AAEA,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AAEpC,MAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAE9C,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,OAAO,IAAI,WAAW,mBAAmB;AAEjD,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { Locales } from "@intlayer/config/client";
2
+
3
+ declare const localeCookie: Locales | undefined;
4
+ declare const setLocaleCookie: (locale: Locales) => void;
5
+ declare const useLocaleCookie: () => {
6
+ localeCookie: Locales | undefined;
7
+ setLocaleCookie: (locale: Locales) => void;
8
+ };
9
+
10
+ export { localeCookie, setLocaleCookie, useLocaleCookie };
@@ -0,0 +1,20 @@
1
+ import { intlayerMiddlewareConfiguration } from "@intlayer/config/client";
2
+ import Cookies from "js-cookie";
3
+ const { cookieName } = intlayerMiddlewareConfiguration;
4
+ const cookieAttributes = {
5
+ path: "/",
6
+ expires: void 0,
7
+ domain: void 0,
8
+ secure: false,
9
+ sameSite: "strict",
10
+ };
11
+ const localeCookie = Cookies.get(cookieName);
12
+ const setLocaleCookie = (locale) => {
13
+ Cookies.set(cookieName, locale, cookieAttributes);
14
+ };
15
+ const useLocaleCookie = () => ({
16
+ localeCookie,
17
+ setLocaleCookie,
18
+ });
19
+ export { localeCookie, setLocaleCookie, useLocaleCookie };
20
+ //# sourceMappingURL=useLocaleCookie.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/useLocaleCookie.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-redundant-type-constituents */\nimport {\n type Locales,\n intlayerMiddlewareConfiguration,\n} from '@intlayer/config/client';\nimport Cookies from 'js-cookie';\n\nconst { cookieName } = intlayerMiddlewareConfiguration;\n\nconst cookieAttributes: Cookies.CookieAttributes = {\n path: '/',\n expires: undefined,\n domain: undefined,\n secure: false,\n sameSite: 'strict',\n};\n\nexport const localeCookie = Cookies.get(cookieName) as Locales | undefined;\n\nexport const setLocaleCookie = (locale: Locales) => {\n Cookies.set(cookieName, locale, cookieAttributes);\n};\n\nexport const useLocaleCookie = () => ({\n localeCookie,\n setLocaleCookie,\n});\n"],"mappings":"AACA;AAAA,EAEE;AAAA,OACK;AACP,OAAO,aAAa;AAEpB,MAAM,EAAE,WAAW,IAAI;AAEvB,MAAM,mBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AACZ;AAEO,MAAM,eAAe,QAAQ,IAAI,UAAU;AAE3C,MAAM,kBAAkB,CAAC,WAAoB;AAClD,UAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAEO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { LanguageContent } from "@intlayer/core";
2
+
3
+ declare const useTraduction: <Content>(
4
+ languageContent: LanguageContent<Content>
5
+ ) => Content;
6
+
7
+ export { useTraduction };
@@ -0,0 +1,9 @@
1
+ import { useContext } from "react";
2
+ import { getTranslation } from "../getTranslation.mjs";
3
+ import { LocaleClientContext } from "./LocaleClientContextProvider.mjs";
4
+ const useTraduction = (languageContent) => {
5
+ const { locale } = useContext(LocaleClientContext);
6
+ return getTranslation(languageContent, locale);
7
+ };
8
+ export { useTraduction };
9
+ //# sourceMappingURL=useTraduction.mjs.map
@@ -0,0 +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 { LocaleClientContext } from './LocaleClientContextProvider';\n\nexport const useTraduction = <Content>(\n languageContent: LanguageContent<Content>\n): Content => {\n const { locale } = useContext(LocaleClientContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":"AACA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AAE7B,MAAM,gBAAgB,CAC3B,oBACY;AACZ,QAAM,EAAE,OAAO,IAAI,WAAW,mBAAmB;AAEjD,SAAO,eAAe,iBAAiB,MAAM;AAC/C;","names":[]}
@@ -0,0 +1,8 @@
1
+ import { QuantityContent } from "@intlayer/core";
2
+
3
+ declare const getEnumeration: <Content>(
4
+ enumerationContent: QuantityContent<Content>,
5
+ quantity: number
6
+ ) => Content;
7
+
8
+ export { getEnumeration };
@@ -0,0 +1,11 @@
1
+ import { getEnumerationContent } from "@intlayer/core";
2
+ import { contentRender } from "./ContentEditor/contentRender.mjs";
3
+ const getEnumeration = (enumerationContent, quantity) => {
4
+ const result = getEnumerationContent(enumerationContent, quantity);
5
+ if (typeof result === "string") {
6
+ return contentRender(result);
7
+ }
8
+ return result;
9
+ };
10
+ export { getEnumeration };
11
+ //# sourceMappingURL=getEnumeration.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getEnumeration.ts"],"sourcesContent":["import { type QuantityContent, getEnumerationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\nexport const getEnumeration = <Content>(\n enumerationContent: QuantityContent<Content>,\n quantity: number\n): Content => {\n const result: Content = getEnumerationContent<Content>(\n enumerationContent,\n quantity\n );\n\n if (typeof result === 'string') {\n return contentRender(result) as Content;\n }\n\n return result;\n};\n"],"mappings":"AAAA,SAA+B,6BAA6B;AAC5D,SAAS,qBAAqB;AAEvB,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO,cAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,9 @@
1
+ import { Locales } from "@intlayer/config/client";
2
+ import { LanguageContent } from "@intlayer/core";
3
+
4
+ declare const getTranslation: <Content>(
5
+ languageContent: LanguageContent<Content>,
6
+ locale?: Locales
7
+ ) => Content;
8
+
9
+ export { getTranslation };
@@ -0,0 +1,16 @@
1
+ import { intlayerIntlConfiguration } from "@intlayer/config/client";
2
+ import { getTranslationContent } from "@intlayer/core";
3
+ import { contentRender } from "./ContentEditor/contentRender.mjs";
4
+ const getTranslation = (languageContent, locale) => {
5
+ const { defaultLocale } = intlayerIntlConfiguration;
6
+ const result = getTranslationContent(
7
+ languageContent,
8
+ locale ?? defaultLocale
9
+ );
10
+ if (typeof result === "string") {
11
+ return contentRender(result);
12
+ }
13
+ return result;
14
+ };
15
+ export { getTranslation };
16
+ //# sourceMappingURL=getTranslation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getTranslation.ts"],"sourcesContent":["import {\n type Locales,\n intlayerIntlConfiguration,\n} from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\nimport { contentRender } from './ContentEditor/contentRender';\n\nexport const getTranslation = <Content>(\n languageContent: LanguageContent<Content>,\n locale?: Locales\n): Content => {\n const { defaultLocale } = intlayerIntlConfiguration;\n\n const result: Content = getTranslationContent<Content>(\n languageContent,\n locale ?? defaultLocale\n );\n\n if (typeof result === 'string') {\n return contentRender(result) as Content;\n }\n\n return result;\n};\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,OACK;AACP,SAA+B,6BAA6B;AAC5D,SAAS,qBAAqB;AAEvB,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,IAAI;AAE1B,QAAM,SAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO,cAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,20 @@
1
+ export { getTranslation } from "./getTranslation.mjs";
2
+ export {
3
+ LocaleClientContext,
4
+ LocaleClientContextProvider,
5
+ LocaleClientContextProviderProps,
6
+ useLocaleContext,
7
+ } from "./client/LocaleClientContextProvider.mjs";
8
+ export { useIntlayer } from "./client/useIntlayer.mjs";
9
+ export { useLocale } from "./client/useLocale.mjs";
10
+ export { useTraduction } from "./client/useTraduction.mjs";
11
+ export {
12
+ localeCookie,
13
+ setLocaleCookie,
14
+ useLocaleCookie,
15
+ } from "./client/useLocaleCookie.mjs";
16
+ import "@intlayer/config/client";
17
+ import "@intlayer/core";
18
+ import "react";
19
+ import "./useIntlayerBase.mjs";
20
+ import "intlayer";
@@ -0,0 +1,25 @@
1
+ import { getTranslation } from "./getTranslation.mjs";
2
+ import {
3
+ LocaleClientContextProvider,
4
+ LocaleClientContext,
5
+ useLocaleContext,
6
+ useIntlayer,
7
+ useLocale,
8
+ useTraduction,
9
+ useLocaleCookie,
10
+ localeCookie,
11
+ setLocaleCookie,
12
+ } from "./client/index.mjs";
13
+ export {
14
+ LocaleClientContext,
15
+ LocaleClientContextProvider,
16
+ getTranslation,
17
+ localeCookie,
18
+ setLocaleCookie,
19
+ useIntlayer,
20
+ useLocale,
21
+ useLocaleContext,
22
+ useLocaleCookie,
23
+ useTraduction,
24
+ };
25
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getTranslation } from './getTranslation';\nexport {\n LocaleClientContextProvider,\n type LocaleClientContextProviderProps,\n LocaleClientContext,\n useLocaleContext,\n useIntlayer,\n useLocale,\n useTraduction,\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './client/index';\nexport {} from './client/useLocaleCookie';\n"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -0,0 +1,32 @@
1
+ import { TranslationContent } from "@intlayer/core";
2
+
3
+ type ContentValue =
4
+ | string
5
+ | {
6
+ [key: string]: ContentValue;
7
+ }
8
+ | TranslationContent<unknown>;
9
+
10
+ type Content = Record<string, ContentValue | undefined>;
11
+
12
+ type TransformedContentValue =
13
+ | string
14
+ | {
15
+ [key: string]: TransformedContentValue;
16
+ }
17
+ | undefined
18
+ | ((quantity: number) => TransformedContentValue);
19
+
20
+ type TransformedContent = Record<string, TransformedContentValue | undefined>;
21
+
22
+ type ContentDictionary = Content & {
23
+ id: string;
24
+ };
25
+
26
+ export type {
27
+ Content,
28
+ ContentDictionary,
29
+ ContentValue,
30
+ TransformedContent,
31
+ TransformedContentValue,
32
+ };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=contentDictionary.d.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,22 @@
1
+ import { Locales } from "@intlayer/config/client";
2
+ import {
3
+ ContentValue,
4
+ TransformedContentValue,
5
+ Content,
6
+ TransformedContent,
7
+ } from "./contentDictionary.d.mjs";
8
+ import "@intlayer/core";
9
+
10
+ declare const processNode: (
11
+ field: ContentValue | undefined,
12
+ locale: Locales
13
+ ) => TransformedContentValue;
14
+ /**
15
+ * Function to replace the multi lingual content with content in the current locale
16
+ */
17
+ declare const processDictionary: (
18
+ content: Content,
19
+ locale?: Locales
20
+ ) => TransformedContent;
21
+
22
+ export { processDictionary, processNode };
@@ -0,0 +1,43 @@
1
+ import { intlayerIntlConfiguration } from "@intlayer/config/client";
2
+ import { NodeType } from "@intlayer/core";
3
+ import { getEnumeration } from "../getEnumeration.mjs";
4
+ import { getTranslation } from "../getTranslation.mjs";
5
+ const defaultLocale = intlayerIntlConfiguration.defaultLocale;
6
+ const processTranslation = (languageContent, locale) => {
7
+ const translationResult = getTranslation(languageContent, locale);
8
+ return processDictionary(translationResult, locale);
9
+ };
10
+ const processEnumeration = (enumerationContent, locale) => {
11
+ return (quantity) => {
12
+ const enumerationResult = getEnumeration(enumerationContent, quantity);
13
+ return processDictionary(enumerationResult, locale);
14
+ };
15
+ };
16
+ const processNode = (field, locale) => {
17
+ if (typeof field !== "object" || field === null) {
18
+ return field;
19
+ }
20
+ if (field.nodeType === NodeType.Translation) {
21
+ return processTranslation(field, locale);
22
+ }
23
+ if (field.nodeType === NodeType.Enumeration) {
24
+ return processEnumeration(field, locale);
25
+ }
26
+ if (typeof field.type === "undefined") {
27
+ return processDictionary(field, locale);
28
+ }
29
+ return field;
30
+ };
31
+ const processDictionary = (content, locale = defaultLocale) => {
32
+ if (content && typeof content === "object") {
33
+ const result = {};
34
+ for (const key of Object.keys(content)) {
35
+ const field = content[key];
36
+ result[key] = processNode(field, locale);
37
+ }
38
+ return result;
39
+ }
40
+ return content;
41
+ };
42
+ export { processDictionary, processNode };
43
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/processDictionary/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n type Locales,\n intlayerIntlConfiguration,\n} from '@intlayer/config/client';\nimport {\n NodeType,\n type QuantityContent,\n type LanguageContent,\n} from '@intlayer/core';\nimport { getEnumeration } from '../getEnumeration';\nimport { getTranslation } from '../getTranslation';\nimport type {\n Content,\n ContentValue,\n TransformedContent,\n TransformedContentValue,\n} from './contentDictionary';\n\nconst defaultLocale = intlayerIntlConfiguration.defaultLocale;\n\nconst processTranslation = (\n languageContent: LanguageContent<ContentValue>,\n locale: Locales\n): TransformedContent => {\n const translationResult: ContentValue = getTranslation<ContentValue>(\n languageContent,\n locale\n );\n\n return processDictionary(translationResult as Content, locale);\n};\n\nconst processEnumeration = (\n enumerationContent: QuantityContent<ContentValue>,\n locale: Locales\n): TransformedContentValue => {\n return (quantity: number): TransformedContentValue => {\n const enumerationResult: ContentValue = getEnumeration<ContentValue>(\n enumerationContent,\n quantity\n );\n\n //\n return processDictionary(enumerationResult as Content, locale);\n };\n};\n\nexport const processNode = (\n field: ContentValue | undefined,\n locale: Locales\n): TransformedContentValue => {\n if (typeof field !== 'object' || field === null) {\n return field;\n }\n\n if (field.nodeType === NodeType.Translation) {\n return processTranslation(field as LanguageContent<ContentValue>, locale);\n }\n\n if (field.nodeType === NodeType.Enumeration) {\n return processEnumeration(\n field satisfies QuantityContent<ContentValue>,\n locale\n );\n }\n\n if (typeof (field as any).type === 'undefined') {\n return processDictionary(field as Content, locale);\n }\n\n return field as TransformedContentValue;\n};\n\n/**\n * Function to replace the multi lingual content with content in the current locale\n */\nexport const processDictionary = (\n content: Content,\n locale: Locales = defaultLocale\n): TransformedContent => {\n if (content && typeof content === 'object') {\n const result: TransformedContent = {};\n\n // List each key in the content and process it\n for (const key of Object.keys(content)) {\n const field = content[key];\n\n result[key] = processNode(field, locale);\n }\n\n return result;\n }\n\n // If it's a string, number, or function, return it\n return content;\n};\n"],"mappings":"AACA;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAGK;AACP,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAQ/B,MAAM,gBAAgB,0BAA0B;AAEhD,MAAM,qBAAqB,CACzB,iBACA,WACuB;AACvB,QAAM,oBAAkC;AAAA,IACtC;AAAA,IACA;AAAA,EACF;AAEA,SAAO,kBAAkB,mBAA8B,MAAM;AAC/D;AAEA,MAAM,qBAAqB,CACzB,oBACA,WAC4B;AAC5B,SAAO,CAAC,aAA8C;AACpD,UAAM,oBAAkC;AAAA,MACtC;AAAA,MACA;AAAA,IACF;AAGA,WAAO,kBAAkB,mBAA8B,MAAM;AAAA,EAC/D;AACF;AAEO,MAAM,cAAc,CACzB,OACA,WAC4B;AAC5B,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,aAAa,SAAS,aAAa;AAC3C,WAAO,mBAAmB,OAAwC,MAAM;AAAA,EAC1E;AAEA,MAAI,MAAM,aAAa,SAAS,aAAa;AAC3C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAQ,MAAc,SAAS,aAAa;AAC9C,WAAO,kBAAkB,OAAkB,MAAM;AAAA,EACnD;AAEA,SAAO;AACT;AAKO,MAAM,oBAAoB,CAC/B,SACA,SAAkB,kBACK;AACvB,MAAI,WAAW,OAAO,YAAY,UAAU;AAC1C,UAAM,SAA6B,CAAC;AAGpC,eAAW,OAAO,OAAO,KAAK,OAAO,GAAG;AACtC,YAAM,QAAQ,QAAQ,GAAG;AAEzB,aAAO,GAAG,IAAI,YAAY,OAAO,MAAM;AAAA,IACzC;AAEA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;","names":[]}
@@ -0,0 +1,34 @@
1
+ import * as react from "react";
2
+ import { PropsWithChildren, FC } from "react";
3
+ import { Locales } from "@intlayer/config/client";
4
+
5
+ declare const LocaleServerContext: {
6
+ Provider: ({
7
+ children,
8
+ value,
9
+ }: {
10
+ children: react.ReactNode;
11
+ value: Locales;
12
+ }) => react.ReactNode;
13
+ Consumer: ({
14
+ children,
15
+ }: {
16
+ children: (context: Locales | undefined) => react.ReactNode;
17
+ }) => react.ReactNode;
18
+ _storage: () => {
19
+ value: Locales | undefined;
20
+ };
21
+ _defaultValue: Locales | undefined;
22
+ };
23
+ declare const locale: Locales | undefined;
24
+ type LocaleServerContextProviderProps = PropsWithChildren & {
25
+ locale: Locales;
26
+ };
27
+ declare const LocaleServerContextProvider: FC<LocaleServerContextProviderProps>;
28
+
29
+ export {
30
+ LocaleServerContext,
31
+ LocaleServerContextProvider,
32
+ type LocaleServerContextProviderProps,
33
+ locale,
34
+ };
@@ -0,0 +1,14 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { intlayerIntlConfiguration } from "@intlayer/config/client";
3
+ import { createServerContext, getServerContext } from "./serverContext.mjs";
4
+ const LocaleServerContext = createServerContext(
5
+ intlayerIntlConfiguration.defaultLocale
6
+ );
7
+ const locale = getServerContext(LocaleServerContext);
8
+ const LocaleServerContextProvider = ({ children, locale: locale2 }) =>
9
+ /* @__PURE__ */ jsx(LocaleServerContext.Provider, {
10
+ value: locale2,
11
+ children,
12
+ });
13
+ export { LocaleServerContext, LocaleServerContextProvider, locale };
14
+ //# sourceMappingURL=LocaleServerContextProvider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/LocaleServerContextProvider.tsx"],"sourcesContent":["import {\n type Locales,\n intlayerIntlConfiguration,\n} from '@intlayer/config/client';\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nexport const LocaleServerContext = createServerContext<Locales>(\n intlayerIntlConfiguration.defaultLocale\n);\n\nexport const locale = getServerContext(LocaleServerContext);\n\nexport type LocaleServerContextProviderProps = PropsWithChildren & {\n locale: Locales;\n};\n\nexport const LocaleServerContextProvider: FC<\n LocaleServerContextProviderProps\n> = ({ children, locale }) => (\n <LocaleServerContext.Provider value={locale}>\n {children}\n </LocaleServerContext.Provider>\n);\n"],"mappings":"AAoBE;AApBF;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,qBAAqB,wBAAwB;AAE/C,MAAM,sBAAsB;AAAA,EACjC,0BAA0B;AAC5B;AAEO,MAAM,SAAS,iBAAiB,mBAAmB;AAMnD,MAAM,8BAET,CAAC,EAAE,UAAU,QAAAA,QAAO,MACtB,oBAAC,oBAAoB,UAApB,EAA6B,OAAOA,SAClC,UACH;","names":["locale"]}
@@ -0,0 +1,11 @@
1
+ import * as _intlayer_config_client from "@intlayer/config/client";
2
+ import { LanguageContent } from "@intlayer/core";
3
+
4
+ declare const getLocaleTranslation: <Content>(
5
+ languageContent: LanguageContent<Content>
6
+ ) => {
7
+ locale: _intlayer_config_client.Locales | undefined;
8
+ content: Content;
9
+ };
10
+
11
+ export { getLocaleTranslation };
@@ -0,0 +1,17 @@
1
+ import { intlayerIntlConfiguration } from "@intlayer/config/client";
2
+ import { getTranslationContent } from "@intlayer/core";
3
+ import { LocaleServerContext } from "./LocaleServerContextProvider.mjs";
4
+ import { getServerContext } from "./serverContext.mjs";
5
+ const getLocaleTranslation = (languageContent) => {
6
+ const locale = getServerContext(LocaleServerContext);
7
+ const content = getTranslationContent(
8
+ languageContent,
9
+ locale ?? intlayerIntlConfiguration.defaultLocale
10
+ );
11
+ return {
12
+ locale,
13
+ content,
14
+ };
15
+ };
16
+ export { getLocaleTranslation };
17
+ //# sourceMappingURL=getLocaleTranslation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/getLocaleTranslation.ts"],"sourcesContent":["import { intlayerIntlConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\nimport { LocaleServerContext } from './LocaleServerContextProvider';\nimport { getServerContext } from './serverContext';\n\nexport const getLocaleTranslation = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext(LocaleServerContext);\n const content = getTranslationContent<Content>(\n languageContent,\n locale ?? intlayerIntlConfiguration.defaultLocale\n );\n\n return {\n locale,\n content,\n };\n};\n"],"mappings":"AAAA,SAAS,iCAAiC;AAC1C,SAA+B,6BAA6B;AAC5D,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AAE1B,MAAM,uBAAuB,CAClC,oBACG;AACH,QAAM,SAAS,iBAAiB,mBAAmB;AACnD,QAAM,UAAU;AAAA,IACd;AAAA,IACA,UAAU,0BAA0B;AAAA,EACtC;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,13 @@
1
+ export { getLocaleTranslation as getLocaleContent } from "./getLocaleTranslation.mjs";
2
+ export { useTraduction } from "./useTraduction.mjs";
3
+ export {
4
+ LocaleServerContext,
5
+ LocaleServerContextProvider,
6
+ locale,
7
+ } from "./LocaleServerContextProvider.mjs";
8
+ export { useIntlayer } from "./useIntlayer.mjs";
9
+ import "@intlayer/config/client";
10
+ import "@intlayer/core";
11
+ import "react";
12
+ import "../useIntlayerBase.mjs";
13
+ import "intlayer";
@@ -0,0 +1,17 @@
1
+ import { getLocaleTranslation } from "./getLocaleTranslation.mjs";
2
+ import { useTraduction } from "./useTraduction.mjs";
3
+ import {
4
+ LocaleServerContext,
5
+ locale,
6
+ LocaleServerContextProvider,
7
+ } from "./LocaleServerContextProvider.mjs";
8
+ import { useIntlayer } from "./useIntlayer.mjs";
9
+ export {
10
+ LocaleServerContext,
11
+ LocaleServerContextProvider,
12
+ getLocaleTranslation as getLocaleContent,
13
+ locale,
14
+ useIntlayer,
15
+ useTraduction,
16
+ };
17
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export { getLocaleTranslation as getLocaleContent } from './getLocaleTranslation';\nexport { useTraduction } from './useTraduction';\nexport {\n LocaleServerContext,\n locale,\n LocaleServerContextProvider,\n} from './LocaleServerContextProvider';\nexport { useIntlayer } from './useIntlayer';\n"],"mappings":"AAAA,SAAiC,4BAAwB;AACzD,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;","names":[]}