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.
- package/LICENSE +21 -0
- package/dist/cjs/ContentEditor/ContentEditor.cjs +113 -0
- package/dist/cjs/ContentEditor/ContentEditor.cjs.map +1 -0
- package/dist/cjs/ContentEditor/ContentEditor.d.ts +8 -0
- package/dist/cjs/ContentEditor/contentRender.cjs +45 -0
- package/dist/cjs/ContentEditor/contentRender.cjs.map +1 -0
- package/dist/cjs/ContentEditor/contentRender.d.ts +3 -0
- package/dist/cjs/ContentEditor/index.cjs +41 -0
- package/dist/cjs/ContentEditor/index.cjs.map +1 -0
- package/dist/cjs/ContentEditor/index.d.ts +3 -0
- package/dist/cjs/LocaleContextProvider.cjs +49 -0
- package/dist/cjs/LocaleContextProvider.cjs.map +1 -0
- package/dist/cjs/LocaleContextProvider.d.ts +10 -0
- package/dist/cjs/client/LocaleClientContextProvider.cjs +54 -0
- package/dist/cjs/client/LocaleClientContextProvider.cjs.map +1 -0
- package/dist/cjs/client/LocaleClientContextProvider.d.ts +20 -0
- package/dist/cjs/client/index.cjs +56 -0
- package/dist/cjs/client/index.cjs.map +1 -0
- package/dist/cjs/client/index.d.ts +19 -0
- package/dist/cjs/client/useContent.cjs +44 -0
- package/dist/cjs/client/useContent.cjs.map +1 -0
- package/dist/cjs/client/useContent.d.ts +12 -0
- package/dist/cjs/client/useIntlayer.cjs +44 -0
- package/dist/cjs/client/useIntlayer.cjs.map +1 -0
- package/dist/cjs/client/useIntlayer.d.ts +7 -0
- package/dist/cjs/client/useLocale.cjs +55 -0
- package/dist/cjs/client/useLocale.cjs.map +1 -0
- package/dist/cjs/client/useLocale.d.ts +10 -0
- package/dist/cjs/client/useLocaleCookie.cjs +70 -0
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -0
- package/dist/cjs/client/useLocaleCookie.d.ts +10 -0
- package/dist/cjs/client/useTraduction.cjs +42 -0
- package/dist/cjs/client/useTraduction.cjs.map +1 -0
- package/dist/cjs/client/useTraduction.d.ts +7 -0
- package/dist/cjs/getEnumeration.cjs +45 -0
- package/dist/cjs/getEnumeration.cjs.map +1 -0
- package/dist/cjs/getEnumeration.d.ts +8 -0
- package/dist/cjs/getTranslation.cjs +47 -0
- package/dist/cjs/getTranslation.cjs.map +1 -0
- package/dist/cjs/getTranslation.d.ts +9 -0
- package/dist/cjs/index.cjs +53 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +20 -0
- package/dist/cjs/processDictionary/contentDictionary.d.cjs +21 -0
- package/dist/cjs/processDictionary/contentDictionary.d.cjs.map +1 -0
- package/dist/cjs/processDictionary/contentDictionary.d.d.ts +32 -0
- package/dist/cjs/processDictionary/index.cjs +82 -0
- package/dist/cjs/processDictionary/index.cjs.map +1 -0
- package/dist/cjs/processDictionary/index.d.ts +22 -0
- package/dist/cjs/server/LocaleServerContextProvider.cjs +49 -0
- package/dist/cjs/server/LocaleServerContextProvider.cjs.map +1 -0
- package/dist/cjs/server/LocaleServerContextProvider.d.ts +34 -0
- package/dist/cjs/server/getLocaleTranslation.cjs +50 -0
- package/dist/cjs/server/getLocaleTranslation.cjs.map +1 -0
- package/dist/cjs/server/getLocaleTranslation.d.ts +11 -0
- package/dist/cjs/server/index.cjs +49 -0
- package/dist/cjs/server/index.cjs.map +1 -0
- package/dist/cjs/server/index.d.ts +13 -0
- package/dist/cjs/server/serverContext.cjs +81 -0
- package/dist/cjs/server/serverContext.cjs.map +1 -0
- package/dist/cjs/server/serverContext.d.ts +43 -0
- package/dist/cjs/server/useIntlayer.cjs +44 -0
- package/dist/cjs/server/useIntlayer.cjs.map +1 -0
- package/dist/cjs/server/useIntlayer.d.ts +7 -0
- package/dist/cjs/server/useTraduction.cjs +42 -0
- package/dist/cjs/server/useTraduction.cjs.map +1 -0
- package/dist/cjs/server/useTraduction.d.ts +7 -0
- package/dist/cjs/useIntlayerBase.cjs +56 -0
- package/dist/cjs/useIntlayerBase.cjs.map +1 -0
- package/dist/cjs/useIntlayerBase.d.ts +23 -0
- package/dist/esm/ContentEditor/ContentEditor.d.mts +8 -0
- package/dist/esm/ContentEditor/ContentEditor.mjs +82 -0
- package/dist/esm/ContentEditor/ContentEditor.mjs.map +1 -0
- package/dist/esm/ContentEditor/contentRender.d.mts +3 -0
- package/dist/esm/ContentEditor/contentRender.mjs +11 -0
- package/dist/esm/ContentEditor/contentRender.mjs.map +1 -0
- package/dist/esm/ContentEditor/index.d.mts +3 -0
- package/dist/esm/ContentEditor/index.mjs +3 -0
- package/dist/esm/ContentEditor/index.mjs.map +1 -0
- package/dist/esm/LocaleContextProvider.d.mts +10 -0
- package/dist/esm/LocaleContextProvider.mjs +15 -0
- package/dist/esm/LocaleContextProvider.mjs.map +1 -0
- package/dist/esm/client/LocaleClientContextProvider.d.mts +20 -0
- package/dist/esm/client/LocaleClientContextProvider.mjs +16 -0
- package/dist/esm/client/LocaleClientContextProvider.mjs.map +1 -0
- package/dist/esm/client/index.d.mts +19 -0
- package/dist/esm/client/index.mjs +25 -0
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/client/useContent.d.mts +12 -0
- package/dist/esm/client/useContent.mjs +13 -0
- package/dist/esm/client/useContent.mjs.map +1 -0
- package/dist/esm/client/useIntlayer.d.mts +7 -0
- package/dist/esm/client/useIntlayer.mjs +11 -0
- package/dist/esm/client/useIntlayer.mjs.map +1 -0
- package/dist/esm/client/useLocale.d.mts +10 -0
- package/dist/esm/client/useLocale.mjs +21 -0
- package/dist/esm/client/useLocale.mjs.map +1 -0
- package/dist/esm/client/useLocaleCookie.d.mts +10 -0
- package/dist/esm/client/useLocaleCookie.mjs +20 -0
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -0
- package/dist/esm/client/useTraduction.d.mts +7 -0
- package/dist/esm/client/useTraduction.mjs +9 -0
- package/dist/esm/client/useTraduction.mjs.map +1 -0
- package/dist/esm/getEnumeration.d.mts +8 -0
- package/dist/esm/getEnumeration.mjs +11 -0
- package/dist/esm/getEnumeration.mjs.map +1 -0
- package/dist/esm/getTranslation.d.mts +9 -0
- package/dist/esm/getTranslation.mjs +16 -0
- package/dist/esm/getTranslation.mjs.map +1 -0
- package/dist/esm/index.d.mts +20 -0
- package/dist/esm/index.mjs +25 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/processDictionary/contentDictionary.d.d.mts +32 -0
- package/dist/esm/processDictionary/contentDictionary.d.mjs +1 -0
- package/dist/esm/processDictionary/contentDictionary.d.mjs.map +1 -0
- package/dist/esm/processDictionary/index.d.mts +22 -0
- package/dist/esm/processDictionary/index.mjs +43 -0
- package/dist/esm/processDictionary/index.mjs.map +1 -0
- package/dist/esm/server/LocaleServerContextProvider.d.mts +34 -0
- package/dist/esm/server/LocaleServerContextProvider.mjs +14 -0
- package/dist/esm/server/LocaleServerContextProvider.mjs.map +1 -0
- package/dist/esm/server/getLocaleTranslation.d.mts +11 -0
- package/dist/esm/server/getLocaleTranslation.mjs +17 -0
- package/dist/esm/server/getLocaleTranslation.mjs.map +1 -0
- package/dist/esm/server/index.d.mts +13 -0
- package/dist/esm/server/index.mjs +17 -0
- package/dist/esm/server/index.mjs.map +1 -0
- package/dist/esm/server/serverContext.d.mts +43 -0
- package/dist/esm/server/serverContext.mjs +33 -0
- package/dist/esm/server/serverContext.mjs.map +1 -0
- package/dist/esm/server/useIntlayer.d.mts +7 -0
- package/dist/esm/server/useIntlayer.mjs +9 -0
- package/dist/esm/server/useIntlayer.mjs.map +1 -0
- package/dist/esm/server/useTraduction.d.mts +7 -0
- package/dist/esm/server/useTraduction.mjs +9 -0
- package/dist/esm/server/useTraduction.mjs.map +1 -0
- package/dist/esm/useIntlayerBase.d.mts +23 -0
- package/dist/esm/useIntlayerBase.mjs +8 -0
- package/dist/esm/useIntlayerBase.mjs.map +1 -0
- package/package.json +95 -0
- package/src/ContentEditor/ContentEditor.tsx +116 -0
- package/src/ContentEditor/contentRender.tsx +11 -0
- package/src/ContentEditor/index.tsx +2 -0
- package/src/LocaleContextProvider.tsx +26 -0
- package/src/client/LocaleClientContextProvider.tsx +35 -0
- package/src/client/index.ts +14 -0
- package/src/client/useContent.ts +17 -0
- package/src/client/useIntlayer.ts +20 -0
- package/src/client/useLocale.ts +19 -0
- package/src/client/useLocaleCookie.ts +27 -0
- package/src/client/useTraduction.ts +12 -0
- package/src/getEnumeration.ts +18 -0
- package/src/getTranslation.ts +24 -0
- package/src/index.ts +14 -0
- package/src/processDictionary/contentDictionary.d.ts +27 -0
- package/src/processDictionary/index.ts +97 -0
- package/src/server/LocaleServerContextProvider.tsx +24 -0
- package/src/server/getLocaleTranslation.ts +19 -0
- package/src/server/index.ts +8 -0
- package/src/server/serverContext.ts +85 -0
- package/src/server/useIntlayer.ts +17 -0
- package/src/server/useTraduction.ts +13 -0
- package/src/useIntlayerBase.ts +32 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) =>
|
|
23
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var useLocale_exports = {};
|
|
25
|
+
__export(useLocale_exports, {
|
|
26
|
+
useLocale: () => useLocale,
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(useLocale_exports);
|
|
29
|
+
var import_client = require("@intlayer/config/client");
|
|
30
|
+
var import_core = require("@intlayer/core");
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_LocaleClientContextProvider = require("./LocaleClientContextProvider.cjs");
|
|
33
|
+
const { defaultLocale, locales: availableLocales } =
|
|
34
|
+
import_client.intlayerIntlConfiguration;
|
|
35
|
+
const useLocale = () => {
|
|
36
|
+
const { locale } = (0, import_react.useContext)(
|
|
37
|
+
import_LocaleClientContextProvider.LocaleClientContext
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
locale,
|
|
41
|
+
// Current locale
|
|
42
|
+
defaultLocale,
|
|
43
|
+
// Principal locale defined in config
|
|
44
|
+
availableLocales,
|
|
45
|
+
// List of the available locales defined in config
|
|
46
|
+
localeList: import_core.localeList,
|
|
47
|
+
// List of all available locales
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 &&
|
|
52
|
+
(module.exports = {
|
|
53
|
+
useLocale,
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=useLocale.cjs.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":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA0C;AAC1C,kBAA2B;AAC3B,mBAA2B;AAC3B,yCAAoC;AAEpC,MAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAE9C,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,OAAO,QAAI,yBAAW,sDAAmB;AAEjD,SAAO;AAAA,IACL;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,IACA;AAAA;AAAA,EACF;AACF;","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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (
|
|
24
|
+
(target = mod != null ? __create(__getProtoOf(mod)) : {}),
|
|
25
|
+
__copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule
|
|
31
|
+
? __defProp(target, "default", { value: mod, enumerable: true })
|
|
32
|
+
: target,
|
|
33
|
+
mod
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
var __toCommonJS = (mod) =>
|
|
37
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var useLocaleCookie_exports = {};
|
|
39
|
+
__export(useLocaleCookie_exports, {
|
|
40
|
+
localeCookie: () => localeCookie,
|
|
41
|
+
setLocaleCookie: () => setLocaleCookie,
|
|
42
|
+
useLocaleCookie: () => useLocaleCookie,
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(useLocaleCookie_exports);
|
|
45
|
+
var import_client = require("@intlayer/config/client");
|
|
46
|
+
var import_js_cookie = __toESM(require("js-cookie"));
|
|
47
|
+
const { cookieName } = import_client.intlayerMiddlewareConfiguration;
|
|
48
|
+
const cookieAttributes = {
|
|
49
|
+
path: "/",
|
|
50
|
+
expires: void 0,
|
|
51
|
+
domain: void 0,
|
|
52
|
+
secure: false,
|
|
53
|
+
sameSite: "strict",
|
|
54
|
+
};
|
|
55
|
+
const localeCookie = import_js_cookie.default.get(cookieName);
|
|
56
|
+
const setLocaleCookie = (locale) => {
|
|
57
|
+
import_js_cookie.default.set(cookieName, locale, cookieAttributes);
|
|
58
|
+
};
|
|
59
|
+
const useLocaleCookie = () => ({
|
|
60
|
+
localeCookie,
|
|
61
|
+
setLocaleCookie,
|
|
62
|
+
});
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 &&
|
|
65
|
+
(module.exports = {
|
|
66
|
+
localeCookie,
|
|
67
|
+
setLocaleCookie,
|
|
68
|
+
useLocaleCookie,
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=useLocaleCookie.cjs.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAGO;AACP,uBAAoB;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,iBAAAA,QAAQ,IAAI,UAAU;AAE3C,MAAM,kBAAkB,CAAC,WAAoB;AAClD,mBAAAA,QAAQ,IAAI,YAAY,QAAQ,gBAAgB;AAClD;AAEO,MAAM,kBAAkB,OAAO;AAAA,EACpC;AAAA,EACA;AACF;","names":["Cookies"]}
|
|
@@ -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,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var useTraduction_exports = {};
|
|
24
|
+
__export(useTraduction_exports, {
|
|
25
|
+
useTraduction: () => useTraduction,
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useTraduction_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var import_getTranslation = require("../getTranslation.cjs");
|
|
30
|
+
var import_LocaleClientContextProvider = require("./LocaleClientContextProvider.cjs");
|
|
31
|
+
const useTraduction = (languageContent) => {
|
|
32
|
+
const { locale } = (0, import_react.useContext)(
|
|
33
|
+
import_LocaleClientContextProvider.LocaleClientContext
|
|
34
|
+
);
|
|
35
|
+
return (0, import_getTranslation.getTranslation)(languageContent, locale);
|
|
36
|
+
};
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 &&
|
|
39
|
+
(module.exports = {
|
|
40
|
+
useTraduction,
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=useTraduction.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA2B;AAC3B,4BAA+B;AAC/B,yCAAoC;AAE7B,MAAM,gBAAgB,CAC3B,oBACY;AACZ,QAAM,EAAE,OAAO,QAAI,yBAAW,sDAAmB;AAEjD,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var getEnumeration_exports = {};
|
|
24
|
+
__export(getEnumeration_exports, {
|
|
25
|
+
getEnumeration: () => getEnumeration,
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(getEnumeration_exports);
|
|
28
|
+
var import_core = require("@intlayer/core");
|
|
29
|
+
var import_contentRender = require("./ContentEditor/contentRender.cjs");
|
|
30
|
+
const getEnumeration = (enumerationContent, quantity) => {
|
|
31
|
+
const result = (0, import_core.getEnumerationContent)(
|
|
32
|
+
enumerationContent,
|
|
33
|
+
quantity
|
|
34
|
+
);
|
|
35
|
+
if (typeof result === "string") {
|
|
36
|
+
return (0, import_contentRender.contentRender)(result);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 &&
|
|
42
|
+
(module.exports = {
|
|
43
|
+
getEnumeration,
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=getEnumeration.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4D;AAC5D,2BAA8B;AAEvB,MAAM,iBAAiB,CAC5B,oBACA,aACY;AACZ,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA;AAAA,EACF;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,eAAO,oCAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var getTranslation_exports = {};
|
|
24
|
+
__export(getTranslation_exports, {
|
|
25
|
+
getTranslation: () => getTranslation,
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(getTranslation_exports);
|
|
28
|
+
var import_client = require("@intlayer/config/client");
|
|
29
|
+
var import_core = require("@intlayer/core");
|
|
30
|
+
var import_contentRender = require("./ContentEditor/contentRender.cjs");
|
|
31
|
+
const getTranslation = (languageContent, locale) => {
|
|
32
|
+
const { defaultLocale } = import_client.intlayerIntlConfiguration;
|
|
33
|
+
const result = (0, import_core.getTranslationContent)(
|
|
34
|
+
languageContent,
|
|
35
|
+
locale ?? defaultLocale
|
|
36
|
+
);
|
|
37
|
+
if (typeof result === "string") {
|
|
38
|
+
return (0, import_contentRender.contentRender)(result);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 &&
|
|
44
|
+
(module.exports = {
|
|
45
|
+
getTranslation,
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=getTranslation.cjs.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;AAAA;AAAA;AAAA;AAAA,oBAGO;AACP,kBAA4D;AAC5D,2BAA8B;AAEvB,MAAM,iBAAiB,CAC5B,iBACA,WACY;AACZ,QAAM,EAAE,cAAc,IAAI;AAE1B,QAAM,aAAkB;AAAA,IACtB;AAAA,IACA,UAAU;AAAA,EACZ;AAEA,MAAI,OAAO,WAAW,UAAU;AAC9B,eAAO,oCAAc,MAAM;AAAA,EAC7B;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var src_exports = {};
|
|
24
|
+
__export(src_exports, {
|
|
25
|
+
LocaleClientContext: () => import_client.LocaleClientContext,
|
|
26
|
+
LocaleClientContextProvider: () => import_client.LocaleClientContextProvider,
|
|
27
|
+
getTranslation: () => import_getTranslation.getTranslation,
|
|
28
|
+
localeCookie: () => import_client.localeCookie,
|
|
29
|
+
setLocaleCookie: () => import_client.setLocaleCookie,
|
|
30
|
+
useIntlayer: () => import_client.useIntlayer,
|
|
31
|
+
useLocale: () => import_client.useLocale,
|
|
32
|
+
useLocaleContext: () => import_client.useLocaleContext,
|
|
33
|
+
useLocaleCookie: () => import_client.useLocaleCookie,
|
|
34
|
+
useTraduction: () => import_client.useTraduction,
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
37
|
+
var import_getTranslation = require("./getTranslation.cjs");
|
|
38
|
+
var import_client = require("./client/index.cjs");
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 &&
|
|
41
|
+
(module.exports = {
|
|
42
|
+
LocaleClientContext,
|
|
43
|
+
LocaleClientContextProvider,
|
|
44
|
+
getTranslation,
|
|
45
|
+
localeCookie,
|
|
46
|
+
setLocaleCookie,
|
|
47
|
+
useIntlayer,
|
|
48
|
+
useLocale,
|
|
49
|
+
useLocaleContext,
|
|
50
|
+
useLocaleCookie,
|
|
51
|
+
useTraduction,
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=index.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA+B;AAC/B,oBAWO;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { getTranslation } from "./getTranslation.js";
|
|
2
|
+
export {
|
|
3
|
+
LocaleClientContext,
|
|
4
|
+
LocaleClientContextProvider,
|
|
5
|
+
LocaleClientContextProviderProps,
|
|
6
|
+
useLocaleContext,
|
|
7
|
+
} from "./client/LocaleClientContextProvider.js";
|
|
8
|
+
export { useIntlayer } from "./client/useIntlayer.js";
|
|
9
|
+
export { useLocale } from "./client/useLocale.js";
|
|
10
|
+
export { useTraduction } from "./client/useTraduction.js";
|
|
11
|
+
export {
|
|
12
|
+
localeCookie,
|
|
13
|
+
setLocaleCookie,
|
|
14
|
+
useLocaleCookie,
|
|
15
|
+
} from "./client/useLocaleCookie.js";
|
|
16
|
+
import "@intlayer/config/client";
|
|
17
|
+
import "@intlayer/core";
|
|
18
|
+
import "react";
|
|
19
|
+
import "./useIntlayerBase.js";
|
|
20
|
+
import "intlayer";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) =>
|
|
18
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var contentDictionary_d_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(contentDictionary_d_exports);
|
|
21
|
+
//# sourceMappingURL=contentDictionary.d.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/processDictionary/contentDictionary.d.ts"],"sourcesContent":["import { type TranslationContent } from '@intlayer/core';\n\nexport type ContentValue =\n | string\n | {\n [key: string]: ContentValue;\n }\n | TranslationContent<unknown>;\n\nexport type Content = Record<string, ContentValue | undefined>;\n\nexport type TransformedContentValue =\n | string\n | {\n [key: string]: TransformedContentValue;\n }\n | undefined\n | ((quantity: number) => TransformedContentValue);\n\nexport type TransformedContent = Record<\n string,\n TransformedContentValue | undefined\n>;\n\nexport type ContentDictionary = Content & {\n id: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","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,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var processDictionary_exports = {};
|
|
24
|
+
__export(processDictionary_exports, {
|
|
25
|
+
processDictionary: () => processDictionary,
|
|
26
|
+
processNode: () => processNode,
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(processDictionary_exports);
|
|
29
|
+
var import_client = require("@intlayer/config/client");
|
|
30
|
+
var import_core = require("@intlayer/core");
|
|
31
|
+
var import_getEnumeration = require("../getEnumeration.cjs");
|
|
32
|
+
var import_getTranslation = require("../getTranslation.cjs");
|
|
33
|
+
const defaultLocale = import_client.intlayerIntlConfiguration.defaultLocale;
|
|
34
|
+
const processTranslation = (languageContent, locale) => {
|
|
35
|
+
const translationResult = (0, import_getTranslation.getTranslation)(
|
|
36
|
+
languageContent,
|
|
37
|
+
locale
|
|
38
|
+
);
|
|
39
|
+
return processDictionary(translationResult, locale);
|
|
40
|
+
};
|
|
41
|
+
const processEnumeration = (enumerationContent, locale) => {
|
|
42
|
+
return (quantity) => {
|
|
43
|
+
const enumerationResult = (0, import_getEnumeration.getEnumeration)(
|
|
44
|
+
enumerationContent,
|
|
45
|
+
quantity
|
|
46
|
+
);
|
|
47
|
+
return processDictionary(enumerationResult, locale);
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const processNode = (field, locale) => {
|
|
51
|
+
if (typeof field !== "object" || field === null) {
|
|
52
|
+
return field;
|
|
53
|
+
}
|
|
54
|
+
if (field.nodeType === import_core.NodeType.Translation) {
|
|
55
|
+
return processTranslation(field, locale);
|
|
56
|
+
}
|
|
57
|
+
if (field.nodeType === import_core.NodeType.Enumeration) {
|
|
58
|
+
return processEnumeration(field, locale);
|
|
59
|
+
}
|
|
60
|
+
if (typeof field.type === "undefined") {
|
|
61
|
+
return processDictionary(field, locale);
|
|
62
|
+
}
|
|
63
|
+
return field;
|
|
64
|
+
};
|
|
65
|
+
const processDictionary = (content, locale = defaultLocale) => {
|
|
66
|
+
if (content && typeof content === "object") {
|
|
67
|
+
const result = {};
|
|
68
|
+
for (const key of Object.keys(content)) {
|
|
69
|
+
const field = content[key];
|
|
70
|
+
result[key] = processNode(field, locale);
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
return content;
|
|
75
|
+
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 &&
|
|
78
|
+
(module.exports = {
|
|
79
|
+
processDictionary,
|
|
80
|
+
processNode,
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=index.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAGO;AACP,kBAIO;AACP,4BAA+B;AAC/B,4BAA+B;AAQ/B,MAAM,gBAAgB,wCAA0B;AAEhD,MAAM,qBAAqB,CACzB,iBACA,WACuB;AACvB,QAAM,wBAAkC;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,wBAAkC;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,qBAAS,aAAa;AAC3C,WAAO,mBAAmB,OAAwC,MAAM;AAAA,EAC1E;AAEA,MAAI,MAAM,aAAa,qBAAS,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,22 @@
|
|
|
1
|
+
import { Locales } from "@intlayer/config/client";
|
|
2
|
+
import {
|
|
3
|
+
ContentValue,
|
|
4
|
+
TransformedContentValue,
|
|
5
|
+
Content,
|
|
6
|
+
TransformedContent,
|
|
7
|
+
} from "./contentDictionary.d.js";
|
|
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,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var LocaleServerContextProvider_exports = {};
|
|
24
|
+
__export(LocaleServerContextProvider_exports, {
|
|
25
|
+
LocaleServerContext: () => LocaleServerContext,
|
|
26
|
+
LocaleServerContextProvider: () => LocaleServerContextProvider,
|
|
27
|
+
locale: () => locale,
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(LocaleServerContextProvider_exports);
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
var import_client = require("@intlayer/config/client");
|
|
32
|
+
var import_serverContext = require("./serverContext.cjs");
|
|
33
|
+
const LocaleServerContext = (0, import_serverContext.createServerContext)(
|
|
34
|
+
import_client.intlayerIntlConfiguration.defaultLocale
|
|
35
|
+
);
|
|
36
|
+
const locale = (0, import_serverContext.getServerContext)(LocaleServerContext);
|
|
37
|
+
const LocaleServerContextProvider = ({ children, locale: locale2 }) =>
|
|
38
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LocaleServerContext.Provider, {
|
|
39
|
+
value: locale2,
|
|
40
|
+
children,
|
|
41
|
+
});
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 &&
|
|
44
|
+
(module.exports = {
|
|
45
|
+
LocaleServerContext,
|
|
46
|
+
LocaleServerContextProvider,
|
|
47
|
+
locale,
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=LocaleServerContextProvider.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBE;AApBF,oBAGO;AAEP,2BAAsD;AAE/C,MAAM,0BAAsB;AAAA,EACjC,wCAA0B;AAC5B;AAEO,MAAM,aAAS,uCAAiB,mBAAmB;AAMnD,MAAM,8BAET,CAAC,EAAE,UAAU,QAAAA,QAAO,MACtB,4CAAC,oBAAoB,UAApB,EAA6B,OAAOA,SAClC,UACH;","names":["locale"]}
|