react-intlayer 1.0.0 → 1.2.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/dist/cjs/ContentEditor/ContentEditor.cjs +36 -39
- package/dist/cjs/ContentEditor/ContentEditor.d.ts +2 -2
- package/dist/cjs/ContentEditor/contentRender.cjs +10 -18
- package/dist/cjs/ContentEditor/index.cjs +11 -27
- package/dist/cjs/ContentEditor/index.d.ts +3 -3
- package/dist/cjs/IntlayerProvider.cjs +37 -0
- package/dist/cjs/IntlayerProvider.cjs.map +1 -0
- package/dist/cjs/IntlayerProvider.d.ts +9 -0
- package/dist/cjs/client/IntlayerClientProvider.cjs +45 -0
- package/dist/cjs/client/IntlayerClientProvider.cjs.map +1 -0
- package/dist/cjs/client/IntlayerClientProvider.d.ts +24 -0
- package/dist/cjs/client/index.cjs +24 -31
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/index.d.ts +10 -19
- package/dist/cjs/client/useContent.cjs +11 -16
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useContent.d.ts +10 -8
- package/dist/cjs/client/useIntlayer.cjs +11 -18
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.d.ts +8 -3
- package/dist/cjs/client/useLocale.cjs +12 -20
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocale.d.ts +8 -5
- package/dist/cjs/client/useLocaleCookie.cjs +20 -30
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
- package/dist/cjs/client/useLocaleCookie.d.ts +12 -3
- package/dist/cjs/client/useTraduction.cjs +11 -18
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.d.ts +22 -4
- package/dist/cjs/getEnumeration.cjs +9 -14
- package/dist/cjs/getEnumeration.cjs.map +1 -1
- package/dist/cjs/getEnumeration.d.ts +27 -5
- package/dist/cjs/getTranslation.cjs +9 -14
- package/dist/cjs/getTranslation.cjs.map +1 -1
- package/dist/cjs/getTranslation.d.ts +23 -6
- package/dist/cjs/index.cjs +20 -27
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +11 -20
- package/dist/cjs/processDictionary/contentDictionary.d.cjs +4 -8
- package/dist/cjs/processDictionary/contentDictionary.d.d.ts +6 -9
- package/dist/cjs/processDictionary/index.cjs +15 -17
- package/dist/cjs/processDictionary/index.cjs.map +1 -1
- package/dist/cjs/processDictionary/index.d.ts +6 -17
- package/dist/cjs/server/IntlayerServerProvider.cjs +46 -0
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -0
- package/dist/cjs/server/IntlayerServerProvider.d.ts +37 -0
- package/dist/cjs/server/getLocaleTranslation.cjs +12 -19
- package/dist/cjs/server/getLocaleTranslation.cjs.map +1 -1
- package/dist/cjs/server/getLocaleTranslation.d.ts +8 -7
- package/dist/cjs/server/index.cjs +20 -27
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.ts +9 -13
- package/dist/cjs/server/serverContext.cjs +25 -31
- package/dist/cjs/server/serverContext.cjs.map +1 -1
- package/dist/cjs/server/serverContext.d.ts +16 -24
- package/dist/cjs/server/useIntlayer.cjs +12 -21
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.d.ts +8 -3
- package/dist/cjs/server/useTraduction.cjs +12 -19
- package/dist/cjs/server/useTraduction.cjs.map +1 -1
- package/dist/cjs/server/useTraduction.d.ts +22 -4
- package/dist/cjs/useIntlayerBase.cjs +22 -31
- package/dist/cjs/useIntlayerBase.cjs.map +1 -1
- package/dist/cjs/useIntlayerBase.d.ts +7 -18
- package/dist/esm/ContentEditor/ContentEditor.d.mts +2 -2
- package/dist/esm/ContentEditor/ContentEditor.mjs +38 -29
- package/dist/esm/ContentEditor/contentRender.mjs +5 -3
- package/dist/esm/ContentEditor/index.d.mts +3 -3
- package/dist/esm/ContentEditor/index.mjs +3 -3
- package/dist/esm/IntlayerProvider.d.mts +9 -0
- package/dist/esm/IntlayerProvider.mjs +17 -0
- package/dist/esm/IntlayerProvider.mjs.map +1 -0
- package/dist/esm/client/IntlayerClientProvider.d.mts +24 -0
- package/dist/esm/client/IntlayerClientProvider.mjs +24 -0
- package/dist/esm/client/IntlayerClientProvider.mjs.map +1 -0
- package/dist/esm/client/index.d.mts +10 -19
- package/dist/esm/client/index.mjs +14 -14
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/useContent.d.mts +10 -8
- package/dist/esm/client/useContent.mjs +7 -5
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.d.mts +8 -3
- package/dist/esm/client/useIntlayer.mjs +9 -5
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.d.mts +8 -5
- package/dist/esm/client/useLocale.mjs +7 -5
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleCookie.d.mts +12 -3
- package/dist/esm/client/useLocaleCookie.mjs +11 -5
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
- package/dist/esm/client/useTraduction.d.mts +22 -4
- package/dist/esm/client/useTraduction.mjs +7 -5
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/getEnumeration.d.mts +27 -5
- package/dist/esm/getEnumeration.mjs +9 -4
- package/dist/esm/getEnumeration.mjs.map +1 -1
- package/dist/esm/getTranslation.d.mts +23 -6
- package/dist/esm/getTranslation.mjs +8 -4
- package/dist/esm/getTranslation.mjs.map +1 -1
- package/dist/esm/index.d.mts +11 -20
- package/dist/esm/index.mjs +9 -11
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/processDictionary/contentDictionary.d.d.mts +6 -9
- package/dist/esm/processDictionary/contentDictionary.d.mjs +1 -1
- package/dist/esm/processDictionary/index.d.mts +6 -17
- package/dist/esm/processDictionary/index.mjs +25 -9
- package/dist/esm/processDictionary/index.mjs.map +1 -1
- package/dist/esm/server/IntlayerServerProvider.d.mts +37 -0
- package/dist/esm/server/IntlayerServerProvider.mjs +21 -0
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -0
- package/dist/esm/server/getLocaleTranslation.d.mts +8 -7
- package/dist/esm/server/getLocaleTranslation.mjs +8 -6
- package/dist/esm/server/getLocaleTranslation.mjs.map +1 -1
- package/dist/esm/server/index.d.mts +9 -13
- package/dist/esm/server/index.mjs +10 -10
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/serverContext.d.mts +16 -24
- package/dist/esm/server/serverContext.mjs +13 -6
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.d.mts +8 -3
- package/dist/esm/server/useIntlayer.mjs +10 -6
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/esm/server/useTraduction.d.mts +22 -4
- package/dist/esm/server/useTraduction.mjs +8 -6
- package/dist/esm/server/useTraduction.mjs.map +1 -1
- package/dist/esm/useIntlayerBase.d.mts +7 -18
- package/dist/esm/useIntlayerBase.mjs +9 -4
- package/dist/esm/useIntlayerBase.mjs.map +1 -1
- package/package.json +10 -10
- package/src/IntlayerProvider.tsx +24 -0
- package/src/client/IntlayerClientProvider.tsx +45 -0
- package/src/client/index.ts +5 -5
- package/src/client/useContent.ts +3 -0
- package/src/client/useIntlayer.ts +7 -2
- package/src/client/useLocale.ts +5 -2
- package/src/client/useLocaleCookie.ts +9 -1
- package/src/client/useTraduction.ts +23 -3
- package/src/getEnumeration.ts +25 -0
- package/src/getTranslation.ts +21 -1
- package/src/index.ts +3 -4
- package/src/processDictionary/index.ts +1 -1
- package/src/server/IntlayerServerProvider.tsx +39 -0
- package/src/server/getLocaleTranslation.ts +5 -2
- package/src/server/index.ts +3 -3
- package/src/server/serverContext.ts +4 -4
- package/src/server/useIntlayer.ts +8 -2
- package/src/server/useTraduction.ts +23 -3
- package/src/useIntlayerBase.ts +4 -1
- package/dist/cjs/LocaleContextProvider.cjs +0 -49
- package/dist/cjs/LocaleContextProvider.cjs.map +0 -1
- package/dist/cjs/LocaleContextProvider.d.ts +0 -10
- package/dist/cjs/client/LocaleClientContextProvider.cjs +0 -54
- package/dist/cjs/client/LocaleClientContextProvider.cjs.map +0 -1
- package/dist/cjs/client/LocaleClientContextProvider.d.ts +0 -20
- package/dist/cjs/server/LocaleServerContextProvider.cjs +0 -49
- package/dist/cjs/server/LocaleServerContextProvider.cjs.map +0 -1
- package/dist/cjs/server/LocaleServerContextProvider.d.ts +0 -34
- package/dist/esm/LocaleContextProvider.d.mts +0 -10
- package/dist/esm/LocaleContextProvider.mjs +0 -15
- package/dist/esm/LocaleContextProvider.mjs.map +0 -1
- package/dist/esm/client/LocaleClientContextProvider.d.mts +0 -20
- package/dist/esm/client/LocaleClientContextProvider.mjs +0 -16
- package/dist/esm/client/LocaleClientContextProvider.mjs.map +0 -1
- package/dist/esm/server/LocaleServerContextProvider.d.mts +0 -34
- package/dist/esm/server/LocaleServerContextProvider.mjs +0 -14
- package/dist/esm/server/LocaleServerContextProvider.mjs.map +0 -1
- package/src/LocaleContextProvider.tsx +0 -26
- package/src/client/LocaleClientContextProvider.tsx +0 -35
- package/src/server/LocaleServerContextProvider.tsx +0 -24
|
@@ -8,35 +8,28 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
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
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var useTraduction_exports = {};
|
|
24
20
|
__export(useTraduction_exports, {
|
|
25
|
-
useTraduction: () => useTraduction
|
|
21
|
+
useTraduction: () => useTraduction
|
|
26
22
|
});
|
|
27
23
|
module.exports = __toCommonJS(useTraduction_exports);
|
|
28
|
-
var import_getTranslation = require(
|
|
29
|
-
var
|
|
30
|
-
var import_serverContext = require(
|
|
24
|
+
var import_getTranslation = require('../getTranslation.cjs');
|
|
25
|
+
var import_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
26
|
+
var import_serverContext = require('./serverContext.cjs');
|
|
31
27
|
const useTraduction = (languageContent) => {
|
|
32
|
-
const locale = (0, import_serverContext.getServerContext)(
|
|
33
|
-
import_LocaleServerContextProvider.LocaleServerContext
|
|
34
|
-
);
|
|
28
|
+
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
35
29
|
return (0, import_getTranslation.getTranslation)(languageContent, locale);
|
|
36
30
|
};
|
|
37
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 &&
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=useTraduction.cjs.map
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
useTraduction
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=useTraduction.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/useTraduction.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\nimport type { LanguageContent } from '@intlayer/core';\nimport { getTranslation } from '../getTranslation';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, hook to get the translation content based on the locale\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * const content = getTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * },\n * 'fr');\n * // 'Bonjour'\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext<Locales>(IntlayerServerContext);\n\n return getTranslation(languageContent, locale);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,4BAA+B;AAC/B,oCAAsC;AACtC,2BAAiC;AAsB1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,aAAS,uCAA0B,mDAAqB;AAE9D,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { LanguageContent } from
|
|
1
|
+
import { LanguageContent } from '@intlayer/core';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* On the server side, hook to get the translation content based on the locale
|
|
5
|
+
*
|
|
6
|
+
* If not locale found, it will return the content related to the default locale.
|
|
7
|
+
*
|
|
8
|
+
* Return either the content editor, or the content itself depending on the configuration.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
*
|
|
12
|
+
* const content = getTranslation<string>({
|
|
13
|
+
* en: 'Hello',
|
|
14
|
+
* fr: 'Bonjour',
|
|
15
|
+
* },
|
|
16
|
+
* 'fr');
|
|
17
|
+
* // 'Bonjour'
|
|
18
|
+
*
|
|
19
|
+
* Using TypeScript:
|
|
20
|
+
* - this function will require each locale to be defined if defined in the project configuration.
|
|
21
|
+
* - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
|
|
22
|
+
*/
|
|
23
|
+
declare const useTraduction: <Content = string>(languageContent: LanguageContent<Content>) => Content;
|
|
6
24
|
|
|
7
25
|
export { useTraduction };
|
|
@@ -10,47 +10,38 @@ var __export = (target, all) => {
|
|
|
10
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
14
|
for (let key of __getOwnPropNames(from))
|
|
15
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
|
-
});
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
17
|
}
|
|
21
18
|
return to;
|
|
22
19
|
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
: target,
|
|
33
|
-
mod
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
var __toCommonJS = (mod) =>
|
|
37
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
29
|
var useIntlayerBase_exports = {};
|
|
39
30
|
__export(useIntlayerBase_exports, {
|
|
40
|
-
useIntlayerBase: () => useIntlayerBase
|
|
31
|
+
useIntlayerBase: () => useIntlayerBase
|
|
41
32
|
});
|
|
42
33
|
module.exports = __toCommonJS(useIntlayerBase_exports);
|
|
43
|
-
var import_dictionaries_entry = __toESM(
|
|
44
|
-
|
|
45
|
-
);
|
|
46
|
-
var import_processDictionary = require("./processDictionary/index.cjs");
|
|
34
|
+
var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
|
|
35
|
+
var import_processDictionary = require('./processDictionary/index.cjs');
|
|
47
36
|
const useIntlayerBase = (id, locale) => {
|
|
48
37
|
const dictionary = import_dictionaries_entry.default[id];
|
|
49
|
-
return (0, import_processDictionary.processDictionary)(
|
|
38
|
+
return (0, import_processDictionary.processDictionary)(
|
|
39
|
+
dictionary,
|
|
40
|
+
locale
|
|
41
|
+
);
|
|
50
42
|
};
|
|
51
43
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
-
0 &&
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=useIntlayerBase.cjs.map
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
useIntlayerBase
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=useIntlayerBase.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/useIntlayerBase.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config/client';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { Content } from './processDictionary/contentDictionary';\nimport { processDictionary } from './processDictionary/index';\n\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\nexport type UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => IntlayerDictionaryTypesConnector[T];\n\n/**\n * Hook that picking one dictionary by its id and return the content.\n */\nexport const useIntlayerBase: UseIntlayer = <T extends DictionaryKeys>(\n id: T,\n locale?: Locales\n) => {\n const dictionary: Content = dictionaries[id];\n\n return processDictionary(\n dictionary,\n locale\n ) as IntlayerDictionaryTypesConnector[T];\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,gCAAyB;AAGzB,+BAAkC;AAe3B,MAAM,kBAA+B,CAC1C,IACA,WACG;AACH,QAAM,aAAsB,0BAAAA,QAAa,EAAE;AAE3C,aAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":["dictionaries"]}
|
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
import { Locales } from
|
|
2
|
-
import { IntlayerDictionaryTypesConnector } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.
|
|
6
|
-
* Using an external package allow to alias it in the bundle configuration (such as webpack).
|
|
7
|
-
* The alias allow hot reload the app (such as nextjs) on any dictionary change.
|
|
8
|
-
*/
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
import { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
9
3
|
|
|
10
4
|
type StringFallback<T> = T extends never ? string : T;
|
|
11
5
|
type DictionaryKeys = StringFallback<keyof IntlayerDictionaryTypesConnector>;
|
|
12
|
-
type UseIntlayer = <T extends DictionaryKeys>(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
type UseIntlayer = <T extends DictionaryKeys>(id: T, locale?: Locales) => IntlayerDictionaryTypesConnector[T];
|
|
7
|
+
/**
|
|
8
|
+
* Hook that picking one dictionary by its id and return the content.
|
|
9
|
+
*/
|
|
16
10
|
declare const useIntlayerBase: UseIntlayer;
|
|
17
11
|
|
|
18
|
-
export {
|
|
19
|
-
type DictionaryKeys,
|
|
20
|
-
type StringFallback,
|
|
21
|
-
type UseIntlayer,
|
|
22
|
-
useIntlayerBase,
|
|
23
|
-
};
|
|
12
|
+
export { type DictionaryKeys, type StringFallback, type UseIntlayer, useIntlayerBase };
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useState,
|
|
6
|
+
useRef,
|
|
7
|
+
useCallback
|
|
8
|
+
} from "react";
|
|
4
9
|
const PRESS_DETECT_DURATION = 500;
|
|
5
10
|
const ContentEditor = ({ children }) => {
|
|
6
11
|
const divRef = useRef(null);
|
|
@@ -51,32 +56,36 @@ const ContentEditor = ({ children }) => {
|
|
|
51
56
|
const handleOnBlur = () => {
|
|
52
57
|
setIsEditing(false);
|
|
53
58
|
};
|
|
54
|
-
const onContentChange = (_e) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
const onContentChange = (_e) => {
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
role: "textbox",
|
|
65
|
+
tabIndex: 0,
|
|
66
|
+
onKeyUp: () => null,
|
|
67
|
+
contentEditable: isEditing,
|
|
68
|
+
onInput: onContentChange,
|
|
69
|
+
onClick: handleOnClick,
|
|
70
|
+
onMouseDown: handleMouseDown,
|
|
71
|
+
onMouseUp: handleMouseUp,
|
|
72
|
+
onMouseLeave: handleMouseUp,
|
|
73
|
+
onTouchStart: handleMouseDown,
|
|
74
|
+
onTouchEnd: handleMouseUp,
|
|
75
|
+
onTouchCancel: handleMouseUp,
|
|
76
|
+
onBlur: handleOnBlur,
|
|
77
|
+
suppressContentEditableWarning: true,
|
|
78
|
+
style: isEditing ? {
|
|
79
|
+
backgroundColor: "transparent",
|
|
80
|
+
cursor: "text",
|
|
81
|
+
display: "inline"
|
|
82
|
+
} : { cursor: "pointer", display: "inline" },
|
|
83
|
+
ref: divRef,
|
|
84
|
+
children
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
export {
|
|
89
|
+
ContentEditor
|
|
80
90
|
};
|
|
81
|
-
|
|
82
|
-
//# sourceMappingURL=ContentEditor.mjs.map
|
|
91
|
+
//# sourceMappingURL=ContentEditor.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ContentEditor } from
|
|
2
|
+
import { ContentEditor } from './ContentEditor.mjs';
|
|
3
3
|
const contentRender = (content) => {
|
|
4
4
|
const isEditable = process.env.NODE_ENV === "development";
|
|
5
5
|
if (isEditable && ContentEditor) {
|
|
@@ -7,5 +7,7 @@ const contentRender = (content) => {
|
|
|
7
7
|
}
|
|
8
8
|
return content;
|
|
9
9
|
};
|
|
10
|
-
export {
|
|
11
|
-
|
|
10
|
+
export {
|
|
11
|
+
contentRender
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=contentRender.mjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { ContentEditor } from
|
|
2
|
-
export { contentRender } from
|
|
3
|
-
import
|
|
1
|
+
export { ContentEditor } from './ContentEditor.mjs';
|
|
2
|
+
export { contentRender } from './contentRender.mjs';
|
|
3
|
+
import 'react';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from './ContentEditor.mjs';
|
|
2
|
+
export * from './contentRender.mjs';
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IntlayerClientProviderProps } from './client/IntlayerClientProvider.mjs';
|
|
3
|
+
import { IntlayerServerProviderProps } from './server/IntlayerServerProvider.mjs';
|
|
4
|
+
import '@intlayer/config/client';
|
|
5
|
+
|
|
6
|
+
type IntlayerProviderProps = IntlayerClientProviderProps & IntlayerServerProviderProps;
|
|
7
|
+
declare const IntlayerProvider: FC<IntlayerProviderProps>;
|
|
8
|
+
|
|
9
|
+
export { IntlayerProvider };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { intlayerIntlConfiguration } from "@intlayer/config/client";
|
|
3
|
+
import {
|
|
4
|
+
IntlayerClientProvider
|
|
5
|
+
} from './client/IntlayerClientProvider.mjs';
|
|
6
|
+
import {
|
|
7
|
+
IntlayerServerProvider
|
|
8
|
+
} from './server/IntlayerServerProvider.mjs';
|
|
9
|
+
const defaultLocale = intlayerIntlConfiguration.defaultLocale;
|
|
10
|
+
const IntlayerProvider = ({
|
|
11
|
+
children,
|
|
12
|
+
locale = defaultLocale
|
|
13
|
+
}) => /* @__PURE__ */ jsx(IntlayerServerProvider, { locale, children: /* @__PURE__ */ jsx(IntlayerClientProvider, { locale, children }) });
|
|
14
|
+
export {
|
|
15
|
+
IntlayerProvider
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=IntlayerProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/IntlayerProvider.tsx"],"sourcesContent":["import { intlayerIntlConfiguration } from '@intlayer/config/client';\nimport type { FC } from 'react';\nimport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/IntlayerClientProvider';\nimport {\n IntlayerServerProvider,\n type IntlayerServerProviderProps,\n} from './server/IntlayerServerProvider';\n\nconst defaultLocale = intlayerIntlConfiguration.defaultLocale;\n\ntype IntlayerProviderProps = IntlayerClientProviderProps &\n IntlayerServerProviderProps;\n\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n locale = defaultLocale,\n}) => (\n <IntlayerServerProvider locale={locale}>\n <IntlayerClientProvider locale={locale}>{children}</IntlayerClientProvider>\n </IntlayerServerProvider>\n);\n"],"mappings":"AAqBI;AArBJ,SAAS,iCAAiC;AAE1C;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAEK;AAEP,MAAM,gBAAgB,0BAA0B;AAKzC,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA,SAAS;AACX,MACE,oBAAC,0BAAuB,QACtB,8BAAC,0BAAuB,QAAiB,UAAS,GACpD;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PropsWithChildren, FC } from 'react';
|
|
3
|
+
import { Locales } from '@intlayer/config/client';
|
|
4
|
+
|
|
5
|
+
type IntlayerValue = {
|
|
6
|
+
locale: Locales;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Context that store the current locale on the client side
|
|
10
|
+
*/
|
|
11
|
+
declare const IntlayerClientContext: react.Context<IntlayerValue>;
|
|
12
|
+
/**
|
|
13
|
+
* Hook that provides the current locale
|
|
14
|
+
*/
|
|
15
|
+
declare const useIntlayerContext: () => IntlayerValue;
|
|
16
|
+
type IntlayerClientProviderProps = PropsWithChildren & {
|
|
17
|
+
locale: Locales;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Provider that store the current locale on the client side
|
|
21
|
+
*/
|
|
22
|
+
declare const IntlayerClientProvider: FC<IntlayerClientProviderProps>;
|
|
23
|
+
|
|
24
|
+
export { IntlayerClientContext, IntlayerClientProvider, type IntlayerClientProviderProps, useIntlayerContext };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
intlayerIntlConfiguration
|
|
5
|
+
} from "@intlayer/config/client";
|
|
6
|
+
import {
|
|
7
|
+
createContext,
|
|
8
|
+
useContext
|
|
9
|
+
} from "react";
|
|
10
|
+
import { localeCookie } from './useLocaleCookie.mjs';
|
|
11
|
+
const IntlayerClientContext = createContext({
|
|
12
|
+
locale: localeCookie ?? intlayerIntlConfiguration.defaultLocale
|
|
13
|
+
});
|
|
14
|
+
const useIntlayerContext = () => useContext(IntlayerClientContext);
|
|
15
|
+
const IntlayerClientProvider = ({
|
|
16
|
+
locale,
|
|
17
|
+
children
|
|
18
|
+
}) => /* @__PURE__ */ jsx(IntlayerClientContext.Provider, { value: { locale }, children });
|
|
19
|
+
export {
|
|
20
|
+
IntlayerClientContext,
|
|
21
|
+
IntlayerClientProvider,
|
|
22
|
+
useIntlayerContext
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=IntlayerClientProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n intlayerIntlConfiguration,\n type Locales,\n} from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n type FC,\n} from 'react';\nimport { localeCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? intlayerIntlConfiguration.defaultLocale,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerClientProviderProps = PropsWithChildren & {\n locale: Locales;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerClientProvider: FC<IntlayerClientProviderProps> = ({\n locale,\n children,\n}) => (\n <IntlayerClientContext.Provider value={{ locale }}>\n {children}\n </IntlayerClientContext.Provider>\n);\n"],"mappings":";AAyCE;AAvCF;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB;AAStB,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,0BAA0B;AACpD,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AASjE,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AACF,MACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,EAAE,OAAO,GAC7C,UACH;","names":[]}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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";
|
|
1
|
+
export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps, useIntlayerContext } from './IntlayerClientProvider.mjs';
|
|
2
|
+
export { useIntlayer } from './useIntlayer.mjs';
|
|
3
|
+
export { useLocale } from './useLocale.mjs';
|
|
4
|
+
export { useTraduction } from './useTraduction.mjs';
|
|
5
|
+
export { localeCookie, setLocaleCookie, useLocaleCookie } from './useLocaleCookie.mjs';
|
|
6
|
+
import 'react';
|
|
7
|
+
import '@intlayer/config/client';
|
|
8
|
+
import '../useIntlayerBase.mjs';
|
|
9
|
+
import 'intlayer';
|
|
10
|
+
import '@intlayer/core';
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from
|
|
6
|
-
import { useIntlayer } from
|
|
7
|
-
import { useLocale } from
|
|
8
|
-
import { useTraduction } from
|
|
2
|
+
IntlayerClientContext,
|
|
3
|
+
useIntlayerContext,
|
|
4
|
+
IntlayerClientProvider
|
|
5
|
+
} from './IntlayerClientProvider.mjs';
|
|
6
|
+
import { useIntlayer } from './useIntlayer.mjs';
|
|
7
|
+
import { useLocale } from './useLocale.mjs';
|
|
8
|
+
import { useTraduction } from './useTraduction.mjs';
|
|
9
9
|
import {
|
|
10
10
|
useLocaleCookie,
|
|
11
11
|
localeCookie,
|
|
12
|
-
setLocaleCookie
|
|
13
|
-
} from
|
|
12
|
+
setLocaleCookie
|
|
13
|
+
} from './useLocaleCookie.mjs';
|
|
14
14
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
IntlayerClientContext as IntlayerClient,
|
|
16
|
+
IntlayerClientProvider,
|
|
17
17
|
localeCookie,
|
|
18
18
|
setLocaleCookie,
|
|
19
19
|
useIntlayer,
|
|
20
|
+
useIntlayerContext,
|
|
20
21
|
useLocale,
|
|
21
|
-
useLocaleContext,
|
|
22
22
|
useLocaleCookie,
|
|
23
|
-
useTraduction
|
|
23
|
+
useTraduction
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=index.mjs.map
|
|
25
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export type {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export type { IntlayerClientProviderProps } from './IntlayerClientProvider';\nexport {\n IntlayerClientContext as IntlayerClient,\n useIntlayerContext,\n IntlayerClientProvider,\n} from './IntlayerClientProvider';\nexport { useIntlayer } from './useIntlayer';\nexport { useLocale } from './useLocale';\nexport { useTraduction } from './useTraduction';\nexport {\n useLocaleCookie,\n localeCookie,\n setLocaleCookie,\n} from './useLocaleCookie';\n"],"mappings":"AACA;AAAA,EAC2B;AAAA,EACzB;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as _intlayer_config_client from '@intlayer/config/client';
|
|
2
|
+
import * as intlayer from 'intlayer';
|
|
3
|
+
import { LanguageContent } from '@intlayer/core';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* On the client side, hook to get the translation content based on the locale
|
|
7
|
+
*/
|
|
8
|
+
declare const useContent: <Content>(languageContent: LanguageContent<Content>) => {
|
|
9
|
+
locale: intlayer.Locales;
|
|
10
|
+
content: Content;
|
|
11
|
+
t: <Content_1 = string>(languageContent: Partial<Record<_intlayer_config_client.LocalesValues, Content_1>>) => Content_1;
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export { useContent };
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { useLocale } from
|
|
2
|
-
import { useTraduction } from
|
|
1
|
+
import { useLocale } from './useLocale.mjs';
|
|
2
|
+
import { useTraduction } from './useTraduction.mjs';
|
|
3
3
|
const useContent = (languageContent) => {
|
|
4
4
|
const { locale } = useLocale();
|
|
5
5
|
const content = useTraduction(languageContent);
|
|
6
6
|
return {
|
|
7
7
|
locale,
|
|
8
8
|
content,
|
|
9
|
-
t: useTraduction
|
|
9
|
+
t: useTraduction
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export {
|
|
13
|
-
|
|
12
|
+
export {
|
|
13
|
+
useContent
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useLocale } from './useLocale';\nimport { useTraduction } from './useTraduction';\n\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;
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { LanguageContent } from '@intlayer/core';\nimport { useLocale } from './useLocale';\nimport { useTraduction } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const { locale } = useLocale();\n\n const content = useTraduction(languageContent);\n\n return {\n locale,\n content,\n t: useTraduction,\n };\n};\n"],"mappings":"AACA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAKvB,MAAM,aAAa,CACxB,oBACG;AACH,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,UAAU,cAAc,eAAe;AAE7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;","names":[]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { UseIntlayer } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { UseIntlayer } from '../useIntlayerBase.mjs';
|
|
2
|
+
import '@intlayer/config/client';
|
|
3
|
+
import 'intlayer';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* On the client side, Hook that picking one dictionary by its id and return the content
|
|
7
|
+
*
|
|
8
|
+
* If the locale is not provided, it will use the locale from the client context
|
|
9
|
+
*/
|
|
5
10
|
declare const useIntlayer: UseIntlayer;
|
|
6
11
|
|
|
7
12
|
export { useIntlayer };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useContext } from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
useIntlayerBase
|
|
5
|
+
} from '../useIntlayerBase.mjs';
|
|
6
|
+
import { IntlayerClientContext } from './IntlayerClientProvider.mjs';
|
|
5
7
|
const useIntlayer = (id, locale) => {
|
|
6
|
-
const { locale: currentLocale } = useContext(
|
|
8
|
+
const { locale: currentLocale } = useContext(IntlayerClientContext);
|
|
7
9
|
const localeTarget = locale ?? currentLocale;
|
|
8
10
|
return useIntlayerBase(id, localeTarget);
|
|
9
11
|
};
|
|
10
|
-
export {
|
|
11
|
-
|
|
12
|
+
export {
|
|
13
|
+
useIntlayer
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useIntlayer.mjs.map
|
|
@@ -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 {
|
|
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,10 +1,13 @@
|
|
|
1
|
-
import * as _intlayer_config_client from
|
|
1
|
+
import * as _intlayer_config_client from '@intlayer/config/client';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* On the client side, hook to get the current locale and all related fields
|
|
5
|
+
*/
|
|
3
6
|
declare const useLocale: () => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
locale: _intlayer_config_client.Locales;
|
|
8
|
+
defaultLocale: _intlayer_config_client.Locales;
|
|
9
|
+
availableLocales: _intlayer_config_client.Locales[];
|
|
10
|
+
localeList: _intlayer_config_client.Locales[];
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
export { useLocale };
|