next-intlayer 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +199 -0
- package/dist/cjs/client/index.cjs +17 -23
- package/dist/cjs/client/index.cjs.map +1 -1
- package/dist/cjs/client/index.d.ts +3 -10
- package/dist/cjs/client/useLocale.cjs +13 -20
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocale.d.ts +7 -7
- package/dist/cjs/generateStaticParams.cjs +8 -13
- package/dist/cjs/generateStaticParams.d.ts +2 -2
- package/dist/cjs/index.cjs +19 -25
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +8 -15
- package/dist/cjs/middleware/index.cjs +9 -21
- package/dist/cjs/middleware/index.d.ts +2 -2
- package/dist/cjs/middleware/intlayerMiddleware.cjs +28 -86
- package/dist/cjs/middleware/intlayerMiddleware.cjs.map +1 -1
- package/dist/cjs/middleware/intlayerMiddleware.d.ts +16 -1
- package/dist/cjs/middleware/localeDetector.cjs +20 -37
- package/dist/cjs/middleware/localeDetector.cjs.map +1 -1
- package/dist/cjs/middleware/localeDetector.d.ts +7 -2
- package/dist/cjs/server/index.cjs +17 -22
- package/dist/cjs/server/index.cjs.map +1 -1
- package/dist/cjs/server/index.d.ts +3 -10
- package/dist/cjs/server/withIntlayer.cjs +38 -53
- package/dist/cjs/server/withIntlayer.cjs.map +1 -1
- package/dist/cjs/server/withIntlayer.d.ts +13 -5
- package/dist/cjs/types/NextPage.cjs +4 -8
- package/dist/cjs/types/NextPage.d.ts +6 -6
- package/dist/cjs/types/index.cjs +4 -8
- package/dist/cjs/types/index.d.ts +4 -4
- package/dist/esm/client/index.d.mts +3 -10
- package/dist/esm/client/index.mjs +8 -8
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/useLocale.d.mts +7 -7
- package/dist/esm/client/useLocale.mjs +12 -10
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/generateStaticParams.d.mts +2 -2
- package/dist/esm/generateStaticParams.mjs +4 -2
- package/dist/esm/index.d.mts +8 -15
- package/dist/esm/index.mjs +9 -9
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/middleware/index.d.mts +2 -2
- package/dist/esm/middleware/index.mjs +2 -2
- package/dist/esm/middleware/intlayerMiddleware.d.mts +16 -1
- package/dist/esm/middleware/intlayerMiddleware.mjs +21 -66
- package/dist/esm/middleware/intlayerMiddleware.mjs.map +1 -1
- package/dist/esm/middleware/localeDetector.d.mts +7 -2
- package/dist/esm/middleware/localeDetector.mjs +5 -3
- package/dist/esm/middleware/localeDetector.mjs.map +1 -1
- package/dist/esm/server/index.d.mts +3 -10
- package/dist/esm/server/index.mjs +8 -8
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/withIntlayer.d.mts +13 -5
- package/dist/esm/server/withIntlayer.mjs +34 -37
- package/dist/esm/server/withIntlayer.mjs.map +1 -1
- package/dist/esm/types/NextPage.d.mts +6 -6
- package/dist/esm/types/NextPage.mjs +1 -1
- package/dist/esm/types/index.d.mts +4 -4
- package/dist/esm/types/index.mjs +1 -1
- package/package.json +14 -12
- package/src/client/index.ts +2 -2
- package/src/client/useLocale.ts +6 -4
- package/src/index.ts +2 -2
- package/src/middleware/intlayerMiddleware.ts +15 -0
- package/src/middleware/localeDetector.ts +5 -0
- package/src/server/index.ts +2 -2
- package/src/server/withIntlayer.ts +33 -27
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Intlayer: Next-Level Content Management in JavaScript
|
|
2
|
+
|
|
3
|
+
**Intlayer** is an innovative Content Management System (CMS) designed specifically for JavaScript developers. It enables seamless transpilation of JavaScript content into structured dictionaries, making integration into your codebase straightforward and efficient.
|
|
4
|
+
|
|
5
|
+
## Why Choose Intlayer?
|
|
6
|
+
|
|
7
|
+
- **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
|
|
8
|
+
- **Type-Safe Environment**: Leverage TypeScript to ensure all your content definitions are precise and error-free.
|
|
9
|
+
- **Integrated Content Files**: Keep your translations close to their respective components, enhancing maintainability and clarity.
|
|
10
|
+
- **Simplified Setup**: Get up and running quickly with minimal configuration, especially optimized for Next.js projects.
|
|
11
|
+
- **Server Component Support**: Perfectly suited for Next.js server components, ensuring smooth server-side rendering.
|
|
12
|
+
- **Enhanced Routing**: Full support for Next.js app routing, adapting seamlessly to complex application structures.
|
|
13
|
+
|
|
14
|
+
## Getting Started with Intlayer
|
|
15
|
+
|
|
16
|
+
Setting up Intlayer in a Next.js application is straightforward:
|
|
17
|
+
|
|
18
|
+
### Step 1: Install Dependencies
|
|
19
|
+
|
|
20
|
+
Install the necessary packages using npm:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install intlayer next-intlayer
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn install intlayer next-intlayer
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm install intlayer next-intlayer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Step 2: Integrate Intlayer in Your Next.js Configuration
|
|
35
|
+
|
|
36
|
+
Configure your Next.js setup to use Intlayer:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// next.config.mjs
|
|
40
|
+
import { withIntlayer } from "next-intlayer/server";
|
|
41
|
+
|
|
42
|
+
const nextConfig = {};
|
|
43
|
+
|
|
44
|
+
export default withIntlayer(nextConfig);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Step 3: Configure Middleware for Locale Detection
|
|
48
|
+
|
|
49
|
+
Set up middleware to detect the user's preferred locale:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// src/middleware.ts
|
|
53
|
+
export { intlayerMiddleware as middleware } from 'next-intlayer/middleware';
|
|
54
|
+
|
|
55
|
+
export const config = {
|
|
56
|
+
matcher: '/((?!api|static|._\\.._|\_next).*),
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Step 4: Define Dynamic Locale Routes
|
|
61
|
+
|
|
62
|
+
Implement dynamic routing for localized content:
|
|
63
|
+
|
|
64
|
+
Change `src/app/page.ts` to `src/app/[locale]/page.ts`
|
|
65
|
+
|
|
66
|
+
### Step 5: Manage Your Content
|
|
67
|
+
|
|
68
|
+
Create and manage your content dictionaries:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
// src/app/[locale]/page.content.ts
|
|
72
|
+
import { t, type ContentModule } from "intlayer";
|
|
73
|
+
|
|
74
|
+
const pageContent: ContentModule = {
|
|
75
|
+
id: "page",
|
|
76
|
+
getStarted: {
|
|
77
|
+
main: t({
|
|
78
|
+
en: "Get started by editing",
|
|
79
|
+
fr: "Commencez par éditer",
|
|
80
|
+
es: "Comience por editar",
|
|
81
|
+
}),
|
|
82
|
+
pageLink: "src/app/page.tsx",
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default pageContent;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
[See how to declare your Intlayer declaration files](https://github.com/aypineau/intlayer/blob/main/packages/intlayer/readme.md).
|
|
90
|
+
|
|
91
|
+
### Step 6: Utilize Content in Your Code
|
|
92
|
+
|
|
93
|
+
Access your content dictionaries throughout your application:
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
// src/app/[locale]/page.ts
|
|
97
|
+
|
|
98
|
+
import { ClientComponentExample } from "@component/components/ClientComponentExample";
|
|
99
|
+
import { LocaleSwitcher } from "@component/components/LangSwitcherDropDown";
|
|
100
|
+
import { NestedServerComponentExample } from "@component/components/NestedServerComponentExample";
|
|
101
|
+
import { ServerComponentExample } from "@component/components/ServerComponentExample";
|
|
102
|
+
import { type NextPageIntlayer, IntlayerClientProvider } from "next-intlayer";
|
|
103
|
+
import { IntlayerServerProvider, useIntlayer } from "next-intlayer/server";
|
|
104
|
+
|
|
105
|
+
const Page: NextPageIntlayer = ({ params: { locale } }) => {
|
|
106
|
+
const content = useIntlayer("page", locale);
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
<p>
|
|
111
|
+
{content.getStarted.main}
|
|
112
|
+
<code>{content.getStarted.pageLink}</code>
|
|
113
|
+
</p>
|
|
114
|
+
{/**
|
|
115
|
+
* IntlayerServerProvider is used to provide the locale to the server children
|
|
116
|
+
* Don't work if set in the layout
|
|
117
|
+
*/}
|
|
118
|
+
<IntlayerServerProvider locale={locale}>
|
|
119
|
+
<ServerComponentExample />
|
|
120
|
+
</IntlayerServerProvider>
|
|
121
|
+
{/**
|
|
122
|
+
* IntlayerClientProvider is used to provide the locale to the client children
|
|
123
|
+
* Can be set in any parent component, including the layout
|
|
124
|
+
*/}
|
|
125
|
+
<IntlayerClientProvider locale={locale}>
|
|
126
|
+
<ClientComponentExample />
|
|
127
|
+
</IntlayerClientProvider>
|
|
128
|
+
</>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default Page;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
// src/components/ClientComponentExample.tsx
|
|
137
|
+
|
|
138
|
+
"use client";
|
|
139
|
+
|
|
140
|
+
import { useIntlayer } from "next-intlayer";
|
|
141
|
+
|
|
142
|
+
export const ClientComponentExample = () => {
|
|
143
|
+
const content = useIntlayer("client-component-example"); // Create related content declaration
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div>
|
|
147
|
+
<h2>{content.title} </h2>
|
|
148
|
+
<p>{content.content}</p>
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
// src/components/ServerComponentExample.tsx
|
|
156
|
+
|
|
157
|
+
import { useIntlayer } from "next-intlayer/server";
|
|
158
|
+
|
|
159
|
+
export const ServerComponentExample = () => {
|
|
160
|
+
const content = useIntlayer("server-component-example"); // Create related content declaration
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<div>
|
|
164
|
+
<h2>{content.title} </h2>
|
|
165
|
+
<p>{content.content}</p>
|
|
166
|
+
</div>
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
For more detailed usage of intlayer into Client, or Server component, see the [nextJS example here](https://github.com/aypineau/intlayer/blob/main/examples/nextjs-app/src/app/%5Blocale%5D/demo-usage-components/page.tsx).
|
|
172
|
+
|
|
173
|
+
## Configuration of your project
|
|
174
|
+
|
|
175
|
+
Create a config file to configure the languages of your application:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
// intlayer.config.ts
|
|
179
|
+
|
|
180
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
181
|
+
|
|
182
|
+
const config: IntlayerConfig = {
|
|
183
|
+
internationalization: {
|
|
184
|
+
locales: [
|
|
185
|
+
Locales.ENGLISH,
|
|
186
|
+
// Your other locales
|
|
187
|
+
],
|
|
188
|
+
defaultLocale: Locales.ENGLISH,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export default config;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
To see all available parameters, refer to the [configuration documentation here](https://github.com/aypineau/intlayer/blob/main/docs/configuration.md).
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
This version emphasizes ease of use, practical steps, and the professional application of Intlayer in a Next.js environment.
|
|
@@ -8,41 +8,35 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var client_exports = {};
|
|
24
20
|
__export(client_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import_react_intlayer.LocaleClientContextProvider,
|
|
21
|
+
IntlayerClient: () => import_react_intlayer.IntlayerClient,
|
|
22
|
+
IntlayerClientProvider: () => import_react_intlayer.IntlayerClientProvider,
|
|
28
23
|
getTranslation: () => import_react_intlayer.getTranslation,
|
|
29
24
|
useIntlayer: () => import_react_intlayer.useIntlayer,
|
|
30
25
|
useLocale: () => import_useLocale.useLocale,
|
|
31
26
|
useLocaleCookie: () => import_react_intlayer.useLocaleCookie,
|
|
32
|
-
useTraduction: () => import_react_intlayer.useTraduction
|
|
27
|
+
useTraduction: () => import_react_intlayer.useTraduction
|
|
33
28
|
});
|
|
34
29
|
module.exports = __toCommonJS(client_exports);
|
|
35
30
|
var import_react_intlayer = require("react-intlayer");
|
|
36
|
-
var import_useLocale = require(
|
|
31
|
+
var import_useLocale = require('./useLocale.cjs');
|
|
37
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 &&
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//# sourceMappingURL=index.cjs.map
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
IntlayerClient,
|
|
35
|
+
IntlayerClientProvider,
|
|
36
|
+
getTranslation,
|
|
37
|
+
useIntlayer,
|
|
38
|
+
useLocale,
|
|
39
|
+
useLocaleCookie,
|
|
40
|
+
useTraduction
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n getTranslation,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n getTranslation,\n IntlayerClientProvider,\n IntlayerClient,\n useIntlayer,\n useTraduction,\n useLocaleCookie,\n} from 'react-intlayer';\nexport { useLocale } from './useLocale';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAOO;AACP,uBAA0B;","names":[]}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
getTranslation,
|
|
5
|
-
useIntlayer,
|
|
6
|
-
useLocaleCookie,
|
|
7
|
-
useTraduction,
|
|
8
|
-
} from "react-intlayer";
|
|
9
|
-
export { useLocale } from "./useLocale.js";
|
|
10
|
-
import "intlayer";
|
|
1
|
+
export { IntlayerClient, IntlayerClientProvider, getTranslation, useIntlayer, useLocaleCookie, useTraduction } from 'react-intlayer';
|
|
2
|
+
export { useLocale } from './useLocale.js';
|
|
3
|
+
import '@intlayer/config/client';
|
|
@@ -8,21 +8,17 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var useLocale_exports = {};
|
|
24
20
|
__export(useLocale_exports, {
|
|
25
|
-
useLocale: () => useLocale
|
|
21
|
+
useLocale: () => useLocale
|
|
26
22
|
});
|
|
27
23
|
module.exports = __toCommonJS(useLocale_exports);
|
|
28
24
|
var import_client = require("@intlayer/config/client");
|
|
@@ -37,19 +33,17 @@ const useLocale = () => {
|
|
|
37
33
|
const {
|
|
38
34
|
defaultLocale,
|
|
39
35
|
availableLocales,
|
|
40
|
-
locale: currentLocale
|
|
36
|
+
locale: currentLocale
|
|
41
37
|
} = reactLocaleHook;
|
|
42
38
|
const setLocale = (locale) => {
|
|
43
|
-
if (currentLocale === locale)
|
|
39
|
+
if (currentLocale.toString() === locale.toString())
|
|
40
|
+
return;
|
|
44
41
|
if (!availableLocales.includes(locale)) {
|
|
45
42
|
console.error(`Locale ${locale} is not available`);
|
|
46
43
|
return;
|
|
47
44
|
}
|
|
48
45
|
setLocaleCookie(locale);
|
|
49
|
-
const pathWithoutLocale =
|
|
50
|
-
!prefixDefault && currentLocale === defaultLocale
|
|
51
|
-
? pathname
|
|
52
|
-
: pathname.slice(`/${currentLocale}`.length) || "/";
|
|
46
|
+
const pathWithoutLocale = !prefixDefault && currentLocale.toString() === defaultLocale.toString() ? pathname : pathname.slice(`/${currentLocale}`.length) || "/";
|
|
53
47
|
if (!prefixDefault && locale === defaultLocale) {
|
|
54
48
|
return router.push(pathWithoutLocale);
|
|
55
49
|
}
|
|
@@ -57,12 +51,11 @@ const useLocale = () => {
|
|
|
57
51
|
};
|
|
58
52
|
return {
|
|
59
53
|
...reactLocaleHook,
|
|
60
|
-
setLocale
|
|
54
|
+
setLocale
|
|
61
55
|
};
|
|
62
56
|
};
|
|
63
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 &&
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//# sourceMappingURL=useLocale.cjs.map
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
useLocale
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=useLocale.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { intlayerMiddlewareConfiguration
|
|
1
|
+
{"version":3,"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import {\n type Locales,\n intlayerMiddlewareConfiguration,\n} from '@intlayer/config/client';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useLocale as useReactLocale, useLocaleCookie } from 'react-intlayer';\n\nconst { prefixDefault } = intlayerMiddlewareConfiguration;\n\nexport const useLocale = () => {\n const { setLocaleCookie } = useLocaleCookie();\n const reactLocaleHook = useReactLocale();\n const router = useRouter();\n const pathname = usePathname();\n\n const {\n defaultLocale,\n availableLocales,\n locale: currentLocale,\n } = reactLocaleHook;\n\n const setLocale = (locale: Locales) => {\n if (currentLocale.toString() === locale.toString()) return;\n\n if (!availableLocales.includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleCookie(locale);\n\n const pathWithoutLocale =\n !prefixDefault && currentLocale.toString() === defaultLocale.toString()\n ? pathname\n : pathname.slice(`/${currentLocale}`.length) || '/';\n\n if (!prefixDefault && locale === defaultLocale) {\n return router.push(pathWithoutLocale);\n }\n\n return router.push(`/${locale}${pathWithoutLocale}`);\n };\n\n return {\n ...reactLocaleHook,\n setLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAGO;AACP,wBAAuC;AACvC,4BAA6D;AAE7D,MAAM,EAAE,cAAc,IAAI;AAEnB,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,gBAAgB,QAAI,uCAAgB;AAC5C,QAAM,sBAAkB,sBAAAA,WAAe;AACvC,QAAM,aAAS,6BAAU;AACzB,QAAM,eAAW,+BAAY;AAE7B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,EACV,IAAI;AAEJ,QAAM,YAAY,CAAC,WAAoB;AACrC,QAAI,cAAc,SAAS,MAAM,OAAO,SAAS;AAAG;AAEpD,QAAI,CAAC,iBAAiB,SAAS,MAAM,GAAG;AACtC,cAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,IACF;AAEA,oBAAgB,MAAM;AAEtB,UAAM,oBACJ,CAAC,iBAAiB,cAAc,SAAS,MAAM,cAAc,SAAS,IAClE,WACA,SAAS,MAAM,IAAI,aAAa,GAAG,MAAM,KAAK;AAEpD,QAAI,CAAC,iBAAiB,WAAW,eAAe;AAC9C,aAAO,OAAO,KAAK,iBAAiB;AAAA,IACtC;AAEA,WAAO,OAAO,KAAK,IAAI,MAAM,GAAG,iBAAiB,EAAE;AAAA,EACrD;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,EACF;AACF;","names":["useReactLocale"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Locales } from
|
|
1
|
+
import 'react-intlayer';
|
|
2
|
+
import { Locales } from '@intlayer/config/client';
|
|
3
3
|
|
|
4
4
|
declare const useLocale: () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
setLocale: (locale: Locales) => void;
|
|
6
|
+
locale: Locales;
|
|
7
|
+
defaultLocale: Locales;
|
|
8
|
+
availableLocales: Locales[];
|
|
9
|
+
localeList: Locales[];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { useLocale };
|
|
@@ -8,29 +8,24 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var generateStaticParams_exports = {};
|
|
24
20
|
__export(generateStaticParams_exports, {
|
|
25
|
-
generateStaticParams: () => generateStaticParams
|
|
21
|
+
generateStaticParams: () => generateStaticParams
|
|
26
22
|
});
|
|
27
23
|
module.exports = __toCommonJS(generateStaticParams_exports);
|
|
28
24
|
var import_client = require("@intlayer/config/client");
|
|
29
25
|
const { locales } = import_client.intlayerIntlConfiguration;
|
|
30
26
|
const generateStaticParams = () => locales.map((locale) => ({ locale }));
|
|
31
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 &&
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=generateStaticParams.cjs.map
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
generateStaticParams
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=generateStaticParams.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as _intlayer_config_client from
|
|
1
|
+
import * as _intlayer_config_client from '@intlayer/config/client';
|
|
2
2
|
|
|
3
3
|
declare const generateStaticParams: () => {
|
|
4
|
-
|
|
4
|
+
locale: _intlayer_config_client.Locales;
|
|
5
5
|
}[];
|
|
6
6
|
|
|
7
7
|
export { generateStaticParams };
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -8,44 +8,38 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
var src_exports = {};
|
|
24
20
|
__export(src_exports, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import_react_intlayer.LocaleClientContextProvider,
|
|
21
|
+
IntlayerClient: () => import_react_intlayer.IntlayerClient,
|
|
22
|
+
IntlayerClientProvider: () => import_react_intlayer.IntlayerClientProvider,
|
|
28
23
|
generateStaticParams: () => import_generateStaticParams.generateStaticParams,
|
|
29
24
|
getTranslation: () => import_react_intlayer.getTranslation,
|
|
30
25
|
useIntlayer: () => import_react_intlayer.useIntlayer,
|
|
31
26
|
useLocale: () => import_useLocale.useLocale,
|
|
32
27
|
useLocaleCookie: () => import_react_intlayer.useLocaleCookie,
|
|
33
|
-
useTraduction: () => import_react_intlayer.useTraduction
|
|
28
|
+
useTraduction: () => import_react_intlayer.useTraduction
|
|
34
29
|
});
|
|
35
30
|
module.exports = __toCommonJS(src_exports);
|
|
36
31
|
var import_react_intlayer = require("react-intlayer");
|
|
37
|
-
var import_generateStaticParams = require(
|
|
38
|
-
var import_useLocale = require(
|
|
32
|
+
var import_generateStaticParams = require('./generateStaticParams.cjs');
|
|
33
|
+
var import_useLocale = require('./client/useLocale.cjs');
|
|
39
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 &&
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=index.cjs.map
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
IntlayerClient,
|
|
37
|
+
IntlayerClientProvider,
|
|
38
|
+
generateStaticParams,
|
|
39
|
+
getTranslation,
|
|
40
|
+
useIntlayer,
|
|
41
|
+
useLocale,
|
|
42
|
+
useLocaleCookie,
|
|
43
|
+
useTraduction
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getTranslation,\n
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getTranslation,\n IntlayerClientProvider,\n IntlayerClient,\n useIntlayer,\n useTraduction,\n useLocaleCookie,\n} from 'react-intlayer';\nexport { generateStaticParams } from './generateStaticParams';\nexport type { LocalParams, NextPageIntlayer } from './types/index';\nexport { useLocale } from './client/useLocale';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAOO;AACP,kCAAqC;AAErC,uBAA0B;","names":[]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export { generateStaticParams } from "./generateStaticParams.js";
|
|
10
|
-
export { LocalParams, NextPageIntlayer } from "./types/NextPage.js";
|
|
11
|
-
export { useLocale } from "./client/useLocale.js";
|
|
12
|
-
import "@intlayer/config/client";
|
|
13
|
-
import "intlayer";
|
|
14
|
-
import "next";
|
|
15
|
-
import "react";
|
|
1
|
+
export { IntlayerClient, IntlayerClientProvider, getTranslation, useIntlayer, useLocaleCookie, useTraduction } from 'react-intlayer';
|
|
2
|
+
export { generateStaticParams } from './generateStaticParams.js';
|
|
3
|
+
export { LocalParams, NextPageIntlayer } from './types/NextPage.js';
|
|
4
|
+
export { useLocale } from './client/useLocale.js';
|
|
5
|
+
import '@intlayer/config/client';
|
|
6
|
+
import 'intlayer';
|
|
7
|
+
import 'next';
|
|
8
|
+
import 'react';
|
|
@@ -4,32 +4,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
8
|
for (let key of __getOwnPropNames(from))
|
|
9
9
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, {
|
|
11
|
-
get: () => from[key],
|
|
12
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
13
|
-
});
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
11
|
}
|
|
15
12
|
return to;
|
|
16
13
|
};
|
|
17
|
-
var __reExport = (target, mod, secondTarget) => (
|
|
18
|
-
|
|
19
|
-
secondTarget && __copyProps(secondTarget, mod, "default")
|
|
20
|
-
);
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
16
|
var middleware_exports = {};
|
|
24
17
|
module.exports = __toCommonJS(middleware_exports);
|
|
25
|
-
__reExport(
|
|
26
|
-
middleware_exports,
|
|
27
|
-
require("./intlayerMiddleware.cjs"),
|
|
28
|
-
module.exports
|
|
29
|
-
);
|
|
18
|
+
__reExport(middleware_exports, require('./intlayerMiddleware.cjs'), module.exports);
|
|
30
19
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
-
0 &&
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=index.cjs.map
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require('./intlayerMiddleware.cjs')
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { intlayerMiddleware } from
|
|
2
|
-
import
|
|
1
|
+
export { intlayerMiddleware } from './intlayerMiddleware.js';
|
|
2
|
+
import 'next/server';
|