@intlayer/docs 7.0.2 → 7.0.3-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-01-02
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
4
|
title: Intlayer and next-intl
|
|
5
5
|
description: Integrate Intlayer with next-intl for the internationalization (i18n) of a React app
|
|
6
6
|
keywords:
|
|
@@ -14,6 +14,10 @@ keywords:
|
|
|
14
14
|
slugs:
|
|
15
15
|
- blog
|
|
16
16
|
- intlayer-with-next-intl
|
|
17
|
+
history:
|
|
18
|
+
- version: 7.0.0
|
|
19
|
+
date: 2025-10-29
|
|
20
|
+
changes: Change to syncJSON plugin
|
|
17
21
|
---
|
|
18
22
|
|
|
19
23
|
# Next.js Internationalization (i18n) with next-intl and Intlayer
|
|
@@ -30,6 +34,10 @@ They share three principal notions:
|
|
|
30
34
|
|
|
31
35
|
3. **Plugins and Middlewares**: Features for managing URL redirection, bundling optimization, and more e.g., `intlayerMiddleware` for Intlayer or [`createMiddleware`](https://github.com/amannn/next-intl) for next-intl.
|
|
32
36
|
|
|
37
|
+
## Table of Contents
|
|
38
|
+
|
|
39
|
+
<TOC>
|
|
40
|
+
|
|
33
41
|
## Intlayer vs. next-intl: Key Differences
|
|
34
42
|
|
|
35
43
|
For a deeper analysis of how Intlayer compares to other i18n libraries for Next.js (such as next-intl), check out the [next-i18next vs. next-intl vs. Intlayer blog post](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/i18next_vs_next-intl_vs_intlayer.md).
|
|
@@ -87,15 +95,15 @@ Intlayer content declaration files generally offer a better developer experience
|
|
|
87
95
|
To use Intlayer and next-intl together, install both libraries:
|
|
88
96
|
|
|
89
97
|
```bash packageManager="npm"
|
|
90
|
-
npm install intlayer next-intl
|
|
98
|
+
npm install intlayer next-intl @intlayer/sync-json-plugin
|
|
91
99
|
```
|
|
92
100
|
|
|
93
101
|
```bash packageManager="yarn"
|
|
94
|
-
yarn add intlayer next-intl
|
|
102
|
+
yarn add intlayer next-intl @intlayer/sync-json-plugin
|
|
95
103
|
```
|
|
96
104
|
|
|
97
105
|
```bash packageManager="pnpm"
|
|
98
|
-
pnpm add intlayer next-intl
|
|
106
|
+
pnpm add intlayer next-intl @intlayer/sync-json-plugin
|
|
99
107
|
```
|
|
100
108
|
|
|
101
109
|
### Configuring Intlayer to Export next-intl Messages
|
|
@@ -104,7 +112,7 @@ pnpm add intlayer next-intl
|
|
|
104
112
|
|
|
105
113
|
Create or update an `intlayer.config.ts` file (or `.mjs` / `.cjs`) in the root of your project:
|
|
106
114
|
|
|
107
|
-
```typescript fileName="intlayer.config.ts"
|
|
115
|
+
```typescript fileName="intlayer.config.ts"
|
|
108
116
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
109
117
|
|
|
110
118
|
const config: IntlayerConfig = {
|
|
@@ -112,51 +120,16 @@ const config: IntlayerConfig = {
|
|
|
112
120
|
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
113
121
|
defaultLocale: Locales.ENGLISH,
|
|
114
122
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
export default config;
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
125
|
-
import { Locales } from "intlayer";
|
|
126
|
-
|
|
127
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
128
|
-
const config = {
|
|
129
|
-
internationalization: {
|
|
130
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
131
|
-
defaultLocale: Locales.ENGLISH,
|
|
132
|
-
},
|
|
133
|
-
content: {
|
|
134
|
-
dictionaryOutput: ["react-intl"],
|
|
135
|
-
nextIntlMessagesDir: "./intl/messages",
|
|
136
|
-
},
|
|
123
|
+
plugins: [
|
|
124
|
+
syncJSON({
|
|
125
|
+
source: ({ key, locale }) => `./intl/messages/${locale}/${key}.json`,
|
|
126
|
+
}),
|
|
127
|
+
],
|
|
137
128
|
};
|
|
138
129
|
|
|
139
130
|
export default config;
|
|
140
131
|
```
|
|
141
132
|
|
|
142
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
143
|
-
const { Locales } = require("intlayer");
|
|
144
|
-
|
|
145
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
146
|
-
const config = {
|
|
147
|
-
internationalization: {
|
|
148
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
149
|
-
defaultLocale: Locales.ENGLISH,
|
|
150
|
-
},
|
|
151
|
-
content: {
|
|
152
|
-
dictionaryOutput: ["next-intl"],
|
|
153
|
-
nextIntlMessagesDir: "./intl/messages",
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
module.exports = config;
|
|
158
|
-
```
|
|
159
|
-
|
|
160
133
|
### Dictionary
|
|
161
134
|
|
|
162
135
|
Below are examples of content declaration files in multiple formats. Intlayer will compile these into message files that next-intl can consume.
|
|
@@ -233,7 +206,7 @@ module.exports = {
|
|
|
233
206
|
To build the message files for next-intl, run:
|
|
234
207
|
|
|
235
208
|
```bash packageManager="npm"
|
|
236
|
-
npx intlayer
|
|
209
|
+
npx intlayer build
|
|
237
210
|
```
|
|
238
211
|
|
|
239
212
|
```bash packageManager="yarn"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-01-02
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
4
|
title: Intlayer and react-i18next
|
|
5
5
|
description: Compare Intlayer with react-i18next for a React app
|
|
6
6
|
keywords:
|
|
@@ -15,6 +15,10 @@ keywords:
|
|
|
15
15
|
slugs:
|
|
16
16
|
- blog
|
|
17
17
|
- intlayer-with-react-i18next
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.0.0
|
|
20
|
+
date: 2025-10-29
|
|
21
|
+
changes: Change to syncJSON plugin
|
|
18
22
|
---
|
|
19
23
|
|
|
20
24
|
# React Internationalization (i18n) with react-i18next and Intlayer
|
|
@@ -26,6 +30,10 @@ slugs:
|
|
|
26
30
|
|
|
27
31
|
When combined, Intlayer can **export** dictionaries in **i18next-compatible JSON** so that react-i18next can **consume** them at runtime.
|
|
28
32
|
|
|
33
|
+
## Table of Contents
|
|
34
|
+
|
|
35
|
+
<TOC>
|
|
36
|
+
|
|
29
37
|
## Why Use Intlayer with react-i18next?
|
|
30
38
|
|
|
31
39
|
**Intlayer** content declaration files offer a better developer experience because they are:
|
|
@@ -79,17 +87,17 @@ In a Create React App project, install these dependencies:
|
|
|
79
87
|
|
|
80
88
|
```bash
|
|
81
89
|
# With npm
|
|
82
|
-
npm install intlayer react-i18next i18next i18next-resources-to-backend
|
|
90
|
+
npm install intlayer react-i18next i18next i18next-resources-to-backend @intlayer/sync-json-plugin
|
|
83
91
|
```
|
|
84
92
|
|
|
85
93
|
```bash
|
|
86
94
|
# With yarn
|
|
87
|
-
yarn add intlayer react-i18next i18next i18next-resources-to-backend
|
|
95
|
+
yarn add intlayer react-i18next i18next i18next-resources-to-backend @intlayer/sync-json-plugin
|
|
88
96
|
```
|
|
89
97
|
|
|
90
98
|
```bash
|
|
91
99
|
# With pnpm
|
|
92
|
-
pnpm add intlayer react-i18next i18next i18next-resources-to-backend
|
|
100
|
+
pnpm add intlayer react-i18next i18next i18next-resources-to-backend @intlayer/sync-json-plugin
|
|
93
101
|
```
|
|
94
102
|
|
|
95
103
|
### What Are These Packages?
|
|
@@ -99,6 +107,7 @@ pnpm add intlayer react-i18next i18next i18next-resources-to-backend
|
|
|
99
107
|
- **react-i18next** – React-specific integration library for i18next, including the `useTranslation` hook.
|
|
100
108
|
- **i18next** – The underlying framework for translation handling.
|
|
101
109
|
- **i18next-resources-to-backend** – An i18next backend that dynamically imports JSON resources.
|
|
110
|
+
- **@intlayer/sync-json-plugin** – A plugin for Intlayer that syncs JSON files to dictionaries.
|
|
102
111
|
|
|
103
112
|
## Configuring Intlayer to Export i18next Dictionaries
|
|
104
113
|
|
|
@@ -113,14 +122,11 @@ const config: IntlayerConfig = {
|
|
|
113
122
|
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
114
123
|
defaultLocale: Locales.ENGLISH,
|
|
115
124
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// This folder will be created if it doesn't exist yet.
|
|
122
|
-
i18nextResourcesDir: "./i18next/resources",
|
|
123
|
-
},
|
|
125
|
+
plugins: [
|
|
126
|
+
syncJSON({
|
|
127
|
+
source: ({ key, locale }) => `./i18next/resources/${locale}/${key}.json`,
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
124
130
|
};
|
|
125
131
|
|
|
126
132
|
export default config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/docs",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.3-canary.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Intlayer documentation",
|
|
6
6
|
"keywords": [
|
|
@@ -69,17 +69,17 @@
|
|
|
69
69
|
"watch": "webpack --config ./webpack.config.ts --watch"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@intlayer/config": "7.0.
|
|
73
|
-
"@intlayer/core": "7.0.
|
|
74
|
-
"@intlayer/types": "7.0.
|
|
72
|
+
"@intlayer/config": "7.0.3-canary.1",
|
|
73
|
+
"@intlayer/core": "7.0.3-canary.1",
|
|
74
|
+
"@intlayer/types": "7.0.3-canary.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@intlayer/api": "7.0.
|
|
78
|
-
"@intlayer/cli": "7.0.
|
|
77
|
+
"@intlayer/api": "7.0.3-canary.1",
|
|
78
|
+
"@intlayer/cli": "7.0.3-canary.1",
|
|
79
79
|
"@types/node": "24.9.1",
|
|
80
|
-
"@utils/ts-config": "7.0.
|
|
81
|
-
"@utils/ts-config-types": "7.0.
|
|
82
|
-
"@utils/tsdown-config": "7.0.
|
|
80
|
+
"@utils/ts-config": "7.0.3-canary.1",
|
|
81
|
+
"@utils/ts-config-types": "7.0.3-canary.1",
|
|
82
|
+
"@utils/tsdown-config": "7.0.3-canary.1",
|
|
83
83
|
"fast-glob": "3.3.3",
|
|
84
84
|
"rimraf": "6.0.1",
|
|
85
85
|
"tsdown": "0.15.9",
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"vitest": "4.0.3"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"@intlayer/api": "7.0.
|
|
91
|
-
"@intlayer/cli": "7.0.
|
|
92
|
-
"@intlayer/config": "7.0.
|
|
93
|
-
"@intlayer/core": "7.0.
|
|
94
|
-
"@intlayer/types": "7.0.
|
|
90
|
+
"@intlayer/api": "7.0.3-canary.1",
|
|
91
|
+
"@intlayer/cli": "7.0.3-canary.1",
|
|
92
|
+
"@intlayer/config": "7.0.3-canary.1",
|
|
93
|
+
"@intlayer/core": "7.0.3-canary.1",
|
|
94
|
+
"@intlayer/types": "7.0.3-canary.1"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": ">=14.18"
|