react-intlayer 1.2.0 → 2.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/dist/cjs/IntlayerProvider.cjs +1 -1
- package/dist/cjs/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/cli/react-intlayer.cjs +68 -0
- package/dist/cjs/cli/react-intlayer.cjs.map +1 -0
- package/dist/cjs/cli/react-intlayer.d.ts +1 -0
- package/dist/cjs/{ContentEditor/contentRender.cjs → client/ContentEditionLayout.cjs} +9 -14
- package/dist/cjs/client/ContentEditionLayout.cjs.map +1 -0
- package/dist/cjs/client/ContentEditionLayout.d.ts +6 -0
- package/dist/cjs/client/IntlayerClientProvider.cjs +35 -2
- package/dist/cjs/client/IntlayerClientProvider.cjs.map +1 -1
- package/dist/cjs/client/IntlayerClientProvider.d.ts +2 -1
- package/dist/cjs/client/getBrowserLocale.cjs +170 -0
- package/dist/cjs/client/getBrowserLocale.cjs.map +1 -0
- package/dist/cjs/client/getBrowserLocale.d.ts +26 -0
- package/dist/cjs/client/index.cjs +6 -0
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/index.d.ts +2 -0
- package/dist/cjs/client/useContent.cjs +2 -2
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useContent.d.ts +1 -2
- package/dist/cjs/client/useLocale.cjs +5 -3
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocale.d.ts +1 -0
- package/dist/cjs/client/useLocaleBase.cjs +49 -0
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -0
- package/dist/cjs/client/useLocaleBase.d.ts +14 -0
- package/dist/cjs/client/useLocaleCookie.cjs +1 -1
- package/dist/cjs/client/useLocaleCookie.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.d.ts +6 -5
- package/dist/cjs/craco/craco.config.cjs +32 -0
- package/dist/cjs/craco/craco.config.cjs.map +1 -0
- package/dist/cjs/craco/craco.config.d.ts +2 -0
- package/dist/cjs/craco/intlayerCracoPlugin.cjs +89 -0
- package/dist/cjs/craco/intlayerCracoPlugin.cjs.map +1 -0
- package/dist/cjs/craco/intlayerCracoPlugin.d.ts +26 -0
- package/dist/cjs/getEnumeration.cjs +0 -4
- package/dist/cjs/getEnumeration.cjs.map +1 -1
- package/dist/cjs/getEnumeration.d.ts +8 -5
- package/dist/cjs/getTranslation.cjs +1 -5
- package/dist/cjs/getTranslation.cjs.map +1 -1
- package/dist/cjs/getTranslation.d.ts +3 -2
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/processDictionary/{contentDictionary.d.cjs → contentDictionary.cjs} +3 -3
- package/dist/cjs/processDictionary/contentDictionary.cjs.map +1 -0
- package/dist/cjs/processDictionary/contentDictionary.d.ts +16 -0
- package/dist/cjs/processDictionary/index.cjs +118 -21
- package/dist/cjs/processDictionary/index.cjs.map +1 -1
- package/dist/cjs/processDictionary/index.d.ts +5 -4
- package/dist/cjs/server/IntlayerServerProvider.cjs +1 -1
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/getLocaleTranslation.cjs +1 -1
- package/dist/cjs/server/getLocaleTranslation.cjs.map +1 -1
- package/dist/cjs/server/useTraduction.cjs.map +1 -1
- package/dist/cjs/server/useTraduction.d.ts +4 -3
- package/dist/cjs/useIntlayerBase.cjs +3 -0
- package/dist/cjs/useIntlayerBase.cjs.map +1 -1
- package/dist/cjs/vite/intlayerPlugin.cjs +60 -0
- package/dist/cjs/vite/intlayerPlugin.cjs.map +1 -0
- package/dist/cjs/vite/intlayerPlugin.d.ts +17 -0
- package/dist/esm/IntlayerProvider.mjs +3 -2
- package/dist/esm/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/chunk-ZNCO4QRF.mjs +9 -0
- package/dist/esm/cli/react-intlayer.d.mts +1 -0
- package/dist/esm/cli/react-intlayer.mjs +45 -0
- package/dist/esm/cli/react-intlayer.mjs.map +1 -0
- package/dist/esm/client/ContentEditionLayout.d.mts +6 -0
- package/dist/esm/client/ContentEditionLayout.mjs +11 -0
- package/dist/esm/client/ContentEditionLayout.mjs.map +1 -0
- package/dist/esm/client/IntlayerClientProvider.d.mts +2 -1
- package/dist/esm/client/IntlayerClientProvider.mjs +42 -7
- package/dist/esm/client/IntlayerClientProvider.mjs.map +1 -1
- package/dist/esm/client/getBrowserLocale.d.mts +26 -0
- package/dist/esm/client/getBrowserLocale.mjs +146 -0
- package/dist/esm/client/getBrowserLocale.mjs.map +1 -0
- package/dist/esm/client/index.d.mts +2 -0
- package/dist/esm/client/index.mjs +5 -0
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/useContent.d.mts +1 -2
- package/dist/esm/client/useContent.mjs +3 -2
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs +1 -0
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.d.mts +1 -0
- package/dist/esm/client/useLocale.mjs +7 -4
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.d.mts +14 -0
- package/dist/esm/client/useLocaleBase.mjs +26 -0
- package/dist/esm/client/useLocaleBase.mjs.map +1 -0
- package/dist/esm/client/useLocaleCookie.mjs +3 -4
- package/dist/esm/client/useLocaleCookie.mjs.map +1 -1
- package/dist/esm/client/useTraduction.d.mts +6 -5
- package/dist/esm/client/useTraduction.mjs +1 -0
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/craco/craco.config.d.mts +2 -0
- package/dist/esm/craco/craco.config.mjs +17 -0
- package/dist/esm/craco/craco.config.mjs.map +1 -0
- package/dist/esm/craco/intlayerCracoPlugin.d.mts +26 -0
- package/dist/esm/craco/intlayerCracoPlugin.mjs +54 -0
- package/dist/esm/craco/intlayerCracoPlugin.mjs.map +1 -0
- package/dist/esm/getEnumeration.d.mts +8 -5
- package/dist/esm/getEnumeration.mjs +1 -4
- package/dist/esm/getEnumeration.mjs.map +1 -1
- package/dist/esm/getTranslation.d.mts +3 -2
- package/dist/esm/getTranslation.mjs +3 -8
- package/dist/esm/getTranslation.mjs.map +1 -1
- package/dist/esm/index.d.mts +2 -0
- package/dist/esm/index.mjs +6 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/processDictionary/contentDictionary.d.mts +16 -0
- package/dist/esm/processDictionary/contentDictionary.mjs +1 -0
- package/dist/esm/processDictionary/contentDictionary.mjs.map +1 -0
- package/dist/esm/processDictionary/index.d.mts +5 -4
- package/dist/esm/processDictionary/index.mjs +122 -25
- package/dist/esm/processDictionary/index.mjs.map +1 -1
- package/dist/esm/server/IntlayerServerProvider.mjs +3 -4
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/getLocaleTranslation.mjs +3 -2
- package/dist/esm/server/getLocaleTranslation.mjs.map +1 -1
- package/dist/esm/server/index.mjs +1 -0
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/serverContext.mjs +1 -0
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs +1 -0
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/esm/server/useTraduction.d.mts +4 -3
- package/dist/esm/server/useTraduction.mjs +1 -0
- package/dist/esm/server/useTraduction.mjs.map +1 -1
- package/dist/esm/useIntlayerBase.mjs +4 -0
- package/dist/esm/useIntlayerBase.mjs.map +1 -1
- package/dist/esm/vite/intlayerPlugin.d.mts +17 -0
- package/dist/esm/vite/intlayerPlugin.mjs +36 -0
- package/dist/esm/vite/intlayerPlugin.mjs.map +1 -0
- package/package.json +37 -6
- package/src/IntlayerProvider.tsx +2 -2
- package/src/cli/react-intlayer.ts +60 -0
- package/src/client/ContentEditionLayout.tsx +15 -0
- package/src/client/IntlayerClientProvider.tsx +50 -12
- package/src/client/getBrowserLocale.tsx +192 -0
- package/src/client/index.ts +2 -0
- package/src/client/useContent.ts +2 -2
- package/src/client/useLocale.ts +5 -4
- package/src/client/useLocaleBase.ts +24 -0
- package/src/client/useLocaleCookie.ts +2 -5
- package/src/client/useTraduction.ts +6 -5
- package/src/craco/craco.config.ts +11 -0
- package/src/craco/intlayerCracoPlugin.ts +89 -0
- package/src/getEnumeration.ts +8 -10
- package/src/getTranslation.ts +5 -12
- package/src/index.ts +2 -1
- package/src/processDictionary/{contentDictionary.d.ts → contentDictionary.ts} +6 -5
- package/src/processDictionary/index.ts +159 -25
- package/src/server/IntlayerServerProvider.tsx +2 -5
- package/src/server/getLocaleTranslation.ts +2 -2
- package/src/server/useTraduction.ts +4 -3
- package/src/useIntlayerBase.ts +3 -0
- package/src/vite/intlayerPlugin.ts +59 -0
- package/dist/cjs/ContentEditor/ContentEditor.cjs +0 -110
- package/dist/cjs/ContentEditor/ContentEditor.cjs.map +0 -1
- package/dist/cjs/ContentEditor/ContentEditor.d.ts +0 -8
- package/dist/cjs/ContentEditor/contentRender.cjs.map +0 -1
- package/dist/cjs/ContentEditor/contentRender.d.ts +0 -3
- package/dist/cjs/ContentEditor/index.cjs +0 -25
- package/dist/cjs/ContentEditor/index.cjs.map +0 -1
- package/dist/cjs/ContentEditor/index.d.ts +0 -3
- package/dist/cjs/processDictionary/contentDictionary.d.cjs.map +0 -1
- package/dist/cjs/processDictionary/contentDictionary.d.d.ts +0 -29
- package/dist/esm/ContentEditor/ContentEditor.d.mts +0 -8
- package/dist/esm/ContentEditor/ContentEditor.mjs +0 -91
- package/dist/esm/ContentEditor/ContentEditor.mjs.map +0 -1
- package/dist/esm/ContentEditor/contentRender.d.mts +0 -3
- package/dist/esm/ContentEditor/contentRender.mjs +0 -13
- package/dist/esm/ContentEditor/contentRender.mjs.map +0 -1
- package/dist/esm/ContentEditor/index.d.mts +0 -3
- package/dist/esm/ContentEditor/index.mjs +0 -3
- package/dist/esm/ContentEditor/index.mjs.map +0 -1
- package/dist/esm/processDictionary/contentDictionary.d.d.mts +0 -29
- package/dist/esm/processDictionary/contentDictionary.d.mjs +0 -1
- package/src/ContentEditor/ContentEditor.tsx +0 -116
- package/src/ContentEditor/contentRender.tsx +0 -11
- package/src/ContentEditor/index.tsx +0 -2
- /package/dist/esm/{processDictionary/contentDictionary.d.mjs.map → chunk-ZNCO4QRF.mjs.map} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Locales } from '@intlayer/config/client';
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
2
|
+
import { KeyPath } from '@intlayer/core';
|
|
3
|
+
import { ContentValue, TransformedContentValue, Content, TransformedContent } from './contentDictionary.js';
|
|
4
|
+
import 'react';
|
|
4
5
|
|
|
5
|
-
declare const processNode: (field: ContentValue | undefined, locale: Locales) => TransformedContentValue;
|
|
6
|
+
declare const processNode: (field: ContentValue | undefined, locale: Locales, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[]) => TransformedContentValue;
|
|
6
7
|
/**
|
|
7
8
|
* Function that process a dictionary and return the result to be used in the application.
|
|
8
9
|
*/
|
|
9
|
-
declare const processDictionary: (content: Content, locale?: Locales) => TransformedContent;
|
|
10
|
+
declare const processDictionary: (content: Content, dictionaryId: string, dictionaryPath: string, keyPath?: KeyPath[], locale?: Locales) => TransformedContent;
|
|
10
11
|
|
|
11
12
|
export { processDictionary, processNode };
|
|
@@ -28,7 +28,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
28
28
|
var import_client = require("@intlayer/config/client");
|
|
29
29
|
var import_serverContext = require('./serverContext.cjs');
|
|
30
30
|
const IntlayerServerContext = (0, import_serverContext.createServerContext)(
|
|
31
|
-
import_client.
|
|
31
|
+
(0, import_client.getConfiguration)().internationalization.defaultLocale
|
|
32
32
|
);
|
|
33
33
|
const useIntlayer = () => (0, import_serverContext.getServerContext)(IntlayerServerContext);
|
|
34
34
|
const locale = (0, import_serverContext.getServerContext)(IntlayerServerContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext = createServerContext<Locales>(\n getConfiguration().internationalization.defaultLocale\n);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale: Locales;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n {children}\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCE;AAhCF,oBAA+C;AAE/C,2BAAsD;AAK/C,MAAM,4BAAwB;AAAA,MACnC,gCAAiB,EAAE,qBAAqB;AAC1C;AAKO,MAAM,cAAc,UAAM,uCAAiB,qBAAqB;AAKhE,MAAM,aAAS,uCAAiB,qBAAqB;AASrD,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,QAAAA;AACF,MACE,4CAAC,sBAAsB,UAAtB,EAA+B,OAAOA,SACpC,UACH;","names":["locale"]}
|
|
@@ -29,7 +29,7 @@ const getLocaleTranslation = (languageContent) => {
|
|
|
29
29
|
const locale = (0, import_serverContext.getServerContext)(import_IntlayerServerProvider.IntlayerServerContext);
|
|
30
30
|
const content = (0, import_core.getTranslationContent)(
|
|
31
31
|
languageContent,
|
|
32
|
-
locale ?? import_client.
|
|
32
|
+
locale ?? (0, import_client.getConfiguration)().internationalization.defaultLocale
|
|
33
33
|
);
|
|
34
34
|
return {
|
|
35
35
|
locale,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/getLocaleTranslation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/getLocaleTranslation.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config/client';\nimport { type LanguageContent, getTranslationContent } from '@intlayer/core';\nimport { IntlayerServerContext } from './IntlayerServerProvider';\nimport { getServerContext } from './serverContext';\n\n/**\n * On the server side, get the translation content based on the locale\n */\nexport const getLocaleTranslation = <Content>(\n languageContent: LanguageContent<Content>\n) => {\n const locale = getServerContext(IntlayerServerContext);\n const content = getTranslationContent<Content>(\n languageContent,\n locale ?? getConfiguration().internationalization.defaultLocale\n );\n\n return {\n locale,\n content,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AACjC,kBAA4D;AAC5D,oCAAsC;AACtC,2BAAiC;AAK1B,MAAM,uBAAuB,CAClC,oBACG;AACH,QAAM,aAAS,uCAAiB,mDAAqB;AACrD,QAAM,cAAU;AAAA,IACd;AAAA,IACA,cAAU,gCAAiB,EAAE,qBAAqB;AAAA,EACpD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -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 { 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 =
|
|
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 * ```ts\n * const content = useTraduction<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTraduction = <Content = string>(\n languageContent: LanguageContent<Content>\n) => {\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;AAuB1B,MAAM,gBAAgB,CAC3B,oBACG;AACH,QAAM,aAAS,uCAA0B,mDAAqB;AAE9D,aAAO,sCAAe,iBAAiB,MAAM;AAC/C;","names":[]}
|
|
@@ -9,12 +9,13 @@ import { LanguageContent } from '@intlayer/core';
|
|
|
9
9
|
*
|
|
10
10
|
* Usage:
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const content = useTraduction<string>({
|
|
13
14
|
* en: 'Hello',
|
|
14
15
|
* fr: 'Bonjour',
|
|
15
|
-
* },
|
|
16
|
-
* 'fr');
|
|
16
|
+
* }, 'fr');
|
|
17
17
|
* // 'Bonjour'
|
|
18
|
+
* ```
|
|
18
19
|
*
|
|
19
20
|
* Using TypeScript:
|
|
20
21
|
* - this function will require each locale to be defined if defined in the project configuration.
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"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 id,\n dictionary.filePath as string,\n [],\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,IACA,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AACF;","names":["dictionaries"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
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, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var intlayerPlugin_exports = {};
|
|
20
|
+
__export(intlayerPlugin_exports, {
|
|
21
|
+
intLayerPlugin: () => intLayerPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(intlayerPlugin_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_chokidar = require("@intlayer/chokidar");
|
|
26
|
+
var import_config = require("@intlayer/config");
|
|
27
|
+
var import_vite = require("vite");
|
|
28
|
+
const import_meta = {};
|
|
29
|
+
const intLayerPlugin = (_pluginOptions = {}) => ({
|
|
30
|
+
name: "vite-intlayer-plugin",
|
|
31
|
+
config: (config, { mode }) => {
|
|
32
|
+
const intlayerConfig = (0, import_config.getConfiguration)();
|
|
33
|
+
const env = (0, import_config.formatEnvVariable)("vite");
|
|
34
|
+
process.env = { ...process.env, ...(0, import_vite.loadEnv)(mode, process.cwd()), ...env };
|
|
35
|
+
const { mainDir, baseDir } = intlayerConfig.content;
|
|
36
|
+
const dictionariesPath = (0, import_path.join)(mainDir, "dictionaries.mjs");
|
|
37
|
+
const relativeDictionariesPath = (0, import_path.relative)(baseDir, dictionariesPath);
|
|
38
|
+
config.resolve = {
|
|
39
|
+
...config.resolve,
|
|
40
|
+
alias: {
|
|
41
|
+
...config.resolve?.alias,
|
|
42
|
+
"@intlayer/dictionaries-entry": (0, import_path.resolve)(relativeDictionariesPath)
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return config;
|
|
46
|
+
},
|
|
47
|
+
buildStart: () => {
|
|
48
|
+
(0, import_chokidar.watch)({
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
persistent: import_meta.env === "development"
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
configureServer: () => {
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
intLayerPlugin
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=intlayerPlugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/vite/intlayerPlugin.ts"],"sourcesContent":["import { join, relative, resolve } from 'path';\nimport { watch } from '@intlayer/chokidar';\nimport { getConfiguration, formatEnvVariable } from '@intlayer/config';\nimport { loadEnv, type Plugin } from 'vite';\n\n// Plugin options type definition\ntype PluginOptions = {\n // Custom options for your plugin, if any\n};\n\n/**\n *\n * A Vite plugin that integrates IntLayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intLayerPlugin() ],\n * });\n * ```\n * */\nexport const intLayerPlugin = (_pluginOptions: PluginOptions = {}): Plugin => ({\n name: 'vite-intlayer-plugin',\n\n config: (config, { mode }) => {\n const intlayerConfig = getConfiguration();\n\n // Set all configuration values as environment variables\n const env = formatEnvVariable('vite');\n\n process.env = { ...process.env, ...loadEnv(mode, process.cwd()), ...env };\n\n const { mainDir, baseDir } = intlayerConfig.content;\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n // Update Vite's resolve alias\n config.resolve = {\n ...config.resolve,\n alias: {\n ...config.resolve?.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n },\n };\n\n return config;\n },\n\n buildStart: () => {\n // Code to run when Vite build starts\n watch({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n persistent: (import.meta as any).env === 'development',\n });\n },\n configureServer: () => {\n // Custom server configuration, if needed\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwC;AACxC,sBAAsB;AACtB,oBAAoD;AACpD,kBAAqC;AAHrC;AAqBO,MAAM,iBAAiB,CAAC,iBAAgC,CAAC,OAAe;AAAA,EAC7E,MAAM;AAAA,EAEN,QAAQ,CAAC,QAAQ,EAAE,KAAK,MAAM;AAC5B,UAAM,qBAAiB,gCAAiB;AAGxC,UAAM,UAAM,iCAAkB,MAAM;AAEpC,YAAQ,MAAM,EAAE,GAAG,QAAQ,KAAK,OAAG,qBAAQ,MAAM,QAAQ,IAAI,CAAC,GAAG,GAAG,IAAI;AAExE,UAAM,EAAE,SAAS,QAAQ,IAAI,eAAe;AAC5C,UAAM,uBAAmB,kBAAK,SAAS,kBAAkB;AACzD,UAAM,+BAA2B,sBAAS,SAAS,gBAAgB;AAGnE,WAAO,UAAU;AAAA,MACf,GAAG,OAAO;AAAA,MACV,OAAO;AAAA,QACL,GAAG,OAAO,SAAS;AAAA,QACnB,oCAAgC,qBAAQ,wBAAwB;AAAA,MAClE;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,YAAY,MAAM;AAEhB,+BAAM;AAAA;AAAA,MAEJ,YAAa,YAAoB,QAAQ;AAAA,IAC3C,CAAC;AAAA,EACH;AAAA,EACA,iBAAiB,MAAM;AAAA,EAEvB;AACF;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
type PluginOptions = {};
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* A Vite plugin that integrates IntLayer configuration into the build process
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Example usage of the plugin in a Vite configuration
|
|
10
|
+
* export default defineConfig({
|
|
11
|
+
* plugins: [ intLayerPlugin() ],
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
* */
|
|
15
|
+
declare const intLayerPlugin: (_pluginOptions?: PluginOptions) => Plugin;
|
|
16
|
+
|
|
17
|
+
export { intLayerPlugin };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import "./chunk-ZNCO4QRF.mjs";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
+
import { getConfiguration } from "@intlayer/config/client";
|
|
3
4
|
import {
|
|
4
5
|
IntlayerClientProvider
|
|
5
6
|
} from './client/IntlayerClientProvider.mjs';
|
|
6
7
|
import {
|
|
7
8
|
IntlayerServerProvider
|
|
8
9
|
} from './server/IntlayerServerProvider.mjs';
|
|
9
|
-
const defaultLocale =
|
|
10
|
+
const { defaultLocale } = getConfiguration().internationalization;
|
|
10
11
|
const IntlayerProvider = ({
|
|
11
12
|
children,
|
|
12
13
|
locale = defaultLocale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/IntlayerProvider.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../src/IntlayerProvider.tsx"],"sourcesContent":["import { getConfiguration } 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 } = getConfiguration().internationalization;\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,wBAAwB;AAEjC;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAEK;AAEP,MAAM,EAAE,cAAc,IAAI,iBAAiB,EAAE;AAKtC,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA,SAAS;AACX,MACE,oBAAC,0BAAuB,QACtB,8BAAC,0BAAuB,QAAiB,UAAS,GACpD;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
__commonJS
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=chunk-ZNCO4QRF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import spawn from "cross-spawn";
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
const scriptIndex = args.findIndex(
|
|
5
|
+
(x) => x === "build" || x === "start" || x === "test"
|
|
6
|
+
);
|
|
7
|
+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
8
|
+
switch (script) {
|
|
9
|
+
case "build":
|
|
10
|
+
case "start":
|
|
11
|
+
case "test": {
|
|
12
|
+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
|
13
|
+
const scriptPath = require.resolve(`@craco/craco/dist/scripts/${script}`);
|
|
14
|
+
const scriptArgs = args.slice(scriptIndex + 1);
|
|
15
|
+
const processArgs = nodeArgs.concat(scriptPath).concat([
|
|
16
|
+
...scriptArgs,
|
|
17
|
+
"--config",
|
|
18
|
+
"./node_modules/react-intlayer/dist/cjs/craco/craco.config.cjs"
|
|
19
|
+
]);
|
|
20
|
+
const child = spawn.sync("node", processArgs, { stdio: "inherit" });
|
|
21
|
+
if (child.signal) {
|
|
22
|
+
if (child.signal === "SIGKILL") {
|
|
23
|
+
console.info(`
|
|
24
|
+
The build failed because the process exited too early.
|
|
25
|
+
This probably means the system ran out of memory or someone called
|
|
26
|
+
\`kill -9\` on the process.
|
|
27
|
+
`);
|
|
28
|
+
} else if (child.signal === "SIGTERM") {
|
|
29
|
+
console.info(`
|
|
30
|
+
The build failed because the process exited too early.
|
|
31
|
+
Someone might have called \`kill\` or \`killall\`, or the system could
|
|
32
|
+
be shutting down.
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
process.exit(child.status ?? void 0);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
default:
|
|
41
|
+
console.info(`Unknown script "${script}".`);
|
|
42
|
+
console.info("Perhaps you need to update craco?");
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=react-intlayer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/react-intlayer.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * To make the setup easier, we are using craco to override the webpack configuration.\n * This script is used to run the craco scripts with the custom configuration.\n *\n * The script is based on the original craco script from create-react-app.\n */\n\nimport spawn from 'cross-spawn';\n\nconst args = process.argv.slice(2);\nconst scriptIndex = args.findIndex(\n (x) => x === 'build' || x === 'start' || x === 'test'\n);\nconst script = scriptIndex === -1 ? args[0] : args[scriptIndex];\n\nswitch (script) {\n case 'build':\n case 'start':\n case 'test': {\n const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];\n const scriptPath = require.resolve(`@craco/craco/dist/scripts/${script}`);\n const scriptArgs = args.slice(scriptIndex + 1);\n const processArgs = nodeArgs\n .concat(scriptPath)\n .concat([\n ...scriptArgs,\n '--config',\n './node_modules/react-intlayer/dist/cjs/craco/craco.config.cjs',\n ]);\n\n const child = spawn.sync('node', processArgs, { stdio: 'inherit' });\n\n if (child.signal) {\n if (child.signal === 'SIGKILL') {\n console.info(`\n The build failed because the process exited too early.\n This probably means the system ran out of memory or someone called\n \\`kill -9\\` on the process.\n `);\n } else if (child.signal === 'SIGTERM') {\n console.info(`\n The build failed because the process exited too early.\n Someone might have called \\`kill\\` or \\`killall\\`, or the system could\n be shutting down.\n `);\n }\n\n process.exit(1);\n }\n\n process.exit(child.status ?? undefined);\n break;\n }\n default:\n console.info(`Unknown script \"${script}\".`);\n console.info('Perhaps you need to update craco?');\n break;\n}\n"],"mappings":";AASA,OAAO,WAAW;AAElB,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC;AACjC,MAAM,cAAc,KAAK;AAAA,EACvB,CAAC,MAAM,MAAM,WAAW,MAAM,WAAW,MAAM;AACjD;AACA,MAAM,SAAS,gBAAgB,KAAK,KAAK,CAAC,IAAI,KAAK,WAAW;AAE9D,QAAQ,QAAQ;AAAA,EACd,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK,QAAQ;AACX,UAAM,WAAW,cAAc,IAAI,KAAK,MAAM,GAAG,WAAW,IAAI,CAAC;AACjE,UAAM,aAAa,QAAQ,QAAQ,6BAA6B,MAAM,EAAE;AACxE,UAAM,aAAa,KAAK,MAAM,cAAc,CAAC;AAC7C,UAAM,cAAc,SACjB,OAAO,UAAU,EACjB,OAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAEH,UAAM,QAAQ,MAAM,KAAK,QAAQ,aAAa,EAAE,OAAO,UAAU,CAAC;AAElE,QAAI,MAAM,QAAQ;AAChB,UAAI,MAAM,WAAW,WAAW;AAC9B,gBAAQ,KAAK;AAAA;AAAA;AAAA;AAAA,aAIR;AAAA,MACP,WAAW,MAAM,WAAW,WAAW;AACrC,gBAAQ,KAAK;AAAA;AAAA;AAAA;AAAA,aAIR;AAAA,MACP;AAEA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,YAAQ,KAAK,MAAM,UAAU,MAAS;AACtC;AAAA,EACF;AAAA,EACA;AACE,YAAQ,KAAK,mBAAmB,MAAM,IAAI;AAC1C,YAAQ,KAAK,mCAAmC;AAChD;AACJ;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "../chunk-ZNCO4QRF.mjs";
|
|
2
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
ContentEditionLayout as ContentEditionLayoutBase
|
|
5
|
+
} from "intlayer-editor/client";
|
|
6
|
+
const BlankLayout = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
|
|
7
|
+
const ContentEditionLayout = typeof ContentEditionLayoutBase === "undefined" ? BlankLayout : ContentEditionLayoutBase;
|
|
8
|
+
export {
|
|
9
|
+
ContentEditionLayout
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=ContentEditionLayout.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/ContentEditionLayout.tsx"],"sourcesContent":["import {\n ContentEditionLayout as ContentEditionLayoutBase,\n type ContentEditionLayoutProps,\n} from 'intlayer-editor/client';\nimport type { FC } from 'react';\n\nconst BlankLayout: FC<ContentEditionLayoutProps> = ({ children }) => (\n <>{children}</>\n);\n\n// intlayer-editor is an optional dependency. If it's not installed, return the blank layout\nexport const ContentEditionLayout: FC<ContentEditionLayoutProps> =\n typeof ContentEditionLayoutBase === 'undefined'\n ? BlankLayout\n : (ContentEditionLayoutBase as typeof ContentEditionLayout);\n"],"mappings":";AAOE;AAPF;AAAA,EACE,wBAAwB;AAAA,OAEnB;AAGP,MAAM,cAA6C,CAAC,EAAE,SAAS,MAC7D,gCAAG,UAAS;AAIP,MAAM,uBACX,OAAO,6BAA6B,cAChC,cACC;","names":[]}
|
|
@@ -4,6 +4,7 @@ import { Locales } from '@intlayer/config/client';
|
|
|
4
4
|
|
|
5
5
|
type IntlayerValue = {
|
|
6
6
|
locale: Locales;
|
|
7
|
+
setLocale: (newLocale: Locales) => void;
|
|
7
8
|
};
|
|
8
9
|
/**
|
|
9
10
|
* Context that store the current locale on the client side
|
|
@@ -14,7 +15,7 @@ declare const IntlayerClientContext: react.Context<IntlayerValue>;
|
|
|
14
15
|
*/
|
|
15
16
|
declare const useIntlayerContext: () => IntlayerValue;
|
|
16
17
|
type IntlayerClientProviderProps = PropsWithChildren & {
|
|
17
|
-
locale
|
|
18
|
+
locale?: Locales;
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
21
|
* Provider that store the current locale on the client side
|
|
@@ -1,21 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import "../chunk-ZNCO4QRF.mjs";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
intlayerIntlConfiguration
|
|
5
|
-
} from "@intlayer/config/client";
|
|
4
|
+
import { getConfiguration } from "@intlayer/config/client";
|
|
6
5
|
import {
|
|
7
6
|
createContext,
|
|
8
|
-
useContext
|
|
7
|
+
useContext,
|
|
8
|
+
useMemo,
|
|
9
|
+
useState,
|
|
10
|
+
useCallback
|
|
9
11
|
} from "react";
|
|
10
|
-
import {
|
|
12
|
+
import { ContentEditionLayout } from './ContentEditionLayout.mjs';
|
|
13
|
+
import { localeCookie, setLocaleCookie } from './useLocaleCookie.mjs';
|
|
11
14
|
const IntlayerClientContext = createContext({
|
|
12
|
-
locale: localeCookie ??
|
|
15
|
+
locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,
|
|
16
|
+
setLocale: () => null
|
|
13
17
|
});
|
|
14
18
|
const useIntlayerContext = () => useContext(IntlayerClientContext);
|
|
15
19
|
const IntlayerClientProvider = ({
|
|
16
20
|
locale,
|
|
17
21
|
children
|
|
18
|
-
}) =>
|
|
22
|
+
}) => {
|
|
23
|
+
const { defaultLocale, locales: availableLocales } = getConfiguration().internationalization;
|
|
24
|
+
const [currentLocale, setCurrentLocale] = useState(
|
|
25
|
+
locale ?? localeCookie ?? defaultLocale
|
|
26
|
+
);
|
|
27
|
+
const setLocale = useCallback(
|
|
28
|
+
(newLocale) => {
|
|
29
|
+
if (currentLocale.toString() === newLocale.toString())
|
|
30
|
+
return;
|
|
31
|
+
if (!availableLocales.includes(newLocale)) {
|
|
32
|
+
console.error(`Locale ${locale} is not available`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
setCurrentLocale(newLocale);
|
|
36
|
+
setLocaleCookie(newLocale);
|
|
37
|
+
},
|
|
38
|
+
[availableLocales, currentLocale, locale]
|
|
39
|
+
);
|
|
40
|
+
const value = useMemo(
|
|
41
|
+
() => ({ locale: currentLocale, setLocale }),
|
|
42
|
+
[currentLocale, setLocale]
|
|
43
|
+
);
|
|
44
|
+
return /* @__PURE__ */ jsx(IntlayerClientContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
45
|
+
ContentEditionLayout,
|
|
46
|
+
{
|
|
47
|
+
locale: currentLocale,
|
|
48
|
+
setLocale,
|
|
49
|
+
localeList: availableLocales,
|
|
50
|
+
children
|
|
51
|
+
}
|
|
52
|
+
) });
|
|
53
|
+
};
|
|
19
54
|
export {
|
|
20
55
|
IntlayerClientContext,
|
|
21
56
|
IntlayerClientProvider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { ContentEditionLayout } from './ContentEditionLayout';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\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 const { defaultLocale, locales: availableLocales } =\n getConfiguration().internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocale = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <ContentEditionLayout\n locale={currentLocale}\n setLocale={setLocale}\n localeList={availableLocales}\n >\n {children}\n </ContentEditionLayout>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";;AAyEM;AAvEN,SAAS,wBAAsC;AAC/C;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,4BAA4B;AACrC,SAAS,cAAc,uBAAuB;AAUvC,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AASjE,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAC/C,iBAAiB,EAAE;AAErB,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,YAAY;AAAA,IAChB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS;AAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAU;AAAA,IAC1C,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,IAAC;AAAA;AAAA,MACC,QAAQ;AAAA,MACR;AAAA,MACA,YAAY;AAAA,MAEX;AAAA;AAAA,EACH,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Locales } from '@intlayer/config/client';
|
|
2
|
+
|
|
3
|
+
declare enum LanguageDetector {
|
|
4
|
+
Querystring = "querystring",
|
|
5
|
+
Cookie = "cookie",
|
|
6
|
+
LocalStorage = "localStorage",
|
|
7
|
+
SessionStorage = "sessionStorage",
|
|
8
|
+
Navigator = "navigator",
|
|
9
|
+
HtmlTag = "htmlTag"
|
|
10
|
+
}
|
|
11
|
+
type LanguageDetectorOptions = {
|
|
12
|
+
order?: LanguageDetector[];
|
|
13
|
+
lookupQuerystring?: string;
|
|
14
|
+
lookupCookie?: string;
|
|
15
|
+
lookupLocalStorage?: string;
|
|
16
|
+
lookupSessionStorage?: string;
|
|
17
|
+
excludeCacheFor?: string[];
|
|
18
|
+
htmlTag?: HTMLElement | null;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Core language detector function
|
|
22
|
+
* const detectedLanguages = detectLanguage(['LanguageDetector.Cookie', 'LanguageDetector.LocalStorage'], { lookupCookie: 'myCookie' });
|
|
23
|
+
*/
|
|
24
|
+
declare const getBrowserLocale: (userOptions?: LanguageDetectorOptions | undefined) => Locales;
|
|
25
|
+
|
|
26
|
+
export { LanguageDetector, getBrowserLocale };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import "../chunk-ZNCO4QRF.mjs";
|
|
2
|
+
import { getConfiguration } from "@intlayer/config/client";
|
|
3
|
+
import { localeList } from "@intlayer/core";
|
|
4
|
+
var LanguageDetector = /* @__PURE__ */ ((LanguageDetector2) => {
|
|
5
|
+
LanguageDetector2["Querystring"] = "querystring";
|
|
6
|
+
LanguageDetector2["Cookie"] = "cookie";
|
|
7
|
+
LanguageDetector2["LocalStorage"] = "localStorage";
|
|
8
|
+
LanguageDetector2["SessionStorage"] = "sessionStorage";
|
|
9
|
+
LanguageDetector2["Navigator"] = "navigator";
|
|
10
|
+
LanguageDetector2["HtmlTag"] = "htmlTag";
|
|
11
|
+
return LanguageDetector2;
|
|
12
|
+
})(LanguageDetector || {});
|
|
13
|
+
const getDefaultsOptions = () => {
|
|
14
|
+
const { middleware } = getConfiguration();
|
|
15
|
+
return {
|
|
16
|
+
order: [
|
|
17
|
+
"querystring" /* Querystring */,
|
|
18
|
+
"cookie" /* Cookie */,
|
|
19
|
+
"navigator" /* Navigator */,
|
|
20
|
+
"htmlTag" /* HtmlTag */
|
|
21
|
+
],
|
|
22
|
+
lookupQuerystring: "locale",
|
|
23
|
+
lookupCookie: middleware.cookieName,
|
|
24
|
+
htmlTag: document.documentElement
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const isLocalStorageAvailable = () => {
|
|
28
|
+
try {
|
|
29
|
+
if (typeof window === "undefined")
|
|
30
|
+
return false;
|
|
31
|
+
const testKey = "intlayer.translate.boo";
|
|
32
|
+
window.localStorage.setItem(testKey, "foo");
|
|
33
|
+
window.localStorage.removeItem(testKey);
|
|
34
|
+
return true;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const isSessionStorageAvailable = () => {
|
|
40
|
+
try {
|
|
41
|
+
if (typeof window === "undefined")
|
|
42
|
+
return false;
|
|
43
|
+
const testKey = "intlayer.translate.boo";
|
|
44
|
+
window.sessionStorage.setItem(testKey, "foo");
|
|
45
|
+
window.sessionStorage.removeItem(testKey);
|
|
46
|
+
return true;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const detectLanguage = (order, options) => {
|
|
52
|
+
const detected = {};
|
|
53
|
+
const queryStringDetector = () => {
|
|
54
|
+
if (typeof window === "undefined")
|
|
55
|
+
return;
|
|
56
|
+
const search = window.location.search || "";
|
|
57
|
+
const params = new URLSearchParams(search);
|
|
58
|
+
const value = params.get(options.lookupQuerystring ?? "");
|
|
59
|
+
if (value) {
|
|
60
|
+
detected["querystring" /* Querystring */] = value;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const cookieDetector = () => {
|
|
64
|
+
if (typeof document === "undefined")
|
|
65
|
+
return;
|
|
66
|
+
const cookies = document.cookie.split(";");
|
|
67
|
+
const cookieName = `${options.lookupCookie ?? ""}=`;
|
|
68
|
+
const cookie = cookies.find((c) => c.trim().startsWith(cookieName));
|
|
69
|
+
if (cookie) {
|
|
70
|
+
const value = cookie.split("=")[1].trim();
|
|
71
|
+
detected["cookie" /* Cookie */] = value;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const localStorageDetector = () => {
|
|
75
|
+
if (!isLocalStorageAvailable())
|
|
76
|
+
return;
|
|
77
|
+
const value = window.localStorage.getItem(options.lookupLocalStorage ?? "");
|
|
78
|
+
if (value) {
|
|
79
|
+
detected["localStorage" /* LocalStorage */] = value;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const sessionStorageDetector = () => {
|
|
83
|
+
if (!isSessionStorageAvailable())
|
|
84
|
+
return;
|
|
85
|
+
const value = window.sessionStorage.getItem(
|
|
86
|
+
options.lookupSessionStorage ?? ""
|
|
87
|
+
);
|
|
88
|
+
if (value) {
|
|
89
|
+
detected["sessionStorage" /* SessionStorage */] = value;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const navigatorDetector = () => {
|
|
93
|
+
if (typeof navigator === "undefined")
|
|
94
|
+
return;
|
|
95
|
+
if (navigator.language) {
|
|
96
|
+
detected["navigator" /* Navigator */] = navigator.language;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const htmlTagDetector = () => {
|
|
100
|
+
const htmlTag = options.htmlTag;
|
|
101
|
+
if (htmlTag && typeof htmlTag.getAttribute === "function") {
|
|
102
|
+
const lang = htmlTag.getAttribute("lang");
|
|
103
|
+
if (lang) {
|
|
104
|
+
detected["htmlTag" /* HtmlTag */] = lang;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const detectors = {
|
|
109
|
+
["querystring" /* Querystring */]: queryStringDetector,
|
|
110
|
+
["cookie" /* Cookie */]: cookieDetector,
|
|
111
|
+
["localStorage" /* LocalStorage */]: localStorageDetector,
|
|
112
|
+
["sessionStorage" /* SessionStorage */]: sessionStorageDetector,
|
|
113
|
+
["navigator" /* Navigator */]: navigatorDetector,
|
|
114
|
+
["htmlTag" /* HtmlTag */]: htmlTagDetector
|
|
115
|
+
};
|
|
116
|
+
order.forEach((detectorName) => {
|
|
117
|
+
detectors[detectorName]?.();
|
|
118
|
+
});
|
|
119
|
+
return detected;
|
|
120
|
+
};
|
|
121
|
+
const getFirstAvailableLocale = (locales, order) => {
|
|
122
|
+
const { internationalization } = getConfiguration();
|
|
123
|
+
for (const detector of order) {
|
|
124
|
+
const localesArray = [locales[detector]].flat();
|
|
125
|
+
for (const locale of localesArray) {
|
|
126
|
+
if (locale && (internationalization.locales ?? localeList).includes(locale)) {
|
|
127
|
+
return locale;
|
|
128
|
+
} else if (locale?.includes("-") && (internationalization.locales ?? localeList).includes(
|
|
129
|
+
locale.split("-")[0]
|
|
130
|
+
)) {
|
|
131
|
+
return locale.split("-")[0];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return internationalization.defaultLocale;
|
|
136
|
+
};
|
|
137
|
+
const getBrowserLocale = (userOptions = {}) => {
|
|
138
|
+
const options = { ...getDefaultsOptions(), ...userOptions };
|
|
139
|
+
const locales = detectLanguage(options.order ?? [], options);
|
|
140
|
+
return getFirstAvailableLocale(locales, options.order ?? []);
|
|
141
|
+
};
|
|
142
|
+
export {
|
|
143
|
+
LanguageDetector,
|
|
144
|
+
getBrowserLocale
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=getBrowserLocale.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/getBrowserLocale.tsx"],"sourcesContent":["import { getConfiguration, type Locales } from '@intlayer/config/client';\nimport { localeList } from '@intlayer/core';\n\nexport enum LanguageDetector {\n Querystring = 'querystring',\n Cookie = 'cookie',\n LocalStorage = 'localStorage',\n SessionStorage = 'sessionStorage',\n Navigator = 'navigator',\n HtmlTag = 'htmlTag',\n}\n\n// Default settings for the language detector\ntype LanguageDetectorOptions = {\n order?: LanguageDetector[];\n lookupQuerystring?: string;\n lookupCookie?: string;\n lookupLocalStorage?: string;\n lookupSessionStorage?: string;\n excludeCacheFor?: string[];\n htmlTag?: HTMLElement | null;\n};\n\nconst getDefaultsOptions = (): LanguageDetectorOptions => {\n const { middleware } = getConfiguration();\n\n return {\n order: [\n LanguageDetector.Querystring,\n LanguageDetector.Cookie,\n LanguageDetector.Navigator,\n LanguageDetector.HtmlTag,\n ],\n lookupQuerystring: 'locale',\n lookupCookie: middleware.cookieName,\n htmlTag: document.documentElement,\n };\n};\n\n// Helper functions for various checks and operations\nconst isLocalStorageAvailable = (): boolean => {\n try {\n if (typeof window === 'undefined') return false;\n const testKey = 'intlayer.translate.boo';\n window.localStorage.setItem(testKey, 'foo');\n window.localStorage.removeItem(testKey);\n return true;\n } catch {\n return false;\n }\n};\n\nconst isSessionStorageAvailable = (): boolean => {\n try {\n if (typeof window === 'undefined') return false;\n const testKey = 'intlayer.translate.boo';\n window.sessionStorage.setItem(testKey, 'foo');\n window.sessionStorage.removeItem(testKey);\n return true;\n } catch {\n return false;\n }\n};\n\n// Function to detect language using different detectors\nconst detectLanguage = (\n order: string[],\n options: LanguageDetectorOptions\n): Record<LanguageDetector, Locales | Locales[]> => {\n const detected: Record<LanguageDetector, Locales | Locales[]> = {} as Record<\n LanguageDetector,\n Locales | Locales[]\n >;\n\n const queryStringDetector = () => {\n if (typeof window === 'undefined') return;\n const search = window.location.search || '';\n const params = new URLSearchParams(search);\n const value = params.get(options.lookupQuerystring ?? '');\n if (value) {\n detected[LanguageDetector.Querystring] = value as Locales;\n }\n };\n\n const cookieDetector = () => {\n if (typeof document === 'undefined') return;\n const cookies = document.cookie.split(';');\n const cookieName = `${options.lookupCookie ?? ''}=`;\n const cookie = cookies.find((c) => c.trim().startsWith(cookieName));\n if (cookie) {\n const value = cookie.split('=')[1].trim();\n\n detected[LanguageDetector.Cookie] = value as Locales;\n }\n };\n\n const localStorageDetector = () => {\n if (!isLocalStorageAvailable()) return;\n const value = window.localStorage.getItem(options.lookupLocalStorage ?? '');\n if (value) {\n detected[LanguageDetector.LocalStorage] = value as Locales;\n }\n };\n\n const sessionStorageDetector = () => {\n if (!isSessionStorageAvailable()) return;\n const value = window.sessionStorage.getItem(\n options.lookupSessionStorage ?? ''\n );\n if (value) {\n detected[LanguageDetector.SessionStorage] = value as Locales;\n }\n };\n\n const navigatorDetector = () => {\n if (typeof navigator === 'undefined') return;\n\n if (navigator.language) {\n detected[LanguageDetector.Navigator] = navigator.language as Locales;\n }\n };\n\n const htmlTagDetector = () => {\n const htmlTag = options.htmlTag;\n if (htmlTag && typeof htmlTag.getAttribute === 'function') {\n const lang = htmlTag.getAttribute('lang');\n if (lang) {\n detected[LanguageDetector.HtmlTag] = lang as Locales;\n }\n }\n };\n\n // Map detector names to their corresponding functions\n const detectors: Record<string, () => void> = {\n [LanguageDetector.Querystring]: queryStringDetector,\n [LanguageDetector.Cookie]: cookieDetector,\n [LanguageDetector.LocalStorage]: localStorageDetector,\n [LanguageDetector.SessionStorage]: sessionStorageDetector,\n [LanguageDetector.Navigator]: navigatorDetector,\n [LanguageDetector.HtmlTag]: htmlTagDetector,\n };\n\n // Use the provided order to run each detector\n order.forEach((detectorName) => {\n detectors[detectorName]?.();\n });\n\n return detected;\n};\n\nconst getFirstAvailableLocale = (\n locales: Record<LanguageDetector, Locales | Locales[]>,\n order: LanguageDetector[]\n): Locales => {\n const { internationalization } = getConfiguration();\n\n for (const detector of order) {\n const localesArray = [locales[detector]].flat() as Locales[];\n\n for (const locale of localesArray) {\n if (\n locale &&\n (internationalization.locales ?? localeList).includes(locale)\n ) {\n return locale;\n } else if (\n locale?.includes('-') &&\n (internationalization.locales ?? localeList).includes(\n locale.split('-')[0] as Locales\n )\n ) {\n return locale.split('-')[0] as Locales;\n }\n }\n }\n\n return internationalization.defaultLocale;\n};\n\n/**\n * Core language detector function\n * const detectedLanguages = detectLanguage(['LanguageDetector.Cookie', 'LanguageDetector.LocalStorage'], { lookupCookie: 'myCookie' });\n */\nexport const getBrowserLocale = (\n userOptions: LanguageDetectorOptions | undefined = {}\n): Locales => {\n const options = { ...getDefaultsOptions(), ...userOptions };\n\n const locales = detectLanguage(options.order ?? [], options);\n\n return getFirstAvailableLocale(locales, options.order ?? []);\n};\n"],"mappings":"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","names":["LanguageDetector"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { IntlayerClientContext as IntlayerClient, IntlayerClientProvider, IntlayerClientProviderProps, useIntlayerContext } from './IntlayerClientProvider.mjs';
|
|
2
2
|
export { useIntlayer } from './useIntlayer.mjs';
|
|
3
|
+
export { useLocaleBase } from './useLocaleBase.mjs';
|
|
3
4
|
export { useLocale } from './useLocale.mjs';
|
|
4
5
|
export { useTraduction } from './useTraduction.mjs';
|
|
5
6
|
export { localeCookie, setLocaleCookie, useLocaleCookie } from './useLocaleCookie.mjs';
|
|
7
|
+
export { getBrowserLocale } from './getBrowserLocale.mjs';
|
|
6
8
|
import 'react';
|
|
7
9
|
import '@intlayer/config/client';
|
|
8
10
|
import '../useIntlayerBase.mjs';
|