react-intlayer 1.0.0 → 1.0.1
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/LocaleContextProvider.cjs +14 -26
- package/dist/cjs/LocaleContextProvider.d.ts +5 -6
- package/dist/cjs/client/LocaleClientContextProvider.cjs +14 -26
- package/dist/cjs/client/LocaleClientContextProvider.d.ts +6 -11
- package/dist/cjs/client/index.cjs +23 -30
- package/dist/cjs/client/index.d.ts +10 -19
- package/dist/cjs/client/useContent.cjs +11 -16
- package/dist/cjs/client/useContent.d.ts +7 -8
- package/dist/cjs/client/useIntlayer.cjs +11 -18
- package/dist/cjs/client/useIntlayer.d.ts +3 -3
- package/dist/cjs/client/useLocale.cjs +12 -20
- package/dist/cjs/client/useLocale.d.ts +5 -5
- package/dist/cjs/client/useLocaleCookie.cjs +20 -30
- package/dist/cjs/client/useLocaleCookie.d.ts +3 -3
- package/dist/cjs/client/useTraduction.cjs +11 -18
- package/dist/cjs/client/useTraduction.d.ts +2 -4
- package/dist/cjs/getEnumeration.cjs +9 -14
- package/dist/cjs/getEnumeration.d.ts +2 -5
- package/dist/cjs/getTranslation.cjs +9 -14
- package/dist/cjs/getTranslation.d.ts +3 -6
- package/dist/cjs/index.cjs +19 -24
- 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.d.ts +5 -16
- package/dist/cjs/server/LocaleServerContextProvider.cjs +12 -21
- package/dist/cjs/server/LocaleServerContextProvider.d.ts +16 -26
- package/dist/cjs/server/getLocaleTranslation.cjs +12 -19
- package/dist/cjs/server/getLocaleTranslation.d.ts +5 -7
- package/dist/cjs/server/index.cjs +19 -26
- package/dist/cjs/server/index.d.ts +9 -13
- package/dist/cjs/server/serverContext.cjs +25 -31
- package/dist/cjs/server/serverContext.d.ts +12 -20
- package/dist/cjs/server/useIntlayer.cjs +12 -21
- package/dist/cjs/server/useIntlayer.d.ts +3 -3
- package/dist/cjs/server/useTraduction.cjs +12 -19
- package/dist/cjs/server/useTraduction.d.ts +2 -4
- package/dist/cjs/useIntlayerBase.cjs +22 -31
- package/dist/cjs/useIntlayerBase.d.ts +4 -12
- 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/LocaleContextProvider.d.mts +5 -6
- package/dist/esm/LocaleContextProvider.mjs +14 -12
- package/dist/esm/client/LocaleClientContextProvider.d.mts +6 -11
- package/dist/esm/client/LocaleClientContextProvider.mjs +16 -11
- package/dist/esm/client/index.d.mts +10 -19
- package/dist/esm/client/index.mjs +9 -9
- package/dist/esm/client/useContent.d.mts +7 -8
- package/dist/esm/client/useContent.mjs +7 -5
- package/dist/esm/client/useIntlayer.d.mts +3 -3
- package/dist/esm/client/useIntlayer.mjs +8 -4
- package/dist/esm/client/useLocale.d.mts +5 -5
- package/dist/esm/client/useLocale.mjs +6 -4
- package/dist/esm/client/useLocaleCookie.d.mts +3 -3
- package/dist/esm/client/useLocaleCookie.mjs +11 -5
- package/dist/esm/client/useTraduction.d.mts +2 -4
- package/dist/esm/client/useTraduction.mjs +6 -4
- package/dist/esm/getEnumeration.d.mts +2 -5
- package/dist/esm/getEnumeration.mjs +9 -4
- package/dist/esm/getTranslation.d.mts +3 -6
- package/dist/esm/getTranslation.mjs +8 -4
- package/dist/esm/index.d.mts +11 -20
- package/dist/esm/index.mjs +5 -5
- 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 +5 -16
- package/dist/esm/processDictionary/index.mjs +25 -9
- package/dist/esm/server/LocaleServerContextProvider.d.mts +16 -26
- package/dist/esm/server/LocaleServerContextProvider.mjs +11 -9
- package/dist/esm/server/getLocaleTranslation.d.mts +5 -7
- package/dist/esm/server/getLocaleTranslation.mjs +7 -5
- package/dist/esm/server/index.d.mts +9 -13
- package/dist/esm/server/index.mjs +7 -7
- package/dist/esm/server/serverContext.d.mts +12 -20
- package/dist/esm/server/serverContext.mjs +13 -6
- package/dist/esm/server/useIntlayer.d.mts +3 -3
- package/dist/esm/server/useIntlayer.mjs +9 -5
- package/dist/esm/server/useTraduction.d.mts +2 -4
- package/dist/esm/server/useTraduction.mjs +7 -5
- package/dist/esm/useIntlayerBase.d.mts +4 -12
- package/dist/esm/useIntlayerBase.mjs +9 -4
- package/package.json +8 -8
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import { Locales } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
TransformedContentValue,
|
|
5
|
-
Content,
|
|
6
|
-
TransformedContent,
|
|
7
|
-
} from "./contentDictionary.d.mjs";
|
|
8
|
-
import "@intlayer/core";
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
import { ContentValue, TransformedContentValue, Content, TransformedContent } from './contentDictionary.d.mjs';
|
|
3
|
+
import '@intlayer/core';
|
|
9
4
|
|
|
10
|
-
declare const processNode: (
|
|
11
|
-
field: ContentValue | undefined,
|
|
12
|
-
locale: Locales
|
|
13
|
-
) => TransformedContentValue;
|
|
5
|
+
declare const processNode: (field: ContentValue | undefined, locale: Locales) => TransformedContentValue;
|
|
14
6
|
/**
|
|
15
7
|
* Function to replace the multi lingual content with content in the current locale
|
|
16
8
|
*/
|
|
17
|
-
declare const processDictionary: (
|
|
18
|
-
content: Content,
|
|
19
|
-
locale?: Locales
|
|
20
|
-
) => TransformedContent;
|
|
9
|
+
declare const processDictionary: (content: Content, locale?: Locales) => TransformedContent;
|
|
21
10
|
|
|
22
11
|
export { processDictionary, processNode };
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
intlayerIntlConfiguration
|
|
3
|
+
} from "@intlayer/config/client";
|
|
4
|
+
import {
|
|
5
|
+
NodeType
|
|
6
|
+
} from "@intlayer/core";
|
|
7
|
+
import { getEnumeration } from '../getEnumeration.mjs';
|
|
8
|
+
import { getTranslation } from '../getTranslation.mjs';
|
|
5
9
|
const defaultLocale = intlayerIntlConfiguration.defaultLocale;
|
|
6
10
|
const processTranslation = (languageContent, locale) => {
|
|
7
|
-
const translationResult = getTranslation(
|
|
11
|
+
const translationResult = getTranslation(
|
|
12
|
+
languageContent,
|
|
13
|
+
locale
|
|
14
|
+
);
|
|
8
15
|
return processDictionary(translationResult, locale);
|
|
9
16
|
};
|
|
10
17
|
const processEnumeration = (enumerationContent, locale) => {
|
|
11
18
|
return (quantity) => {
|
|
12
|
-
const enumerationResult = getEnumeration(
|
|
19
|
+
const enumerationResult = getEnumeration(
|
|
20
|
+
enumerationContent,
|
|
21
|
+
quantity
|
|
22
|
+
);
|
|
13
23
|
return processDictionary(enumerationResult, locale);
|
|
14
24
|
};
|
|
15
25
|
};
|
|
@@ -21,7 +31,10 @@ const processNode = (field, locale) => {
|
|
|
21
31
|
return processTranslation(field, locale);
|
|
22
32
|
}
|
|
23
33
|
if (field.nodeType === NodeType.Enumeration) {
|
|
24
|
-
return processEnumeration(
|
|
34
|
+
return processEnumeration(
|
|
35
|
+
field,
|
|
36
|
+
locale
|
|
37
|
+
);
|
|
25
38
|
}
|
|
26
39
|
if (typeof field.type === "undefined") {
|
|
27
40
|
return processDictionary(field, locale);
|
|
@@ -39,5 +52,8 @@ const processDictionary = (content, locale = defaultLocale) => {
|
|
|
39
52
|
}
|
|
40
53
|
return content;
|
|
41
54
|
};
|
|
42
|
-
export {
|
|
43
|
-
|
|
55
|
+
export {
|
|
56
|
+
processDictionary,
|
|
57
|
+
processNode
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import * as react from
|
|
2
|
-
import { PropsWithChildren, FC } from
|
|
3
|
-
import { Locales } from
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PropsWithChildren, FC } from 'react';
|
|
3
|
+
import { Locales } from '@intlayer/config/client';
|
|
4
4
|
|
|
5
5
|
declare const LocaleServerContext: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
children:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}) => react.ReactNode;
|
|
18
|
-
_storage: () => {
|
|
19
|
-
value: Locales | undefined;
|
|
20
|
-
};
|
|
21
|
-
_defaultValue: Locales | undefined;
|
|
6
|
+
Provider: ({ children, value, }: {
|
|
7
|
+
children: react.ReactNode;
|
|
8
|
+
value: Locales;
|
|
9
|
+
}) => react.ReactNode;
|
|
10
|
+
Consumer: ({ children, }: {
|
|
11
|
+
children: (context: Locales | undefined) => react.ReactNode;
|
|
12
|
+
}) => react.ReactNode;
|
|
13
|
+
_storage: () => {
|
|
14
|
+
value: Locales | undefined;
|
|
15
|
+
};
|
|
16
|
+
_defaultValue: Locales | undefined;
|
|
22
17
|
};
|
|
23
18
|
declare const locale: Locales | undefined;
|
|
24
19
|
type LocaleServerContextProviderProps = PropsWithChildren & {
|
|
25
|
-
|
|
20
|
+
locale: Locales;
|
|
26
21
|
};
|
|
27
22
|
declare const LocaleServerContextProvider: FC<LocaleServerContextProviderProps>;
|
|
28
23
|
|
|
29
|
-
export {
|
|
30
|
-
LocaleServerContext,
|
|
31
|
-
LocaleServerContextProvider,
|
|
32
|
-
type LocaleServerContextProviderProps,
|
|
33
|
-
locale,
|
|
34
|
-
};
|
|
24
|
+
export { LocaleServerContext, LocaleServerContextProvider, type LocaleServerContextProviderProps, locale };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
intlayerIntlConfiguration
|
|
4
|
+
} from "@intlayer/config/client";
|
|
5
|
+
import { createServerContext, getServerContext } from './serverContext.mjs';
|
|
4
6
|
const LocaleServerContext = createServerContext(
|
|
5
7
|
intlayerIntlConfiguration.defaultLocale
|
|
6
8
|
);
|
|
7
9
|
const locale = getServerContext(LocaleServerContext);
|
|
8
|
-
const LocaleServerContextProvider = ({ children, locale: locale2 }) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=LocaleServerContextProvider.mjs.map
|
|
10
|
+
const LocaleServerContextProvider = ({ children, locale: locale2 }) => /* @__PURE__ */ jsx(LocaleServerContext.Provider, { value: locale2, children });
|
|
11
|
+
export {
|
|
12
|
+
LocaleServerContext,
|
|
13
|
+
LocaleServerContextProvider,
|
|
14
|
+
locale
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=LocaleServerContextProvider.mjs.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import * as _intlayer_config_client from
|
|
2
|
-
import { LanguageContent } from
|
|
1
|
+
import * as _intlayer_config_client from '@intlayer/config/client';
|
|
2
|
+
import { LanguageContent } from '@intlayer/core';
|
|
3
3
|
|
|
4
|
-
declare const getLocaleTranslation: <Content>(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
locale: _intlayer_config_client.Locales | undefined;
|
|
8
|
-
content: Content;
|
|
4
|
+
declare const getLocaleTranslation: <Content>(languageContent: LanguageContent<Content>) => {
|
|
5
|
+
locale: _intlayer_config_client.Locales | undefined;
|
|
6
|
+
content: Content;
|
|
9
7
|
};
|
|
10
8
|
|
|
11
9
|
export { getLocaleTranslation };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { intlayerIntlConfiguration } from "@intlayer/config/client";
|
|
2
2
|
import { getTranslationContent } from "@intlayer/core";
|
|
3
|
-
import { LocaleServerContext } from
|
|
4
|
-
import { getServerContext } from
|
|
3
|
+
import { LocaleServerContext } from './LocaleServerContextProvider.mjs';
|
|
4
|
+
import { getServerContext } from './serverContext.mjs';
|
|
5
5
|
const getLocaleTranslation = (languageContent) => {
|
|
6
6
|
const locale = getServerContext(LocaleServerContext);
|
|
7
7
|
const content = getTranslationContent(
|
|
@@ -10,8 +10,10 @@ const getLocaleTranslation = (languageContent) => {
|
|
|
10
10
|
);
|
|
11
11
|
return {
|
|
12
12
|
locale,
|
|
13
|
-
content
|
|
13
|
+
content
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
export {
|
|
17
|
-
|
|
16
|
+
export {
|
|
17
|
+
getLocaleTranslation
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=getLocaleTranslation.mjs.map
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
export { getLocaleTranslation as getLocaleContent } from
|
|
2
|
-
export { useTraduction } from
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import "@intlayer/core";
|
|
11
|
-
import "react";
|
|
12
|
-
import "../useIntlayerBase.mjs";
|
|
13
|
-
import "intlayer";
|
|
1
|
+
export { getLocaleTranslation as getLocaleContent } from './getLocaleTranslation.mjs';
|
|
2
|
+
export { useTraduction } from './useTraduction.mjs';
|
|
3
|
+
export { LocaleServerContext, LocaleServerContextProvider, locale } from './LocaleServerContextProvider.mjs';
|
|
4
|
+
export { useIntlayer } from './useIntlayer.mjs';
|
|
5
|
+
import '@intlayer/config/client';
|
|
6
|
+
import '@intlayer/core';
|
|
7
|
+
import 'react';
|
|
8
|
+
import '../useIntlayerBase.mjs';
|
|
9
|
+
import 'intlayer';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { getLocaleTranslation } from
|
|
2
|
-
import { useTraduction } from
|
|
1
|
+
import { getLocaleTranslation } from './getLocaleTranslation.mjs';
|
|
2
|
+
import { useTraduction } from './useTraduction.mjs';
|
|
3
3
|
import {
|
|
4
4
|
LocaleServerContext,
|
|
5
5
|
locale,
|
|
6
|
-
LocaleServerContextProvider
|
|
7
|
-
} from
|
|
8
|
-
import { useIntlayer } from
|
|
6
|
+
LocaleServerContextProvider
|
|
7
|
+
} from './LocaleServerContextProvider.mjs';
|
|
8
|
+
import { useIntlayer } from './useIntlayer.mjs';
|
|
9
9
|
export {
|
|
10
10
|
LocaleServerContext,
|
|
11
11
|
LocaleServerContextProvider,
|
|
12
12
|
getLocaleTranslation as getLocaleContent,
|
|
13
13
|
locale,
|
|
14
14
|
useIntlayer,
|
|
15
|
-
useTraduction
|
|
15
|
+
useTraduction
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=index.mjs.map
|
|
17
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -17,27 +17,19 @@ declare const createServerContext: <T>(defaultValue?: T) => ServerContext<T>;
|
|
|
17
17
|
* @example
|
|
18
18
|
* getServerContext(LocaleServerContext);
|
|
19
19
|
*/
|
|
20
|
-
declare const getServerContext: <T>({
|
|
21
|
-
_storage,
|
|
22
|
-
_defaultValue,
|
|
23
|
-
}: ServerContext<T>) => T | undefined;
|
|
20
|
+
declare const getServerContext: <T>({ _storage, _defaultValue, }: ServerContext<T>) => T | undefined;
|
|
24
21
|
type ServerContext<T> = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
children:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}) => React.ReactNode;
|
|
37
|
-
_storage: () => {
|
|
38
|
-
value: T | undefined;
|
|
39
|
-
};
|
|
40
|
-
_defaultValue: T | undefined;
|
|
22
|
+
Provider: ({ children, value, }: {
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
value: T;
|
|
25
|
+
}) => React.ReactNode;
|
|
26
|
+
Consumer: ({ children, }: {
|
|
27
|
+
children: (context: T | undefined) => React.ReactNode;
|
|
28
|
+
}) => React.ReactNode;
|
|
29
|
+
_storage: () => {
|
|
30
|
+
value: T | undefined;
|
|
31
|
+
};
|
|
32
|
+
_defaultValue: T | undefined;
|
|
41
33
|
};
|
|
42
34
|
|
|
43
35
|
export { createServerContext, getServerContext };
|
|
@@ -4,7 +4,7 @@ const createServerContext = (defaultValue) => {
|
|
|
4
4
|
throwInClient();
|
|
5
5
|
const cache = react.cache ?? cacheFallback;
|
|
6
6
|
const getCache = cache(() => ({
|
|
7
|
-
value: void 0
|
|
7
|
+
value: void 0
|
|
8
8
|
}));
|
|
9
9
|
return {
|
|
10
10
|
Provider: ({ children, value }) => {
|
|
@@ -16,12 +16,16 @@ const createServerContext = (defaultValue) => {
|
|
|
16
16
|
return children(store ? store.value : defaultValue);
|
|
17
17
|
},
|
|
18
18
|
_storage: getCache,
|
|
19
|
-
_defaultValue: defaultValue
|
|
19
|
+
_defaultValue: defaultValue
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
const getServerContext = ({
|
|
22
|
+
const getServerContext = ({
|
|
23
|
+
_storage,
|
|
24
|
+
_defaultValue
|
|
25
|
+
}) => {
|
|
23
26
|
const store = _storage();
|
|
24
|
-
if (!store)
|
|
27
|
+
if (!store)
|
|
28
|
+
return _defaultValue;
|
|
25
29
|
return store.value;
|
|
26
30
|
};
|
|
27
31
|
const throwInClient = () => {
|
|
@@ -29,5 +33,8 @@ const throwInClient = () => {
|
|
|
29
33
|
throw new Error(`createServerContext only works in Server Components`);
|
|
30
34
|
}
|
|
31
35
|
};
|
|
32
|
-
export {
|
|
33
|
-
|
|
36
|
+
export {
|
|
37
|
+
createServerContext,
|
|
38
|
+
getServerContext
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=serverContext.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
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
5
|
declare const useIntlayer: UseIntlayer;
|
|
6
6
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
useIntlayerBase
|
|
3
|
+
} from '../useIntlayerBase.mjs';
|
|
4
|
+
import { LocaleServerContext } from './LocaleServerContextProvider.mjs';
|
|
5
|
+
import { getServerContext } from './serverContext.mjs';
|
|
4
6
|
const useIntlayer = (id, locale) => {
|
|
5
7
|
const localeTarget = locale ?? getServerContext(LocaleServerContext);
|
|
6
8
|
return useIntlayerBase(id, localeTarget);
|
|
7
9
|
};
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
+
export {
|
|
11
|
+
useIntlayer
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useIntlayer.mjs.map
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { LanguageContent } from
|
|
1
|
+
import { LanguageContent } from '@intlayer/core';
|
|
2
2
|
|
|
3
|
-
declare const useTraduction: <Content>(
|
|
4
|
-
languageContent: LanguageContent<Content>
|
|
5
|
-
) => Content;
|
|
3
|
+
declare const useTraduction: <Content>(languageContent: LanguageContent<Content>) => Content;
|
|
6
4
|
|
|
7
5
|
export { useTraduction };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { getTranslation } from
|
|
2
|
-
import { LocaleServerContext } from
|
|
3
|
-
import { getServerContext } from
|
|
1
|
+
import { getTranslation } from '../getTranslation.mjs';
|
|
2
|
+
import { LocaleServerContext } from './LocaleServerContextProvider.mjs';
|
|
3
|
+
import { getServerContext } from './serverContext.mjs';
|
|
4
4
|
const useTraduction = (languageContent) => {
|
|
5
5
|
const locale = getServerContext(LocaleServerContext);
|
|
6
6
|
return getTranslation(languageContent, locale);
|
|
7
7
|
};
|
|
8
|
-
export {
|
|
9
|
-
|
|
8
|
+
export {
|
|
9
|
+
useTraduction
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useTraduction.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Locales } from
|
|
2
|
-
import { IntlayerDictionaryTypesConnector } from
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
import { IntlayerDictionaryTypesConnector } from 'intlayer';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.
|
|
@@ -9,15 +9,7 @@ import { IntlayerDictionaryTypesConnector } from "intlayer";
|
|
|
9
9
|
|
|
10
10
|
type StringFallback<T> = T extends never ? string : T;
|
|
11
11
|
type DictionaryKeys = StringFallback<keyof IntlayerDictionaryTypesConnector>;
|
|
12
|
-
type UseIntlayer = <T extends DictionaryKeys>(
|
|
13
|
-
id: T,
|
|
14
|
-
locale?: Locales
|
|
15
|
-
) => IntlayerDictionaryTypesConnector[T];
|
|
12
|
+
type UseIntlayer = <T extends DictionaryKeys>(id: T, locale?: Locales) => IntlayerDictionaryTypesConnector[T];
|
|
16
13
|
declare const useIntlayerBase: UseIntlayer;
|
|
17
14
|
|
|
18
|
-
export {
|
|
19
|
-
type DictionaryKeys,
|
|
20
|
-
type StringFallback,
|
|
21
|
-
type UseIntlayer,
|
|
22
|
-
useIntlayerBase,
|
|
23
|
-
};
|
|
15
|
+
export { type DictionaryKeys, type StringFallback, type UseIntlayer, useIntlayerBase };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import dictionaries from "@intlayer/dictionaries-entry";
|
|
2
|
-
import { processDictionary } from
|
|
2
|
+
import { processDictionary } from './processDictionary/index.mjs';
|
|
3
3
|
const useIntlayerBase = (id, locale) => {
|
|
4
4
|
const dictionary = dictionaries[id];
|
|
5
|
-
return processDictionary(
|
|
5
|
+
return processDictionary(
|
|
6
|
+
dictionary,
|
|
7
|
+
locale
|
|
8
|
+
);
|
|
6
9
|
};
|
|
7
|
-
export {
|
|
8
|
-
|
|
10
|
+
export {
|
|
11
|
+
useIntlayerBase
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useIntlayerBase.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Internationalization layer for React applications - Layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
|
|
6
6
|
"keywords": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"homepage": "https://github.com/aypineau/intlayer",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/aypineau/intlayer"
|
|
22
|
+
"url": "git+https://github.com/aypineau/intlayer.git"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"author": {
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"js-cookie": "^3.0.5",
|
|
57
57
|
"react-cookie": "^7.1.4",
|
|
58
|
-
"@intlayer/config": "^1.0.
|
|
59
|
-
"@intlayer/core": "^1.0.
|
|
60
|
-
"@intlayer/dictionaries-entry": "^1.0.
|
|
61
|
-
"intlayer": "^1.0.
|
|
58
|
+
"@intlayer/config": "^1.0.1",
|
|
59
|
+
"@intlayer/core": "^1.0.1",
|
|
60
|
+
"@intlayer/dictionaries-entry": "^1.0.1",
|
|
61
|
+
"intlayer": "^1.0.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/js-cookie": "^3.0.6",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"rimraf": "5.0.5",
|
|
70
70
|
"tsup": "^8.0.2",
|
|
71
71
|
"typescript": "^5.4.3",
|
|
72
|
-
"@utils/eslint-config": "^1.0.
|
|
73
|
-
"@utils/ts-config": "^1.0.
|
|
72
|
+
"@utils/eslint-config": "^1.0.1",
|
|
73
|
+
"@utils/ts-config": "^1.0.1"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"react": "^18.2.0",
|