@intlayer/docs 7.0.5 → 7.0.7
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/blog/ar/intlayer_with_i18next.md +72 -19
- package/blog/ar/intlayer_with_next-i18next.md +61 -36
- package/blog/ar/intlayer_with_next-intl.md +61 -13
- package/blog/ar/intlayer_with_react-i18next.md +67 -18
- package/blog/ar/intlayer_with_react-intl.md +66 -13
- package/blog/ar/intlayer_with_vue-i18n.md +180 -0
- package/blog/de/intlayer_with_i18next.md +61 -26
- package/blog/de/intlayer_with_next-i18next.md +66 -17
- package/blog/de/intlayer_with_next-intl.md +62 -13
- package/blog/de/intlayer_with_react-i18next.md +66 -17
- package/blog/de/intlayer_with_react-intl.md +66 -14
- package/blog/de/intlayer_with_vue-i18n.md +178 -0
- package/blog/en/intlayer_with_i18next.md +53 -2
- package/blog/en/intlayer_with_next-i18next.md +52 -16
- package/blog/en/intlayer_with_next-intl.md +49 -0
- package/blog/en/intlayer_with_react-i18next.md +50 -1
- package/blog/en/intlayer_with_react-intl.md +53 -0
- package/blog/en/intlayer_with_vue-i18n.md +178 -0
- package/blog/en-GB/intlayer_with_i18next.md +58 -7
- package/blog/en-GB/intlayer_with_next-i18next.md +55 -9
- package/blog/en-GB/intlayer_with_next-intl.md +55 -6
- package/blog/en-GB/intlayer_with_react-i18next.md +55 -6
- package/blog/en-GB/intlayer_with_react-intl.md +56 -3
- package/blog/en-GB/intlayer_with_vue-i18n.md +180 -0
- package/blog/es/intlayer_with_i18next.md +69 -18
- package/blog/es/intlayer_with_next-i18next.md +70 -24
- package/blog/es/intlayer_with_next-intl.md +64 -13
- package/blog/es/intlayer_with_react-i18next.md +61 -12
- package/blog/es/intlayer_with_react-intl.md +65 -12
- package/blog/es/intlayer_with_vue-i18n.md +178 -0
- package/blog/fr/intlayer_with_i18next.md +77 -16
- package/blog/fr/intlayer_with_next-i18next.md +55 -31
- package/blog/fr/intlayer_with_next-intl.md +57 -7
- package/blog/fr/intlayer_with_react-i18next.md +64 -7
- package/blog/fr/intlayer_with_react-intl.md +63 -10
- package/blog/fr/intlayer_with_vue-i18n.md +178 -0
- package/blog/hi/intlayer_with_i18next.md +67 -16
- package/blog/hi/intlayer_with_next-i18next.md +69 -23
- package/blog/hi/intlayer_with_next-intl.md +61 -8
- package/blog/hi/intlayer_with_react-i18next.md +63 -14
- package/blog/hi/intlayer_with_react-intl.md +66 -13
- package/blog/hi/intlayer_with_vue-i18n.md +180 -0
- package/blog/id/intlayer_with_i18next.md +65 -14
- package/blog/id/intlayer_with_next-i18next.md +58 -12
- package/blog/id/intlayer_with_next-intl.md +60 -11
- package/blog/id/intlayer_with_react-i18next.md +59 -10
- package/blog/id/intlayer_with_react-intl.md +66 -13
- package/blog/id/intlayer_with_vue-i18n.md +178 -0
- package/blog/it/intlayer_with_i18next.md +70 -19
- package/blog/it/intlayer_with_next-i18next.md +68 -22
- package/blog/it/intlayer_with_next-intl.md +62 -12
- package/blog/it/intlayer_with_react-i18next.md +65 -16
- package/blog/it/intlayer_with_react-intl.md +67 -14
- package/blog/it/intlayer_with_vue-i18n.md +178 -0
- package/blog/ja/intlayer_with_i18next.md +74 -24
- package/blog/ja/intlayer_with_next-i18next.md +60 -37
- package/blog/ja/intlayer_with_next-intl.md +63 -15
- package/blog/ja/intlayer_with_react-i18next.md +70 -21
- package/blog/ja/intlayer_with_react-intl.md +73 -21
- package/blog/ja/intlayer_with_vue-i18n.md +180 -0
- package/blog/ko/intlayer_with_i18next.md +60 -29
- package/blog/ko/intlayer_with_next-i18next.md +59 -32
- package/blog/ko/intlayer_with_next-intl.md +52 -23
- package/blog/ko/intlayer_with_react-i18next.md +65 -16
- package/blog/ko/intlayer_with_react-intl.md +74 -22
- package/blog/ko/intlayer_with_vue-i18n.md +180 -0
- package/blog/pl/intlayer_with_i18next.md +63 -12
- package/blog/pl/intlayer_with_next-i18next.md +74 -17
- package/blog/pl/intlayer_with_next-intl.md +59 -8
- package/blog/pl/intlayer_with_react-i18next.md +59 -10
- package/blog/pl/intlayer_with_react-intl.md +65 -12
- package/blog/pl/intlayer_with_vue-i18n.md +180 -0
- package/blog/pt/intlayer_with_i18next.md +67 -16
- package/blog/pt/intlayer_with_next-i18next.md +65 -19
- package/blog/pt/intlayer_with_next-intl.md +62 -12
- package/blog/pt/intlayer_with_react-i18next.md +67 -18
- package/blog/pt/intlayer_with_react-intl.md +62 -10
- package/blog/pt/intlayer_with_vue-i18n.md +178 -0
- package/blog/ru/intlayer_with_i18next.md +68 -15
- package/blog/ru/intlayer_with_next-i18next.md +71 -25
- package/blog/ru/intlayer_with_next-intl.md +56 -7
- package/blog/ru/intlayer_with_react-i18next.md +65 -16
- package/blog/ru/intlayer_with_react-intl.md +69 -16
- package/blog/ru/intlayer_with_vue-i18n.md +180 -0
- package/blog/tr/intlayer_with_i18next.md +67 -16
- package/blog/tr/intlayer_with_next-i18next.md +78 -21
- package/blog/tr/intlayer_with_next-intl.md +69 -18
- package/blog/tr/intlayer_with_react-i18next.md +65 -16
- package/blog/tr/intlayer_with_react-intl.md +71 -19
- package/blog/tr/intlayer_with_vue-i18n.md +180 -0
- package/blog/vi/intlayer_with_i18next.md +64 -13
- package/blog/vi/intlayer_with_next-i18next.md +72 -26
- package/blog/vi/intlayer_with_next-intl.md +62 -11
- package/blog/vi/intlayer_with_react-i18next.md +66 -17
- package/blog/vi/intlayer_with_react-intl.md +70 -17
- package/blog/vi/intlayer_with_vue-i18n.md +180 -0
- package/blog/zh/intlayer_with_i18next.md +67 -17
- package/blog/zh/intlayer_with_next-i18next.md +67 -22
- package/blog/zh/intlayer_with_next-intl.md +61 -13
- package/blog/zh/intlayer_with_react-i18next.md +67 -18
- package/blog/zh/intlayer_with_react-intl.md +69 -17
- package/blog/zh/intlayer_with_vue-i18n.md +180 -0
- package/dist/cjs/generated/blog.entry.cjs +19 -0
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +19 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +1 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_nextjs_15.md +36 -9
- package/docs/ar/intlayer_with_nextjs_16.md +36 -9
- package/docs/de/intlayer_with_nextjs_15.md +36 -9
- package/docs/de/intlayer_with_nextjs_16.md +24 -6
- package/docs/en/intlayer_with_nextjs_14.md +37 -9
- package/docs/en/intlayer_with_nextjs_15.md +40 -10
- package/docs/en/intlayer_with_nextjs_16.md +40 -10
- package/docs/en/plugins/sync-json.md +152 -55
- package/docs/en/releases/v7.md +1 -1
- package/docs/en-GB/intlayer_with_nextjs_15.md +36 -9
- package/docs/en-GB/intlayer_with_nextjs_16.md +36 -9
- package/docs/en-GB/releases/v7.md +1 -1
- package/docs/es/intlayer_with_nextjs_15.md +36 -9
- package/docs/es/intlayer_with_nextjs_16.md +36 -9
- package/docs/fr/intlayer_with_nextjs_15.md +36 -9
- package/docs/fr/intlayer_with_nextjs_16.md +37 -24
- package/docs/hi/intlayer_with_nextjs_15.md +36 -9
- package/docs/hi/intlayer_with_nextjs_16.md +36 -9
- package/docs/id/intlayer_with_nextjs_16.md +36 -9
- package/docs/it/intlayer_with_nextjs_15.md +36 -9
- package/docs/it/intlayer_with_nextjs_16.md +36 -9
- package/docs/ja/intlayer_with_nextjs_15.md +36 -9
- package/docs/ja/intlayer_with_nextjs_16.md +36 -9
- package/docs/ko/intlayer_with_nextjs_15.md +36 -9
- package/docs/ko/intlayer_with_nextjs_16.md +36 -9
- package/docs/pl/intlayer_with_nextjs_16.md +36 -9
- package/docs/pt/intlayer_with_nextjs_15.md +36 -9
- package/docs/pt/intlayer_with_nextjs_16.md +36 -9
- package/docs/ru/intlayer_with_nextjs_15.md +36 -9
- package/docs/ru/intlayer_with_nextjs_16.md +36 -9
- package/docs/tr/intlayer_with_nextjs_15.md +36 -9
- package/docs/tr/intlayer_with_nextjs_16.md +39 -21
- package/docs/vi/intlayer_with_nextjs_16.md +36 -9
- package/docs/zh/intlayer_with_nextjs_15.md +36 -9
- package/docs/zh/intlayer_with_nextjs_16.md +36 -9
- package/package.json +14 -14
- package/src/generated/blog.entry.ts +19 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2024-12-24
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-11-01
|
|
4
4
|
title: How to automate your i18next JSON translations using Intlayer
|
|
5
5
|
description: Automate your JSON translations with Intlayer and i18next for enhanced internationalisation in JavaScript applications.
|
|
6
6
|
keywords:
|
|
@@ -20,6 +20,9 @@ slugs:
|
|
|
20
20
|
- blog
|
|
21
21
|
- intlayer-with-i18next
|
|
22
22
|
history:
|
|
23
|
+
- version: 7.0.6
|
|
24
|
+
date: 2025-11-01
|
|
25
|
+
changes: Add loadJSON plugin
|
|
23
26
|
- version: 7.0.0
|
|
24
27
|
date: 2025-10-29
|
|
25
28
|
changes: Change to syncJSON plugin
|
|
@@ -40,6 +43,7 @@ While Intlayer provides an excellent standalone i18n solution (see our [Next.js
|
|
|
40
43
|
1. **Existing codebase**: You have an established i18next implementation and want to gradually migrate to Intlayer's improved developer experience.
|
|
41
44
|
2. **Legacy requirements**: Your project requires compatibility with existing i18next plugins or workflows.
|
|
42
45
|
3. **Team familiarity**: Your team is comfortable with i18next but wants better content management.
|
|
46
|
+
4. **Using Intlayer features**: You want to use Intlayer features like content declaration, translation keys management, translation status, and more.
|
|
43
47
|
|
|
44
48
|
**For that, Intlayer can be implemented as an adapter for i18next to help automate your JSON translations in CLI or CI/CD pipelines, test your translations, and more.**
|
|
45
49
|
|
|
@@ -67,6 +71,10 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
67
71
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
68
72
|
```
|
|
69
73
|
|
|
74
|
+
```bash packageManager="bun"
|
|
75
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
76
|
+
```
|
|
77
|
+
|
|
70
78
|
**Package descriptions:**
|
|
71
79
|
|
|
72
80
|
- **intlayer**: Core library for internationalisation management, content declaration, and building
|
|
@@ -76,7 +84,7 @@ yarn add intlayer @intlayer/sync-json-plugin
|
|
|
76
84
|
|
|
77
85
|
Create an Intlayer configuration file to define your supported locales:
|
|
78
86
|
|
|
79
|
-
**If you want to
|
|
87
|
+
**If you also want to export JSON dictionaries for i18next**, add the `syncJSON` plugin:
|
|
80
88
|
|
|
81
89
|
```typescript fileName="intlayer.config.ts"
|
|
82
90
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -89,7 +97,7 @@ const config: IntlayerConfig = {
|
|
|
89
97
|
},
|
|
90
98
|
plugins: [
|
|
91
99
|
syncJSON({
|
|
92
|
-
source: ({ key, locale }) => `./
|
|
100
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
93
101
|
}),
|
|
94
102
|
],
|
|
95
103
|
};
|
|
@@ -97,15 +105,60 @@ const config: IntlayerConfig = {
|
|
|
97
105
|
export default config;
|
|
98
106
|
```
|
|
99
107
|
|
|
100
|
-
The `syncJSON` plugin will automatically wrap the JSON. It will read and write the JSON files without
|
|
108
|
+
The `syncJSON` plugin will automatically wrap the JSON. It will read and write the JSON files without altering the content architecture.
|
|
101
109
|
|
|
102
110
|
If you want to make that JSON coexist with Intlayer content declaration files (`.content` files), Intlayer will proceed as follows:
|
|
103
111
|
|
|
104
112
|
1. load both JSON and content declaration files and transform them into an Intlayer dictionary.
|
|
105
|
-
2. if there are conflicts between the JSON and the content declaration files, Intlayer will
|
|
113
|
+
2. if there are conflicts between the JSON and the content declaration files, Intlayer will merge all those dictionaries. This depends on the priority of the plugins and that of the content declaration file (all are configurable).
|
|
106
114
|
|
|
107
115
|
If changes are made using the CLI to translate the JSON, or using the CMS, Intlayer will update the JSON file with the new translations.
|
|
108
116
|
|
|
117
|
+
To see more details about the `syncJSON` plugin, please refer to the [syncJSON plugin documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/plugins/sync-json.md).
|
|
118
|
+
|
|
119
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
120
|
+
|
|
121
|
+
By default, Intlayer will load, merge and synchronise both JSON and content declaration files. See [the content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/content_file.md) for more details. But if you prefer, using an Intlayer plugin, you can also implement per-component management of JSON localised anywhere in your codebase.
|
|
122
|
+
|
|
123
|
+
For that, you can use the `loadJSON` plugin.
|
|
124
|
+
|
|
125
|
+
```ts fileName="intlayer.config.ts"
|
|
126
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
127
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
128
|
+
|
|
129
|
+
const config: IntlayerConfig = {
|
|
130
|
+
internationalisation: {
|
|
131
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
132
|
+
defaultLocale: Locales.ENGLISH,
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// Keep your current JSON files in sync with Intlayer dictionaries
|
|
136
|
+
plugins: [
|
|
137
|
+
/**
|
|
138
|
+
* Will load all the JSON files in the src that match the pattern {key}.i18n.json
|
|
139
|
+
*/
|
|
140
|
+
loadJSON({
|
|
141
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
142
|
+
locale: Locales.ENGLISH,
|
|
143
|
+
priority: 1, // Ensures these JSON files take precedence over files at `./locales/en/${key}.json`
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Will load, and write the output and translations back to the JSON files in the locales directory
|
|
147
|
+
*/
|
|
148
|
+
syncJSON({
|
|
149
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
150
|
+
priority: 0,
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
This will load all the JSON files in the `src` directory that match the pattern `{key}.i18n.json` and load them as Intlayer dictionaries.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
109
162
|
## Git Configuration
|
|
110
163
|
|
|
111
164
|
It is recommended to ignore auto-generated Intlayer files:
|
|
@@ -122,5 +175,3 @@ These files can be regenerated during your build process and do not need to be c
|
|
|
122
175
|
For an improved developer experience, install the official **Intlayer VS Code Extension**:
|
|
123
176
|
|
|
124
177
|
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
125
|
-
|
|
126
|
-
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -16,6 +16,9 @@ slugs:
|
|
|
16
16
|
- blog
|
|
17
17
|
- intlayer-with-next-i18next
|
|
18
18
|
history:
|
|
19
|
+
- version: 7.0.6
|
|
20
|
+
date: 2025-11-01
|
|
21
|
+
changes: Add loadJSON plugin
|
|
19
22
|
- version: 7.0.0
|
|
20
23
|
date: 2025-10-29
|
|
21
24
|
changes: Change to syncJSON plugin and comprehensive rewrite
|
|
@@ -76,13 +79,13 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
76
79
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
77
80
|
```
|
|
78
81
|
|
|
82
|
+
```bash packageManager="bun"
|
|
83
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
84
|
+
```
|
|
85
|
+
|
|
79
86
|
**Package explanations:**
|
|
80
87
|
|
|
81
88
|
- **intlayer**: Core library for content declaration and management
|
|
82
|
-
- **next-intlayer**: Next.js integration layer with build plugins
|
|
83
|
-
- **i18next**: Core i18n framework
|
|
84
|
-
- **next-i18next**: Next.js wrapper for i18next
|
|
85
|
-
- **i18next-resources-to-backend**: Dynamic resource loading for i18next
|
|
86
89
|
- **@intlayer/sync-json-plugin**: Plugin to synchronise Intlayer content declarations to i18next JSON format
|
|
87
90
|
|
|
88
91
|
### Step 2: Implement the Intlayer plugin to wrap the JSON
|
|
@@ -102,7 +105,7 @@ const config: IntlayerConfig = {
|
|
|
102
105
|
},
|
|
103
106
|
plugins: [
|
|
104
107
|
syncJSON({
|
|
105
|
-
source: ({ key, locale }) => `./
|
|
108
|
+
source: ({ key, locale }) => `./public/locales/${locale}/${key}.json`,
|
|
106
109
|
}),
|
|
107
110
|
],
|
|
108
111
|
};
|
|
@@ -115,10 +118,55 @@ The `syncJSON` plugin will automatically wrap the JSON. It will read and write t
|
|
|
115
118
|
If you want to make that JSON coexist with Intlayer content declaration files (`.content` files), Intlayer will proceed as follows:
|
|
116
119
|
|
|
117
120
|
1. load both JSON and content declaration files and transform them into an Intlayer dictionary.
|
|
118
|
-
2. if there are conflicts between the JSON and the content declaration files, Intlayer will
|
|
121
|
+
2. if there are conflicts between the JSON and the content declaration files, Intlayer will merge all those dictionaries. This depends on the priority of the plugins, and that of the content declaration file (all are configurable).
|
|
119
122
|
|
|
120
123
|
If changes are made using the CLI to translate the JSON, or using the CMS, Intlayer will update the JSON file with the new translations.
|
|
121
124
|
|
|
125
|
+
To see more details about the `syncJSON` plugin, please refer to the [syncJSON plugin documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/plugins/sync-json.md).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
130
|
+
|
|
131
|
+
By default, Intlayer will load, merge and synchronise both JSON and content declaration files. See [the content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md) for more details. But if you prefer, using an Intlayer plugin, you can also implement per-component management of JSON localised anywhere in your codebase.
|
|
132
|
+
|
|
133
|
+
For that, you can use the `loadJSON` plugin.
|
|
134
|
+
|
|
135
|
+
```ts fileName="intlayer.config.ts"
|
|
136
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
137
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
138
|
+
|
|
139
|
+
const config: IntlayerConfig = {
|
|
140
|
+
internationalization: {
|
|
141
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
142
|
+
defaultLocale: Locales.ENGLISH,
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
// Keep your current JSON files in sync with Intlayer dictionaries
|
|
146
|
+
plugins: [
|
|
147
|
+
/**
|
|
148
|
+
* Will load all the JSON files in the src that match the pattern {key}.i18n.json
|
|
149
|
+
*/
|
|
150
|
+
loadJSON({
|
|
151
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
152
|
+
locale: Locales.ENGLISH,
|
|
153
|
+
priority: 1, // Ensures these JSON files take precedence over files at `./public/locales/en/${key}.json`
|
|
154
|
+
}),
|
|
155
|
+
/**
|
|
156
|
+
* Will load, and write the output and translations back to the JSON files in the locales directory
|
|
157
|
+
*/
|
|
158
|
+
syncJSON({
|
|
159
|
+
source: ({ key, locale }) => `./public/locales/${locale}/${key}.json`,
|
|
160
|
+
priority: 0,
|
|
161
|
+
}),
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export default config;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
This will load all the JSON files in the `src` directory that match the pattern `{key}.i18n.json` and load them as Intlayer dictionaries.
|
|
169
|
+
|
|
122
170
|
---
|
|
123
171
|
|
|
124
172
|
## Git Configuration
|
|
@@ -135,8 +183,6 @@ These files are automatically regenerated during the build process and do not ne
|
|
|
135
183
|
|
|
136
184
|
### VS Code Extension
|
|
137
185
|
|
|
138
|
-
For
|
|
139
|
-
|
|
140
|
-
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
186
|
+
For improved developer experience, install the official **Intlayer VS Code Extension**:
|
|
141
187
|
|
|
142
188
|
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -7,6 +7,9 @@ slugs:
|
|
|
7
7
|
- blog
|
|
8
8
|
- intlayer-with-next-intl
|
|
9
9
|
history:
|
|
10
|
+
- version: 7.0.6
|
|
11
|
+
date: 2025-11-01
|
|
12
|
+
changes: Add loadJSON plugin
|
|
10
13
|
- version: 7.0.0
|
|
11
14
|
date: 2025-10-29
|
|
12
15
|
changes: Change to syncJSON plugin
|
|
@@ -54,6 +57,10 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
54
57
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
55
58
|
```
|
|
56
59
|
|
|
60
|
+
```bash packageManager="bun"
|
|
61
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
62
|
+
```
|
|
63
|
+
|
|
57
64
|
**Package descriptions:**
|
|
58
65
|
|
|
59
66
|
- **intlayer**: Core library for internationalisation management, content declaration, and building
|
|
@@ -70,7 +77,7 @@ import { Locales, type IntlayerConfig } from "intlayer";
|
|
|
70
77
|
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
71
78
|
|
|
72
79
|
const config: IntlayerConfig = {
|
|
73
|
-
|
|
80
|
+
internationalisation: {
|
|
74
81
|
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
75
82
|
defaultLocale: Locales.ENGLISH,
|
|
76
83
|
},
|
|
@@ -86,13 +93,57 @@ export default config;
|
|
|
86
93
|
|
|
87
94
|
The `syncJSON` plugin will automatically wrap the JSON. It will read and write the JSON files without changing the content architecture.
|
|
88
95
|
|
|
89
|
-
If you want to make that JSON coexist with
|
|
96
|
+
If you want to make that JSON coexist with intlayer content declaration files (`.content` files), Intlayer will proceed as follows:
|
|
97
|
+
|
|
98
|
+
1. load both JSON and content declaration files and transform them into an intlayer dictionary.
|
|
90
99
|
|
|
91
|
-
|
|
92
|
-
2. if there are conflicts between the JSON and the content declaration files, Intlayer will proceed to merge all those dictionaries. This depends on the priority of the plugins and that of the content declaration file (all are configurable).
|
|
100
|
+
2. if there are conflicts between the JSON and the content declaration files, Intlayer will proceed to merge all those dictionaries. This depends on the priority of the plugins, and that of the content declaration file (all are configurable).
|
|
93
101
|
|
|
94
102
|
If changes are made using the CLI to translate the JSON, or using the CMS, Intlayer will update the JSON file with the new translations.
|
|
95
103
|
|
|
104
|
+
For more details about the `syncJSON` plugin, please refer to the [syncJSON plugin documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/plugins/sync-json.md).
|
|
105
|
+
|
|
106
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
107
|
+
|
|
108
|
+
By default, Intlayer will load, merge and synchronise both JSON and content declaration files. See [the content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/content_file.md) for more details. However, if you prefer, using an Intlayer plugin, you can also implement per-component management of JSON localised anywhere in your codebase.
|
|
109
|
+
|
|
110
|
+
For that, you can use the `loadJSON` plugin.
|
|
111
|
+
|
|
112
|
+
```ts fileName="intlayer.config.ts"
|
|
113
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
114
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
115
|
+
|
|
116
|
+
const config: IntlayerConfig = {
|
|
117
|
+
internationalization: {
|
|
118
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
119
|
+
defaultLocale: Locales.ENGLISH,
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
// Keep your current JSON files in sync with Intlayer dictionaries
|
|
123
|
+
plugins: [
|
|
124
|
+
/**
|
|
125
|
+
* Will load all the JSON files in the src that match the pattern {key}.i18n.json
|
|
126
|
+
*/
|
|
127
|
+
loadJSON({
|
|
128
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
129
|
+
locale: Locales.ENGLISH,
|
|
130
|
+
priority: 1, // Ensures these JSON files take precedence over files at `./locales/en/${key}.json`
|
|
131
|
+
}),
|
|
132
|
+
/**
|
|
133
|
+
* Will load, and write the output and translations back to the JSON files in the locales directory
|
|
134
|
+
*/
|
|
135
|
+
syncJSON({
|
|
136
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
137
|
+
priority: 0,
|
|
138
|
+
}),
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default config;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This will load all the JSON files in the `src` directory that match the pattern `{key}.i18n.json` and load them as Intlayer dictionaries.
|
|
146
|
+
|
|
96
147
|
## Git Configuration
|
|
97
148
|
|
|
98
149
|
It is recommended to ignore auto-generated Intlayer files:
|
|
@@ -109,5 +160,3 @@ These files can be regenerated during your build process and do not need to be c
|
|
|
109
160
|
For an improved developer experience, install the official **Intlayer VS Code Extension**:
|
|
110
161
|
|
|
111
162
|
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
112
|
-
|
|
113
|
-
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -18,6 +18,9 @@ slugs:
|
|
|
18
18
|
- blog
|
|
19
19
|
- intlayer-with-react-i18next
|
|
20
20
|
history:
|
|
21
|
+
- version: 7.0.6
|
|
22
|
+
date: 2025-11-01
|
|
23
|
+
changes: Add loadJSON plugin
|
|
21
24
|
- version: 7.0.0
|
|
22
25
|
date: 2025-10-29
|
|
23
26
|
changes: Change to syncJSON plugin
|
|
@@ -38,10 +41,11 @@ While Intlayer provides an excellent standalone i18n solution (see our [React in
|
|
|
38
41
|
1. **Existing codebase**: You have an established react-i18next implementation and want to gradually migrate to Intlayer's improved developer experience.
|
|
39
42
|
2. **Legacy requirements**: Your project requires compatibility with existing react-i18next plugins or workflows.
|
|
40
43
|
3. **Team familiarity**: Your team is comfortable with react-i18next but wants better content management.
|
|
44
|
+
4. **Using Intlayer features**: You want to use Intlayer features like content declaration, translation automation, testing translations, and more.
|
|
41
45
|
|
|
42
46
|
**For that, Intlayer can be implemented as an adapter for react-i18next to help automate your JSON translations in CLI or CI/CD pipelines, test your translations, and more.**
|
|
43
47
|
|
|
44
|
-
This guide shows you how to leverage Intlayer's superior content declaration system
|
|
48
|
+
This guide shows you how to leverage Intlayer's superior content declaration system whilst maintaining compatibility with react-i18next.
|
|
45
49
|
|
|
46
50
|
## Table of Contents
|
|
47
51
|
|
|
@@ -65,6 +69,10 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
65
69
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
66
70
|
```
|
|
67
71
|
|
|
72
|
+
```bash packageManager="bun"
|
|
73
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
74
|
+
```
|
|
75
|
+
|
|
68
76
|
**Package descriptions:**
|
|
69
77
|
|
|
70
78
|
- **intlayer**: Core library for internationalisation management, content declaration, and building
|
|
@@ -74,7 +82,7 @@ yarn add intlayer @intlayer/sync-json-plugin
|
|
|
74
82
|
|
|
75
83
|
Create an Intlayer configuration file to define your supported locales:
|
|
76
84
|
|
|
77
|
-
**If you want to
|
|
85
|
+
**If you also want to export JSON dictionaries for react-i18next**, add the `syncJSON` plugin:
|
|
78
86
|
|
|
79
87
|
```typescript fileName="intlayer.config.ts"
|
|
80
88
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -87,7 +95,7 @@ const config: IntlayerConfig = {
|
|
|
87
95
|
},
|
|
88
96
|
plugins: [
|
|
89
97
|
syncJSON({
|
|
90
|
-
source: ({ key, locale }) => `./
|
|
98
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
91
99
|
}),
|
|
92
100
|
],
|
|
93
101
|
};
|
|
@@ -99,12 +107,53 @@ The `syncJSON` plugin will automatically wrap the JSON. It will read and write t
|
|
|
99
107
|
|
|
100
108
|
If you want to make that JSON coexist with Intlayer content declaration files (`.content` files), Intlayer will proceed as follows:
|
|
101
109
|
|
|
102
|
-
1.
|
|
103
|
-
2.
|
|
110
|
+
1. Load both JSON and content declaration files and transform them into an Intlayer dictionary.
|
|
111
|
+
2. If there are conflicts between the JSON and the content declaration files, Intlayer will merge all those dictionaries. This depends on the priority of the plugins and that of the content declaration file (all are configurable).
|
|
104
112
|
|
|
105
113
|
If changes are made using the CLI to translate the JSON, or using the CMS, Intlayer will update the JSON file with the new translations.
|
|
106
114
|
|
|
107
|
-
|
|
115
|
+
To see more details about the `syncJSON` plugin, please refer to the [syncJSON plugin documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/plugins/sync-json.md).
|
|
116
|
+
|
|
117
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
118
|
+
|
|
119
|
+
By default, Intlayer will load, merge and synchronise both JSON and content declaration files. See [the content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/content_file.md) for more details. But if you prefer, using an Intlayer plugin, you can also implement per-component management of JSON localised anywhere in your codebase.
|
|
120
|
+
|
|
121
|
+
For that, you can use the `loadJSON` plugin.
|
|
122
|
+
|
|
123
|
+
```ts fileName="intlayer.config.ts"
|
|
124
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
125
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
126
|
+
|
|
127
|
+
const config: IntlayerConfig = {
|
|
128
|
+
internationalisation: {
|
|
129
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
130
|
+
defaultLocale: Locales.ENGLISH,
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
// Keep your current JSON files in sync with Intlayer dictionaries
|
|
134
|
+
plugins: [
|
|
135
|
+
/**
|
|
136
|
+
* Will load all the JSON files in the src that match the pattern {key}.i18n.json
|
|
137
|
+
*/
|
|
138
|
+
loadJSON({
|
|
139
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
140
|
+
locale: Locales.ENGLISH,
|
|
141
|
+
priority: 1, // Ensures these JSON files take precedence over files at `./locales/en/${key}.json`
|
|
142
|
+
}),
|
|
143
|
+
/**
|
|
144
|
+
* Will load, and write the output and translations back to the JSON files in the locales directory
|
|
145
|
+
*/
|
|
146
|
+
syncJSON({
|
|
147
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
148
|
+
priority: 0,
|
|
149
|
+
}),
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default config;
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This will load all the JSON files in the `src` directory that match the pattern `{key}.i18n.json` and load them as Intlayer dictionaries.
|
|
108
157
|
|
|
109
158
|
## Git Configuration
|
|
110
159
|
|
|
@@ -16,6 +16,9 @@ slugs:
|
|
|
16
16
|
- blog
|
|
17
17
|
- intlayer-with-react-intl
|
|
18
18
|
history:
|
|
19
|
+
- version: 7.0.6
|
|
20
|
+
date: 2025-11-01
|
|
21
|
+
changes: Add loadJSON plugin
|
|
19
22
|
- version: 7.0.0
|
|
20
23
|
date: 2025-10-29
|
|
21
24
|
changes: Change to syncJSON plugin
|
|
@@ -23,6 +26,10 @@ history:
|
|
|
23
26
|
|
|
24
27
|
# How to automate your react-intl JSON translations using Intlayer
|
|
25
28
|
|
|
29
|
+
## Table of Contents
|
|
30
|
+
|
|
31
|
+
<TOC/>
|
|
32
|
+
|
|
26
33
|
## What is Intlayer?
|
|
27
34
|
|
|
28
35
|
**Intlayer** is an innovative, open-source internationalisation library designed to address the shortcomings of traditional i18n solutions. It offers a modern approach to content management in React applications.
|
|
@@ -36,6 +43,7 @@ While Intlayer provides an excellent standalone i18n solution (see our [React in
|
|
|
36
43
|
1. **Existing codebase**: You have an established react-intl implementation and want to gradually migrate to Intlayer's improved developer experience.
|
|
37
44
|
2. **Legacy requirements**: Your project requires compatibility with existing react-intl plugins or workflows.
|
|
38
45
|
3. **Team familiarity**: Your team is comfortable with react-intl but wants better content management.
|
|
46
|
+
4. **Using Intlayer features**: You want to use Intlayer features like content declaration, translation automation, testing translations, and more.
|
|
39
47
|
|
|
40
48
|
**For that, Intlayer can be implemented as an adapter for react-intl to help automate your JSON translations in CLI or CI/CD pipelines, test your translations, and more.**
|
|
41
49
|
|
|
@@ -63,6 +71,10 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
63
71
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
64
72
|
```
|
|
65
73
|
|
|
74
|
+
```bash packageManager="bun"
|
|
75
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
76
|
+
```
|
|
77
|
+
|
|
66
78
|
**Package descriptions:**
|
|
67
79
|
|
|
68
80
|
- **intlayer**: Core library for internationalisation management, content declaration, and building
|
|
@@ -72,7 +84,7 @@ yarn add intlayer @intlayer/sync-json-plugin
|
|
|
72
84
|
|
|
73
85
|
Create an Intlayer configuration file to define your supported locales:
|
|
74
86
|
|
|
75
|
-
**If you want to
|
|
87
|
+
**If you also want to export JSON dictionaries for react-intl**, add the `syncJSON` plugin:
|
|
76
88
|
|
|
77
89
|
```typescript fileName="intlayer.config.ts"
|
|
78
90
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -98,11 +110,52 @@ The `syncJSON` plugin will automatically wrap the JSON. It will read and write t
|
|
|
98
110
|
If you want to make that JSON coexist with Intlayer content declaration files (`.content` files), Intlayer will proceed as follows:
|
|
99
111
|
|
|
100
112
|
1. load both JSON and content declaration files and transform them into an Intlayer dictionary.
|
|
101
|
-
2. if there are conflicts between the JSON and the content declaration files, Intlayer will
|
|
113
|
+
2. if there are conflicts between the JSON and the content declaration files, Intlayer will merge all those dictionaries. This depends on the priority of the plugins and that of the content declaration file (all are configurable).
|
|
102
114
|
|
|
103
115
|
If changes are made using the CLI to translate the JSON, or using the CMS, Intlayer will update the JSON file with the new translations.
|
|
104
116
|
|
|
105
|
-
|
|
117
|
+
To see more details about the `syncJSON` plugin, please refer to the [syncJSON plugin documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/plugins/sync-json.md).
|
|
118
|
+
|
|
119
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
120
|
+
|
|
121
|
+
By default, Intlayer will load, merge and synchronise both JSON and content declaration files. See [the content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md) for more details. But if you prefer, using an Intlayer plugin, you can also implement per-component management of JSON localised anywhere in your codebase.
|
|
122
|
+
|
|
123
|
+
For that, you can use the `loadJSON` plugin.
|
|
124
|
+
|
|
125
|
+
```ts fileName="intlayer.config.ts"
|
|
126
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
127
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
128
|
+
|
|
129
|
+
const config: IntlayerConfig = {
|
|
130
|
+
internationalisation: {
|
|
131
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
132
|
+
defaultLocale: Locales.ENGLISH,
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// Keep your current JSON files in sync with Intlayer dictionaries
|
|
136
|
+
plugins: [
|
|
137
|
+
/**
|
|
138
|
+
* Will load all the JSON files in the src that match the pattern {key}.i18n.json
|
|
139
|
+
*/
|
|
140
|
+
loadJSON({
|
|
141
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
142
|
+
locale: Locales.ENGLISH,
|
|
143
|
+
priority: 1, // Ensures these JSON files take precedence over files at `./locales/en/${key}.json`
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Will load, and write the output and translations back to the JSON files in the locales directory
|
|
147
|
+
*/
|
|
148
|
+
syncJSON({
|
|
149
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
150
|
+
priority: 0,
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
This will load all the JSON files in the `src` directory that match the pattern `{key}.i18n.json` and load them as Intlayer dictionaries.
|
|
106
159
|
|
|
107
160
|
## Git Configuration
|
|
108
161
|
|