next-intlayer 3.5.2 → 3.5.4

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/README.md CHANGED
@@ -36,7 +36,7 @@
36
36
  ```tsx
37
37
  // ./ClientComponent/index.content.ts
38
38
 
39
- import { DeclarationContent, t } from "intlayer";
39
+ import { type DeclarationContent, t } from "intlayer";
40
40
 
41
41
  const clientComponentContent = {
42
42
  key: "client-component",
@@ -118,7 +118,7 @@ const config: IntlayerConfig = {
118
118
  export default config;
119
119
  ```
120
120
 
121
- To see all available parameters, refer to the [configuration documentation here](https://github.com/aymericzip/intlayer/blob/main/docs/docs/configuration_en.md).
121
+ To see all available parameters, refer to the [configuration documentation here](https://github.com/aymericzip/intlayer/blob/main/docs/docs/configuration.md).
122
122
 
123
123
  ## Step 3: Integrate Intlayer in Your Next.js Configuration
124
124
 
@@ -220,7 +220,7 @@ const pageContent = {
220
220
  export default pageContent;
221
221
  ```
222
222
 
223
- [See how to declare your Intlayer declaration files](https://github.com/aymericzip/intlayer/blob/main/docs/docs/content_declaration/get_started_en.md).
223
+ [See how to declare your Intlayer declaration files](https://github.com/aymericzip/intlayer/blob/main/docs/docs/content_declaration/get_started.md
224
224
 
225
225
  ## Step 7: Utilize Content in Your Code
226
226
 
@@ -21,76 +21,30 @@ __export(useLocale_exports, {
21
21
  useLocale: () => useLocale
22
22
  });
23
23
  module.exports = __toCommonJS(useLocale_exports);
24
- var import_client = require("@intlayer/config/client");
24
+ var import_core = require("@intlayer/core");
25
25
  var import_navigation = require("next/navigation.js");
26
26
  var import_react = require("react");
27
27
  var import_react_intlayer = require("react-intlayer");
28
28
  const useLocale = () => {
29
- const {
30
- /**
31
- * Prefix default prefix the default locale to the path as other locales.
32
- *
33
- * Example with prefixDefault = true and defaultLocale = 'en':
34
- * path = /en/dashboard or /fr/dashboard
35
- *
36
- * Example with prefixDefault = false and defaultLocale = 'en':
37
- * path = /dashboard or /fr/dashboard
38
- *
39
- */
40
- prefixDefault
41
- } = (0, import_client.getConfiguration)().middleware;
42
- const { setLocaleCookie } = (0, import_react_intlayer.useLocaleCookie)();
43
- const reactLocaleHook = (0, import_react_intlayer.useLocaleBase)();
44
29
  const { push, refresh } = (0, import_navigation.useRouter)();
45
30
  const pathname = (0, import_navigation.usePathname)();
46
- const {
47
- defaultLocale,
48
- availableLocales,
49
- locale: currentLocale,
50
- setLocale: setLocaleState
51
- } = reactLocaleHook;
52
- const getPathWithoutLocale = () => {
53
- if (
54
- // If the locale is the default one and the prefixDefault is false, we don't need to add the locale to the path
55
- !prefixDefault && currentLocale.toString() === defaultLocale.toString()
56
- ) {
57
- return pathname;
58
- }
59
- const slicedPath = pathname.slice(`/${currentLocale}`.length);
60
- if (slicedPath) {
61
- return slicedPath;
62
- }
63
- return "/";
64
- };
65
- const pathWithoutLocale = getPathWithoutLocale();
66
- const setLocale = (0, import_react.useCallback)(
31
+ const pathWithoutLocale = (0, import_react.useMemo)(
32
+ () => (0, import_core.getPathWithoutLocale)(pathname),
33
+ [pathname]
34
+ );
35
+ const redirectionFunction = (0, import_react.useCallback)(
67
36
  (locale) => {
68
- if (!availableLocales.includes(locale)) {
69
- console.error(`Locale ${locale} is not available`);
70
- return;
71
- }
72
- setLocaleCookie(locale);
73
- setLocaleState(locale);
74
- if (!prefixDefault && locale.toString() === defaultLocale.toString()) {
75
- push(pathWithoutLocale);
76
- } else {
77
- push(`/${locale}${pathWithoutLocale}`);
78
- }
37
+ const pathWithLocale = (0, import_core.getLocalizedUrl)(pathWithoutLocale, locale);
38
+ push(pathWithLocale);
79
39
  return refresh();
80
40
  },
81
- [
82
- currentLocale,
83
- availableLocales,
84
- setLocaleCookie,
85
- setLocaleState,
86
- prefixDefault,
87
- defaultLocale,
88
- pathWithoutLocale
89
- ]
41
+ [refresh, pathWithoutLocale]
90
42
  );
43
+ const reactLocaleHook = (0, import_react_intlayer.useLocale)({
44
+ onLocaleChange: redirectionFunction
45
+ });
91
46
  return {
92
47
  ...reactLocaleHook,
93
- setLocale,
94
48
  pathWithoutLocale
95
49
  };
96
50
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useCallback } from 'react';\nimport { useLocaleCookie, useLocaleBase } from 'react-intlayer';\n\nexport const useLocale = () => {\n const {\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n */\n prefixDefault,\n } = getConfiguration().middleware;\n const { setLocaleCookie } = useLocaleCookie();\n const reactLocaleHook = useLocaleBase();\n const { push, refresh } = useRouter();\n const pathname = usePathname();\n\n const {\n defaultLocale,\n availableLocales,\n locale: currentLocale,\n setLocale: setLocaleState,\n } = reactLocaleHook;\n\n const getPathWithoutLocale = () => {\n if (\n // If the locale is the default one and the prefixDefault is false, we don't need to add the locale to the path\n !prefixDefault &&\n currentLocale.toString() === defaultLocale.toString()\n ) {\n return pathname;\n }\n\n const slicedPath = pathname.slice(`/${currentLocale}`.length);\n\n // If the path without locale is not empty, we return it\n if (slicedPath) {\n return slicedPath;\n }\n\n // If the path without locale is empty, we return the root path\n return '/';\n };\n\n const pathWithoutLocale = getPathWithoutLocale();\n\n const setLocale = useCallback(\n (locale: Locales) => {\n if (!availableLocales.includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleCookie(locale);\n setLocaleState(locale);\n\n if (!prefixDefault && locale.toString() === defaultLocale.toString()) {\n push(pathWithoutLocale);\n } else {\n push(`/${locale}${pathWithoutLocale}`);\n }\n\n return refresh();\n },\n [\n currentLocale,\n availableLocales,\n setLocaleCookie,\n setLocaleState,\n prefixDefault,\n defaultLocale,\n pathWithoutLocale,\n ]\n );\n\n return {\n ...reactLocaleHook,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MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { type Locales } from '@intlayer/config/client';\nimport { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\n\nexport const useLocale = () => {\n const { push, refresh } = useRouter();\n const pathname = usePathname();\n const pathWithoutLocale = useMemo(\n () => getPathWithoutLocale(pathname),\n [pathname]\n );\n\n const redirectionFunction = useCallback(\n (locale: Locales) => {\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n push(pathWithLocale);\n\n return refresh();\n },\n [refresh, pathWithoutLocale]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAsD;AACtD,wBAAuC;AACvC,mBAAqC;AACrC,4BAA4C;AAErC,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,MAAM,QAAQ,QAAI,6BAAU;AACpC,QAAM,eAAW,+BAAY;AAC7B,QAAM,wBAAoB;AAAA,IACxB,UAAM,kCAAqB,QAAQ;AAAA,IACnC,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,0BAAsB;AAAA,IAC1B,CAAC,WAAoB;AACnB,YAAM,qBAAiB,6BAAgB,mBAAmB,MAAM;AAEhE,WAAK,cAAc;AAEnB,aAAO,QAAQ;AAAA,IACjB;AAAA,IACA,CAAC,SAAS,iBAAiB;AAAA,EAC7B;AAEA,QAAM,sBAAkB,sBAAAA,WAAe;AAAA,IACrC,gBAAgB;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;","names":["useLocaleReact"]}
@@ -21,75 +21,29 @@ __export(useLocalePageRouter_exports, {
21
21
  useLocalePageRouter: () => useLocalePageRouter
22
22
  });
23
23
  module.exports = __toCommonJS(useLocalePageRouter_exports);
24
- var import_client = require("@intlayer/config/client");
24
+ var import_intlayer = require("intlayer");
25
25
  var import_router = require("next/router.js");
26
26
  var import_react = require("react");
27
27
  var import_react_intlayer = require("react-intlayer");
28
28
  const useLocalePageRouter = () => {
29
- const {
30
- /**
31
- * Prefix default prefix the default locale to the path as other locales.
32
- *
33
- * Example with prefixDefault = true and defaultLocale = 'en':
34
- * path = /en/dashboard or /fr/dashboard
35
- *
36
- * Example with prefixDefault = false and defaultLocale = 'en':
37
- * path = /dashboard or /fr/dashboard
38
- *
39
- */
40
- prefixDefault
41
- } = (0, import_client.getConfiguration)().middleware;
42
- const { setLocaleCookie } = (0, import_react_intlayer.useLocaleCookie)();
43
- const reactLocaleHook = (0, import_react_intlayer.useLocaleBase)();
44
29
  const { push, pathname, reload } = (0, import_router.useRouter)();
45
- const {
46
- defaultLocale,
47
- availableLocales,
48
- locale: currentLocale,
49
- setLocale: setLocaleState
50
- } = reactLocaleHook;
51
- const getPathWithoutLocale = () => {
52
- if (
53
- // If the locale is the default one and the prefixDefault is false, we don't need to add the locale to the path
54
- !prefixDefault && currentLocale.toString() === defaultLocale.toString()
55
- ) {
56
- return pathname;
57
- }
58
- const slicedPath = pathname.slice(`/${currentLocale}`.length);
59
- if (slicedPath) {
60
- return slicedPath;
61
- }
62
- return "/";
63
- };
64
- const pathWithoutLocale = getPathWithoutLocale();
65
- const setLocale = (0, import_react.useCallback)(
30
+ const pathWithoutLocale = (0, import_react.useMemo)(
31
+ () => (0, import_intlayer.getPathWithoutLocale)(pathname),
32
+ [pathname]
33
+ );
34
+ const redirectionFunction = (0, import_react.useCallback)(
66
35
  (locale) => {
67
- if (!availableLocales.includes(locale)) {
68
- console.error(`Locale ${locale} is not available`);
69
- return;
70
- }
71
- setLocaleCookie(locale);
72
- setLocaleState(locale);
73
- if (!prefixDefault && locale.toString() === defaultLocale.toString()) {
74
- push(pathWithoutLocale);
75
- } else {
76
- push(`/${locale}${pathWithoutLocale}`);
77
- }
36
+ const pathWithLocale = (0, import_intlayer.getLocalizedUrl)(pathWithoutLocale, locale);
37
+ push(pathWithLocale);
78
38
  return reload();
79
39
  },
80
- [
81
- currentLocale,
82
- availableLocales,
83
- setLocaleCookie,
84
- setLocaleState,
85
- prefixDefault,
86
- defaultLocale,
87
- pathWithoutLocale
88
- ]
40
+ [reload, pathWithoutLocale]
89
41
  );
42
+ const reactLocaleHook = (0, import_react_intlayer.useLocale)({
43
+ onLocaleChange: redirectionFunction
44
+ });
90
45
  return {
91
46
  ...reactLocaleHook,
92
- setLocale,
93
47
  pathWithoutLocale
94
48
  };
95
49
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { useRouter } from 'next/router.js';\nimport { useCallback } from 'react';\nimport { useLocaleCookie, useLocaleBase } from 'react-intlayer';\n\nexport const useLocalePageRouter = () => {\n const {\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n */\n prefixDefault,\n } = getConfiguration().middleware;\n const { setLocaleCookie } = useLocaleCookie();\n const reactLocaleHook = useLocaleBase();\n const { push, pathname, reload } = useRouter();\n\n const {\n defaultLocale,\n availableLocales,\n locale: currentLocale,\n setLocale: setLocaleState,\n } = reactLocaleHook;\n\n const getPathWithoutLocale = () => {\n if (\n // If the locale is the default one and the prefixDefault is false, we don't need to add the locale to the path\n !prefixDefault &&\n currentLocale.toString() === defaultLocale.toString()\n ) {\n return pathname;\n }\n\n const slicedPath = pathname.slice(`/${currentLocale}`.length);\n\n // If the path without locale is not empty, we return it\n if (slicedPath) {\n return slicedPath;\n }\n\n // If the path without locale is empty, we return the root path\n return '/';\n };\n\n const pathWithoutLocale = getPathWithoutLocale();\n\n const setLocale = useCallback(\n (locale: Locales) => {\n if (!availableLocales.includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleCookie(locale);\n setLocaleState(locale);\n\n if (!prefixDefault && locale.toString() === defaultLocale.toString()) {\n push(pathWithoutLocale);\n } else {\n push(`/${locale}${pathWithoutLocale}`);\n }\n\n return reload();\n },\n [\n currentLocale,\n availableLocales,\n setLocaleCookie,\n setLocaleState,\n prefixDefault,\n defaultLocale,\n pathWithoutLocale,\n ]\n );\n\n return {\n ...reactLocaleHook,\n setLocale,\n pathWithoutLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+C;AAC/C,oBAA0B;AAC1B,mBAA4B;AAC5B,4BAA+C;AAExC,MAAM,sBAAsB,MAAM;AACvC,QAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWJ;AAAA,EACF,QAAI,gCAAiB,EAAE;AACvB,QAAM,EAAE,gBAAgB,QAAI,uCAAgB;AAC5C,QAAM,sBAAkB,qCAAc;AACtC,QAAM,EAAE,MAAM,UAAU,OAAO,QAAI,yBAAU;AAE7C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,EACb,IAAI;AAEJ,QAAM,uBAAuB,MAAM;AACjC;AAAA;AAAA,MAEE,CAAC,iBACD,cAAc,SAAS,MAAM,cAAc,SAAS;AAAA,MACpD;AACA,aAAO;AAAA,IACT;AAEA,UAAM,aAAa,SAAS,MAAM,IAAI,aAAa,GAAG,MAAM;AAG5D,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAGA,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,qBAAqB;AAE/C,QAAM,gBAAY;AAAA,IAChB,CAAC,WAAoB;AACnB,UAAI,CAAC,iBAAiB,SAAS,MAAM,GAAG;AACtC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,sBAAgB,MAAM;AACtB,qBAAe,MAAM;AAErB,UAAI,CAAC,iBAAiB,OAAO,SAAS,MAAM,cAAc,SAAS,GAAG;AACpE,aAAK,iBAAiB;AAAA,MACxB,OAAO;AACL,aAAK,IAAI,MAAM,GAAG,iBAAiB,EAAE;AAAA,MACvC;AAEA,aAAO,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["import { type Locales } from '@intlayer/config/client';\nimport { getLocalizedUrl, getPathWithoutLocale } from 'intlayer';\nimport { useRouter } from 'next/router.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\n\nexport const useLocalePageRouter = () => {\n const { push, pathname, reload } = useRouter();\n const pathWithoutLocale = useMemo(\n () => getPathWithoutLocale(pathname),\n [pathname]\n );\n\n const redirectionFunction = useCallback(\n (locale: Locales) => {\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n push(pathWithLocale);\n\n return reload();\n },\n [reload, pathWithoutLocale]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAsD;AACtD,oBAA0B;AAC1B,mBAAqC;AACrC,4BAA4C;AAErC,MAAM,sBAAsB,MAAM;AACvC,QAAM,EAAE,MAAM,UAAU,OAAO,QAAI,yBAAU;AAC7C,QAAM,wBAAoB;AAAA,IACxB,UAAM,sCAAqB,QAAQ;AAAA,IACnC,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,0BAAsB;AAAA,IAC1B,CAAC,WAAoB;AACnB,YAAM,qBAAiB,iCAAgB,mBAAmB,MAAM;AAEhE,WAAK,cAAc;AAEnB,aAAO,OAAO;AAAA,IAChB;AAAA,IACA,CAAC,QAAQ,iBAAiB;AAAA,EAC5B;AAEA,QAAM,sBAAkB,sBAAAA,WAAe;AAAA,IACrC,gBAAgB;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;","names":["useLocaleReact"]}
@@ -21,6 +21,8 @@ __export(src_exports, {
21
21
  IntlayerClientContext: () => import_react_intlayer.IntlayerClientContext,
22
22
  IntlayerClientProvider: () => import_client.IntlayerClientProvider,
23
23
  generateStaticParams: () => import_generateStaticParams.generateStaticParams,
24
+ getDictionary: () => import_react_intlayer.getDictionary,
25
+ getIntlayer: () => import_react_intlayer.getIntlayer,
24
26
  getTranslation: () => import_react_intlayer.getTranslation,
25
27
  t: () => import_react_intlayer.t,
26
28
  useDictionary: () => import_react_intlayer.useDictionary,
@@ -39,6 +41,8 @@ var import_client = require('./client/index.cjs');
39
41
  IntlayerClientContext,
40
42
  IntlayerClientProvider,
41
43
  generateStaticParams,
44
+ getDictionary,
45
+ getIntlayer,
42
46
  getTranslation,
43
47
  t,
44
48
  useDictionary,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getTranslation,\n IntlayerClientContext,\n useIntlayer,\n useTraduction,\n useDictionary,\n useLocaleCookie,\n type IntlayerNode,\n t,\n} from 'react-intlayer';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14PageIntlayer,\n Next15PageIntlayer,\n NextPageIntlayer,\n Next14LayoutIntlayer,\n Next15LayoutIntlayer,\n NextLayoutIntlayer,\n} from './types/index';\nexport {\n useLocale,\n useLocalePageRouter,\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BASO;AACP,kCAAqC;AAWrC,oBAKO;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getTranslation,\n IntlayerClientContext,\n getIntlayer,\n useIntlayer,\n useTraduction,\n getDictionary,\n useDictionary,\n useLocaleCookie,\n type IntlayerNode,\n t,\n} from 'react-intlayer';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14PageIntlayer,\n Next15PageIntlayer,\n NextPageIntlayer,\n Next14LayoutIntlayer,\n Next15LayoutIntlayer,\n NextLayoutIntlayer,\n} from './types/index';\nexport {\n useLocale,\n useLocalePageRouter,\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAWO;AACP,kCAAqC;AAWrC,oBAKO;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/NextPage.ts"],"sourcesContent":["import type { Locales } from 'intlayer';\nimport type { NextPage } from 'next';\nimport type { PropsWithChildren, ReactNode } from 'react';\n\nexport type LocalParams<T = undefined> = {\n params: { locale: Locales } & T;\n};\n\nexport type LocalPromiseParams<T = undefined> = {\n params: Promise<{ locale: Locales } & T>;\n};\n\nexport type Next14PageIntlayer<T = undefined> = NextPage<LocalParams<T>>;\nexport type Next15PageIntlayer<T = undefined> = (\n props: LocalPromiseParams<T>\n) => ReactNode | Promise<ReactNode>;\nexport type NextPageIntlayer<T = undefined> = Next15PageIntlayer<T>;\n\nexport type Next14LayoutIntlayer<T = undefined> = NextPage<\n PropsWithChildren<LocalParams<T>>\n>;\nexport type Next15LayoutIntlayer<T = undefined> = (\n props: PropsWithChildren<LocalPromiseParams<T>>\n) => ReactNode | Promise<ReactNode>;\nexport type NextLayoutIntlayer<T = undefined> = Next15LayoutIntlayer<T>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/NextPage.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { NextPage } from 'next';\nimport type { PropsWithChildren, ReactNode } from 'react';\n\nexport type LocalParams<T = {}> = {\n params: { locale: Locales } & T;\n};\n\nexport type LocalPromiseParams<T = {}> = {\n params: Promise<{ locale: Locales } & T>;\n};\n\nexport type Next14PageIntlayer<T = {}> = NextPage<LocalParams<T>>;\nexport type Next15PageIntlayer<T = {}> = (\n props: LocalPromiseParams<T>\n) => ReactNode | Promise<ReactNode>;\nexport type NextPageIntlayer<T = {}> = Next15PageIntlayer<T>;\n\nexport type Next14LayoutIntlayer<T = {}> = NextPage<\n PropsWithChildren<LocalParams<T>>\n>;\nexport type Next15LayoutIntlayer<T = {}> = (\n props: PropsWithChildren<LocalPromiseParams<T>>\n) => ReactNode | Promise<ReactNode>;\nexport type NextLayoutIntlayer<T = {}> = Next15LayoutIntlayer<T>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,73 +1,27 @@
1
- import { getConfiguration } from "@intlayer/config/client";
1
+ import { getLocalizedUrl, getPathWithoutLocale } from "@intlayer/core";
2
2
  import { usePathname, useRouter } from "next/navigation.js";
3
- import { useCallback } from "react";
4
- import { useLocaleCookie, useLocaleBase } from "react-intlayer";
3
+ import { useCallback, useMemo } from "react";
4
+ import { useLocale as useLocaleReact } from "react-intlayer";
5
5
  const useLocale = () => {
6
- const {
7
- /**
8
- * Prefix default prefix the default locale to the path as other locales.
9
- *
10
- * Example with prefixDefault = true and defaultLocale = 'en':
11
- * path = /en/dashboard or /fr/dashboard
12
- *
13
- * Example with prefixDefault = false and defaultLocale = 'en':
14
- * path = /dashboard or /fr/dashboard
15
- *
16
- */
17
- prefixDefault
18
- } = getConfiguration().middleware;
19
- const { setLocaleCookie } = useLocaleCookie();
20
- const reactLocaleHook = useLocaleBase();
21
6
  const { push, refresh } = useRouter();
22
7
  const pathname = usePathname();
23
- const {
24
- defaultLocale,
25
- availableLocales,
26
- locale: currentLocale,
27
- setLocale: setLocaleState
28
- } = reactLocaleHook;
29
- const getPathWithoutLocale = () => {
30
- if (
31
- // If the locale is the default one and the prefixDefault is false, we don't need to add the locale to the path
32
- !prefixDefault && currentLocale.toString() === defaultLocale.toString()
33
- ) {
34
- return pathname;
35
- }
36
- const slicedPath = pathname.slice(`/${currentLocale}`.length);
37
- if (slicedPath) {
38
- return slicedPath;
39
- }
40
- return "/";
41
- };
42
- const pathWithoutLocale = getPathWithoutLocale();
43
- const setLocale = useCallback(
8
+ const pathWithoutLocale = useMemo(
9
+ () => getPathWithoutLocale(pathname),
10
+ [pathname]
11
+ );
12
+ const redirectionFunction = useCallback(
44
13
  (locale) => {
45
- if (!availableLocales.includes(locale)) {
46
- console.error(`Locale ${locale} is not available`);
47
- return;
48
- }
49
- setLocaleCookie(locale);
50
- setLocaleState(locale);
51
- if (!prefixDefault && locale.toString() === defaultLocale.toString()) {
52
- push(pathWithoutLocale);
53
- } else {
54
- push(`/${locale}${pathWithoutLocale}`);
55
- }
14
+ const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);
15
+ push(pathWithLocale);
56
16
  return refresh();
57
17
  },
58
- [
59
- currentLocale,
60
- availableLocales,
61
- setLocaleCookie,
62
- setLocaleState,
63
- prefixDefault,
64
- defaultLocale,
65
- pathWithoutLocale
66
- ]
18
+ [refresh, pathWithoutLocale]
67
19
  );
20
+ const reactLocaleHook = useLocaleReact({
21
+ onLocaleChange: redirectionFunction
22
+ });
68
23
  return {
69
24
  ...reactLocaleHook,
70
- setLocale,
71
25
  pathWithoutLocale
72
26
  };
73
27
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useCallback } from 'react';\nimport { useLocaleCookie, useLocaleBase } from 'react-intlayer';\n\nexport const useLocale = () => {\n const {\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n */\n prefixDefault,\n } = getConfiguration().middleware;\n const { setLocaleCookie } = useLocaleCookie();\n const reactLocaleHook = useLocaleBase();\n const { push, refresh } = useRouter();\n const pathname = usePathname();\n\n const {\n defaultLocale,\n availableLocales,\n locale: currentLocale,\n setLocale: setLocaleState,\n } = reactLocaleHook;\n\n const getPathWithoutLocale = () => {\n if (\n // If the locale is the default one and the prefixDefault is false, we don't need to add the locale to the path\n !prefixDefault &&\n currentLocale.toString() === defaultLocale.toString()\n ) {\n return pathname;\n }\n\n const slicedPath = pathname.slice(`/${currentLocale}`.length);\n\n // If the path without locale is not empty, we return it\n if (slicedPath) {\n return slicedPath;\n }\n\n // If the path without locale is empty, we return the root path\n return '/';\n };\n\n const pathWithoutLocale = getPathWithoutLocale();\n\n const setLocale = useCallback(\n (locale: Locales) => {\n if (!availableLocales.includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleCookie(locale);\n setLocaleState(locale);\n\n if (!prefixDefault && locale.toString() === defaultLocale.toString()) {\n push(pathWithoutLocale);\n } else {\n push(`/${locale}${pathWithoutLocale}`);\n }\n\n return refresh();\n },\n [\n currentLocale,\n availableLocales,\n setLocaleCookie,\n setLocaleState,\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;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { type Locales } from '@intlayer/config/client';\nimport { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\n\nexport const useLocale = () => {\n const { push, refresh } = useRouter();\n const pathname = usePathname();\n const pathWithoutLocale = useMemo(\n () => getPathWithoutLocale(pathname),\n [pathname]\n );\n\n const redirectionFunction = useCallback(\n (locale: Locales) => {\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n push(pathWithLocale);\n\n return refresh();\n },\n [refresh, pathWithoutLocale]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":"AACA,SAAS,iBAAiB,4BAA4B;AACtD,SAAS,aAAa,iBAAiB;AACvC,SAAS,aAAa,eAAe;AACrC,SAAS,aAAa,sBAAsB;AAErC,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,MAAM,QAAQ,IAAI,UAAU;AACpC,QAAM,WAAW,YAAY;AAC7B,QAAM,oBAAoB;AAAA,IACxB,MAAM,qBAAqB,QAAQ;AAAA,IACnC,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,sBAAsB;AAAA,IAC1B,CAAC,WAAoB;AACnB,YAAM,iBAAiB,gBAAgB,mBAAmB,MAAM;AAEhE,WAAK,cAAc;AAEnB,aAAO,QAAQ;AAAA,IACjB;AAAA,IACA,CAAC,SAAS,iBAAiB;AAAA,EAC7B;AAEA,QAAM,kBAAkB,eAAe;AAAA,IACrC,gBAAgB;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -1,72 +1,26 @@
1
- import { getConfiguration } from "@intlayer/config/client";
1
+ import { getLocalizedUrl, getPathWithoutLocale } from "intlayer";
2
2
  import { useRouter } from "next/router.js";
3
- import { useCallback } from "react";
4
- import { useLocaleCookie, useLocaleBase } from "react-intlayer";
3
+ import { useCallback, useMemo } from "react";
4
+ import { useLocale as useLocaleReact } from "react-intlayer";
5
5
  const useLocalePageRouter = () => {
6
- const {
7
- /**
8
- * Prefix default prefix the default locale to the path as other locales.
9
- *
10
- * Example with prefixDefault = true and defaultLocale = 'en':
11
- * path = /en/dashboard or /fr/dashboard
12
- *
13
- * Example with prefixDefault = false and defaultLocale = 'en':
14
- * path = /dashboard or /fr/dashboard
15
- *
16
- */
17
- prefixDefault
18
- } = getConfiguration().middleware;
19
- const { setLocaleCookie } = useLocaleCookie();
20
- const reactLocaleHook = useLocaleBase();
21
6
  const { push, pathname, reload } = useRouter();
22
- const {
23
- defaultLocale,
24
- availableLocales,
25
- locale: currentLocale,
26
- setLocale: setLocaleState
27
- } = reactLocaleHook;
28
- const getPathWithoutLocale = () => {
29
- if (
30
- // If the locale is the default one and the prefixDefault is false, we don't need to add the locale to the path
31
- !prefixDefault && currentLocale.toString() === defaultLocale.toString()
32
- ) {
33
- return pathname;
34
- }
35
- const slicedPath = pathname.slice(`/${currentLocale}`.length);
36
- if (slicedPath) {
37
- return slicedPath;
38
- }
39
- return "/";
40
- };
41
- const pathWithoutLocale = getPathWithoutLocale();
42
- const setLocale = useCallback(
7
+ const pathWithoutLocale = useMemo(
8
+ () => getPathWithoutLocale(pathname),
9
+ [pathname]
10
+ );
11
+ const redirectionFunction = useCallback(
43
12
  (locale) => {
44
- if (!availableLocales.includes(locale)) {
45
- console.error(`Locale ${locale} is not available`);
46
- return;
47
- }
48
- setLocaleCookie(locale);
49
- setLocaleState(locale);
50
- if (!prefixDefault && locale.toString() === defaultLocale.toString()) {
51
- push(pathWithoutLocale);
52
- } else {
53
- push(`/${locale}${pathWithoutLocale}`);
54
- }
13
+ const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);
14
+ push(pathWithLocale);
55
15
  return reload();
56
16
  },
57
- [
58
- currentLocale,
59
- availableLocales,
60
- setLocaleCookie,
61
- setLocaleState,
62
- prefixDefault,
63
- defaultLocale,
64
- pathWithoutLocale
65
- ]
17
+ [reload, pathWithoutLocale]
66
18
  );
19
+ const reactLocaleHook = useLocaleReact({
20
+ onLocaleChange: redirectionFunction
21
+ });
67
22
  return {
68
23
  ...reactLocaleHook,
69
- setLocale,
70
24
  pathWithoutLocale
71
25
  };
72
26
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["import { type Locales, getConfiguration } from '@intlayer/config/client';\nimport { useRouter } from 'next/router.js';\nimport { useCallback } from 'react';\nimport { useLocaleCookie, useLocaleBase } from 'react-intlayer';\n\nexport const useLocalePageRouter = () => {\n const {\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n */\n prefixDefault,\n } = getConfiguration().middleware;\n const { setLocaleCookie } = useLocaleCookie();\n const reactLocaleHook = useLocaleBase();\n const { push, pathname, reload } = useRouter();\n\n const {\n defaultLocale,\n availableLocales,\n locale: currentLocale,\n setLocale: setLocaleState,\n } = reactLocaleHook;\n\n const getPathWithoutLocale = () => {\n if (\n // If the locale is the default one and the prefixDefault is false, we don't need to add the locale to the path\n !prefixDefault &&\n currentLocale.toString() === defaultLocale.toString()\n ) {\n return pathname;\n }\n\n const slicedPath = pathname.slice(`/${currentLocale}`.length);\n\n // If the path without locale is not empty, we return it\n if (slicedPath) {\n return slicedPath;\n }\n\n // If the path without locale is empty, we return the root path\n return '/';\n };\n\n const pathWithoutLocale = getPathWithoutLocale();\n\n const setLocale = useCallback(\n (locale: Locales) => {\n if (!availableLocales.includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleCookie(locale);\n setLocaleState(locale);\n\n if (!prefixDefault && locale.toString() === defaultLocale.toString()) {\n push(pathWithoutLocale);\n } else {\n push(`/${locale}${pathWithoutLocale}`);\n }\n\n return reload();\n },\n [\n currentLocale,\n availableLocales,\n setLocaleCookie,\n setLocaleState,\n prefixDefault,\n defaultLocale,\n pathWithoutLocale,\n ]\n );\n\n return {\n ...reactLocaleHook,\n setLocale,\n pathWithoutLocale,\n };\n};\n"],"mappings":"AAAA,SAAuB,wBAAwB;AAC/C,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB,qBAAqB;AAExC,MAAM,sBAAsB,MAAM;AACvC,QAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWJ;AAAA,EACF,IAAI,iBAAiB,EAAE;AACvB,QAAM,EAAE,gBAAgB,IAAI,gBAAgB;AAC5C,QAAM,kBAAkB,cAAc;AACtC,QAAM,EAAE,MAAM,UAAU,OAAO,IAAI,UAAU;AAE7C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,EACb,IAAI;AAEJ,QAAM,uBAAuB,MAAM;AACjC;AAAA;AAAA,MAEE,CAAC,iBACD,cAAc,SAAS,MAAM,cAAc,SAAS;AAAA,MACpD;AACA,aAAO;AAAA,IACT;AAEA,UAAM,aAAa,SAAS,MAAM,IAAI,aAAa,GAAG,MAAM;AAG5D,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAGA,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,qBAAqB;AAE/C,QAAM,YAAY;AAAA,IAChB,CAAC,WAAoB;AACnB,UAAI,CAAC,iBAAiB,SAAS,MAAM,GAAG;AACtC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,sBAAgB,MAAM;AACtB,qBAAe,MAAM;AAErB,UAAI,CAAC,iBAAiB,OAAO,SAAS,MAAM,cAAc,SAAS,GAAG;AACpE,aAAK,iBAAiB;AAAA,MACxB,OAAO;AACL,aAAK,IAAI,MAAM,GAAG,iBAAiB,EAAE;AAAA,MACvC;AAEA,aAAO,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["import { type Locales } from '@intlayer/config/client';\nimport { getLocalizedUrl, getPathWithoutLocale } from 'intlayer';\nimport { useRouter } from 'next/router.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\n\nexport const useLocalePageRouter = () => {\n const { push, pathname, reload } = useRouter();\n const pathWithoutLocale = useMemo(\n () => getPathWithoutLocale(pathname),\n [pathname]\n );\n\n const redirectionFunction = useCallback(\n (locale: Locales) => {\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n push(pathWithLocale);\n\n return reload();\n },\n [reload, pathWithoutLocale]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":"AACA,SAAS,iBAAiB,4BAA4B;AACtD,SAAS,iBAAiB;AAC1B,SAAS,aAAa,eAAe;AACrC,SAAS,aAAa,sBAAsB;AAErC,MAAM,sBAAsB,MAAM;AACvC,QAAM,EAAE,MAAM,UAAU,OAAO,IAAI,UAAU;AAC7C,QAAM,oBAAoB;AAAA,IACxB,MAAM,qBAAqB,QAAQ;AAAA,IACnC,CAAC,QAAQ;AAAA,EACX;AAEA,QAAM,sBAAsB;AAAA,IAC1B,CAAC,WAAoB;AACnB,YAAM,iBAAiB,gBAAgB,mBAAmB,MAAM;AAEhE,WAAK,cAAc;AAEnB,aAAO,OAAO;AAAA,IAChB;AAAA,IACA,CAAC,QAAQ,iBAAiB;AAAA,EAC5B;AAEA,QAAM,kBAAkB,eAAe;AAAA,IACrC,gBAAgB;AAAA,EAClB,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  getTranslation,
3
3
  IntlayerClientContext,
4
+ getIntlayer,
4
5
  useIntlayer,
5
6
  useTraduction,
7
+ getDictionary,
6
8
  useDictionary,
7
9
  useLocaleCookie,
8
10
  t
@@ -17,6 +19,8 @@ export {
17
19
  IntlayerClientContext,
18
20
  IntlayerClientProvider,
19
21
  generateStaticParams,
22
+ getDictionary,
23
+ getIntlayer,
20
24
  getTranslation,
21
25
  t,
22
26
  useDictionary,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getTranslation,\n IntlayerClientContext,\n useIntlayer,\n useTraduction,\n useDictionary,\n useLocaleCookie,\n type IntlayerNode,\n t,\n} from 'react-intlayer';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14PageIntlayer,\n Next15PageIntlayer,\n NextPageIntlayer,\n Next14LayoutIntlayer,\n Next15LayoutIntlayer,\n NextLayoutIntlayer,\n} from './types/index';\nexport {\n useLocale,\n useLocalePageRouter,\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/index';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,4BAA4B;AAWrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getTranslation,\n IntlayerClientContext,\n getIntlayer,\n useIntlayer,\n useTraduction,\n getDictionary,\n useDictionary,\n useLocaleCookie,\n type IntlayerNode,\n t,\n} from 'react-intlayer';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14PageIntlayer,\n Next15PageIntlayer,\n NextPageIntlayer,\n Next14LayoutIntlayer,\n Next15LayoutIntlayer,\n NextLayoutIntlayer,\n} from './types/index';\nexport {\n useLocale,\n useLocalePageRouter,\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './client/index';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,4BAA4B;AAWrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import { type Locales } from '@intlayer/config/client';
2
2
  export declare const useLocale: () => {
3
- setLocale: (locale: Locales) => void;
4
3
  pathWithoutLocale: string;
5
- locale: import("intlayer").Locales;
6
- defaultLocale: import("intlayer").Locales;
7
- availableLocales: import("intlayer").Locales[];
8
- localeList: import("intlayer").Locales[];
4
+ locale: Locales;
5
+ defaultLocale: Locales;
6
+ availableLocales: Locales[];
7
+ localeList: Locales[];
8
+ setLocale: (locale: Locales) => void;
9
9
  };
10
10
  //# sourceMappingURL=useLocale.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/useLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AAKzE,eAAO,MAAM,SAAS;wBAiDT,OAAO;;mBApDP,UAAU;0BACA,UAAU;6BAE1B,UAAU;uBAGZ,UAAO;CA+EX,CAAC"}
1
+ {"version":3,"file":"useLocale.d.ts","sourceRoot":"","sources":["../../../src/client/useLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAMvD,eAAO,MAAM,SAAS;;;;;;;CA2BrB,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { type Locales } from '@intlayer/config/client';
2
2
  export declare const useLocalePageRouter: () => {
3
- setLocale: (locale: Locales) => void;
4
3
  pathWithoutLocale: string;
5
- locale: import("intlayer").Locales;
6
- defaultLocale: import("intlayer").Locales;
7
- availableLocales: import("intlayer").Locales[];
8
- localeList: import("intlayer").Locales[];
4
+ locale: Locales;
5
+ defaultLocale: Locales;
6
+ availableLocales: Locales[];
7
+ localeList: Locales[];
8
+ setLocale: (locale: Locales) => void;
9
9
  };
10
10
  //# sourceMappingURL=useLocalePageRouter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalePageRouter.d.ts","sourceRoot":"","sources":["../../../src/client/useLocalePageRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAoB,MAAM,yBAAyB,CAAC;AAKzE,eAAO,MAAM,mBAAmB;wBAgDnB,OAAO;;mBAnDU,UAC3B;0BAAqC,UAAU;6BAE1B,UAAU;uBAGzB,UAAU;CA8ElB,CAAC"}
1
+ {"version":3,"file":"useLocalePageRouter.d.ts","sourceRoot":"","sources":["../../../src/client/useLocalePageRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAMvD,eAAO,MAAM,mBAAmB;;;;;;;CA0B/B,CAAC"}
@@ -1,4 +1,4 @@
1
- export { getTranslation, IntlayerClientContext, useIntlayer, useTraduction, useDictionary, useLocaleCookie, type IntlayerNode, t, } from 'react-intlayer';
1
+ export { getTranslation, IntlayerClientContext, getIntlayer, useIntlayer, useTraduction, getDictionary, useDictionary, useLocaleCookie, type IntlayerNode, t, } from 'react-intlayer';
2
2
  export { generateStaticParams } from './generateStaticParams';
3
3
  export type { LocalParams, LocalPromiseParams, Next14PageIntlayer, Next15PageIntlayer, NextPageIntlayer, Next14LayoutIntlayer, Next15LayoutIntlayer, NextLayoutIntlayer, } from './types/index';
4
4
  export { useLocale, useLocalePageRouter, IntlayerClientProvider, type IntlayerClientProviderProps, } from './client/index';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,KAAK,YAAY,EACjB,CAAC,GACF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,KAAK,YAAY,EACjB,CAAC,GACF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC"}
@@ -1,20 +1,20 @@
1
- import type { Locales } from 'intlayer';
1
+ import type { Locales } from '@intlayer/config';
2
2
  import type { NextPage } from 'next';
3
3
  import type { PropsWithChildren, ReactNode } from 'react';
4
- export type LocalParams<T = undefined> = {
4
+ export type LocalParams<T = {}> = {
5
5
  params: {
6
6
  locale: Locales;
7
7
  } & T;
8
8
  };
9
- export type LocalPromiseParams<T = undefined> = {
9
+ export type LocalPromiseParams<T = {}> = {
10
10
  params: Promise<{
11
11
  locale: Locales;
12
12
  } & T>;
13
13
  };
14
- export type Next14PageIntlayer<T = undefined> = NextPage<LocalParams<T>>;
15
- export type Next15PageIntlayer<T = undefined> = (props: LocalPromiseParams<T>) => ReactNode | Promise<ReactNode>;
16
- export type NextPageIntlayer<T = undefined> = Next15PageIntlayer<T>;
17
- export type Next14LayoutIntlayer<T = undefined> = NextPage<PropsWithChildren<LocalParams<T>>>;
18
- export type Next15LayoutIntlayer<T = undefined> = (props: PropsWithChildren<LocalPromiseParams<T>>) => ReactNode | Promise<ReactNode>;
19
- export type NextLayoutIntlayer<T = undefined> = Next15LayoutIntlayer<T>;
14
+ export type Next14PageIntlayer<T = {}> = NextPage<LocalParams<T>>;
15
+ export type Next15PageIntlayer<T = {}> = (props: LocalPromiseParams<T>) => ReactNode | Promise<ReactNode>;
16
+ export type NextPageIntlayer<T = {}> = Next15PageIntlayer<T>;
17
+ export type Next14LayoutIntlayer<T = {}> = NextPage<PropsWithChildren<LocalParams<T>>>;
18
+ export type Next15LayoutIntlayer<T = {}> = (props: PropsWithChildren<LocalPromiseParams<T>>) => ReactNode | Promise<ReactNode>;
19
+ export type NextLayoutIntlayer<T = {}> = Next15LayoutIntlayer<T>;
20
20
  //# sourceMappingURL=NextPage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NextPage.d.ts","sourceRoot":"","sources":["../../../src/types/NextPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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AC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intlayer",
3
- "version": "3.5.2",
3
+ "version": "3.5.4",
4
4
  "private": false,
5
5
  "description": "Internationalisation tool for Next.js applications. Declare your multilingual contant in the same lever than your component. Powered by TypeScript, declaration files.",
6
6
  "keywords": [
@@ -72,12 +72,12 @@
72
72
  ],
73
73
  "dependencies": {
74
74
  "webpack": "^5.96.1",
75
- "@intlayer/config": "^3.5.2",
76
- "@intlayer/core": "^3.5.2",
77
- "react-intlayer": "^3.5.2",
78
- "@intlayer/chokidar": "^3.5.2",
79
- "@intlayer/dictionaries-entry": "^3.5.2",
80
- "@intlayer/webpack": "^3.5.2"
75
+ "@intlayer/core": "^3.5.4",
76
+ "@intlayer/dictionaries-entry": "^3.5.4",
77
+ "@intlayer/config": "^3.5.4",
78
+ "react-intlayer": "^3.5.4",
79
+ "@intlayer/chokidar": "^3.5.4",
80
+ "@intlayer/webpack": "^3.5.4"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@types/node": "^22.10.1",
@@ -89,21 +89,21 @@
89
89
  "tsc-alias": "^1.8.10",
90
90
  "tsup": "^8.3.5",
91
91
  "typescript": "^5.7.2",
92
- "@utils/ts-config": "^1.0.4",
93
- "@utils/eslint-config": "^1.0.4",
94
- "@utils/tsup-config": "^1.0.4",
95
92
  "@utils/ts-config-types": "^1.0.4",
96
- "intlayer": "^3.5.2"
93
+ "@utils/tsup-config": "^1.0.4",
94
+ "intlayer": "^3.5.4",
95
+ "@utils/eslint-config": "^1.0.4",
96
+ "@utils/ts-config": "^1.0.4"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "next": ">=14.0.0 <16.0.0",
100
100
  "react": ">=16.0.0 <19.0.0",
101
- "@intlayer/config": "^3.5.2",
102
- "@intlayer/core": "^3.5.2",
103
- "intlayer": "^3.5.2",
104
- "@intlayer/dictionaries-entry": "^3.5.2",
105
- "react-intlayer": "^3.5.2",
106
- "@intlayer/webpack": "^3.5.2"
101
+ "@intlayer/config": "^3.5.4",
102
+ "@intlayer/dictionaries-entry": "^3.5.4",
103
+ "@intlayer/webpack": "^3.5.4",
104
+ "@intlayer/core": "^3.5.4",
105
+ "react-intlayer": "^3.5.4",
106
+ "intlayer": "^3.5.4"
107
107
  },
108
108
  "engines": {
109
109
  "node": ">=14.18"