@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 internationalization 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 automation, testing translations, and more.
|
|
43
47
|
|
|
44
48
|
**For that, Intlayer can be implemented as an adapter for i18next to help automating your JSON translations in CLI or CI/CD pipelines, testing 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 internationalization management, content declaration, and building
|
|
@@ -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
|
};
|
|
@@ -108,6 +116,49 @@ If changes are made using the CLI to translate the JSON, or using the CMS, Intla
|
|
|
108
116
|
|
|
109
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).
|
|
110
118
|
|
|
119
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
120
|
+
|
|
121
|
+
By default, Intlayer will load, merge and synchronize 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 a Intlayer plugin, you can also implement per-component management of JSON localized 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
|
+
internationalization: {
|
|
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
|
+
|
|
111
162
|
## Git Configuration
|
|
112
163
|
|
|
113
164
|
It's recommended to ignore auto-generated Intlayer files:
|
|
@@ -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
|
|
@@ -27,17 +30,6 @@ history:
|
|
|
27
30
|
|
|
28
31
|
<TOC/>
|
|
29
32
|
|
|
30
|
-
## What is next-i18next?
|
|
31
|
-
|
|
32
|
-
**next-i18next** is one of the most popular internationalization (i18n) frameworks for Next.js applications. Built on top of the powerful **i18next** ecosystem, it provides a comprehensive solution for managing translations, localization, and language switching in Next.js projects.
|
|
33
|
-
|
|
34
|
-
However, next-i18next comes with some challenges:
|
|
35
|
-
|
|
36
|
-
- **Complex configuration**: Setting up next-i18next requires multiple configuration files and careful setup of server-side and client-side i18n instances.
|
|
37
|
-
- **Scattered translations**: Translation files are typically stored in separate directories from components, making it harder to maintain consistency.
|
|
38
|
-
- **Manual namespace management**: Developers need to manually manage namespaces and ensure proper loading of translation resources.
|
|
39
|
-
- **Limited type safety**: TypeScript support requires additional configuration and doesn't provide automatic type generation for translations.
|
|
40
|
-
|
|
41
33
|
## What is Intlayer?
|
|
42
34
|
|
|
43
35
|
**Intlayer** is an innovative, open-source internationalization library designed to address the shortcomings of traditional i18n solutions. It offers a modern approach to content management in Next.js applications.
|
|
@@ -51,6 +43,7 @@ While Intlayer provides an excellent standalone i18n solution (see our [Next.js
|
|
|
51
43
|
1. **Existing codebase**: You have an established next-i18next implementation and want to gradually migrate to Intlayer's improved developer experience.
|
|
52
44
|
2. **Legacy requirements**: Your project requires compatibility with existing i18next plugins or workflows.
|
|
53
45
|
3. **Team familiarity**: Your team is comfortable with next-i18next 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.
|
|
54
47
|
|
|
55
48
|
**For that, Intlayer can be implemented as an adapter for next-i18next to help automating your JSON translations in CLI or CI/CD pipelines, testing your translations, and more.**
|
|
56
49
|
|
|
@@ -76,13 +69,13 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
76
69
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
77
70
|
```
|
|
78
71
|
|
|
72
|
+
```bash packageManager="bun"
|
|
73
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
74
|
+
```
|
|
75
|
+
|
|
79
76
|
**Package explanations:**
|
|
80
77
|
|
|
81
78
|
- **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
79
|
- **@intlayer/sync-json-plugin**: Plugin to sync Intlayer content declarations to i18next JSON format
|
|
87
80
|
|
|
88
81
|
### Step 2: Implement the Intlayer plugin to wrap the JSON
|
|
@@ -102,7 +95,7 @@ const config: IntlayerConfig = {
|
|
|
102
95
|
},
|
|
103
96
|
plugins: [
|
|
104
97
|
syncJSON({
|
|
105
|
-
source: ({ key, locale }) => `./
|
|
98
|
+
source: ({ key, locale }) => `./public/locales/${locale}/${key}.json`,
|
|
106
99
|
}),
|
|
107
100
|
],
|
|
108
101
|
};
|
|
@@ -123,6 +116,49 @@ To see more details about the `syncJSON` plugin, please refer to the [syncJSON p
|
|
|
123
116
|
|
|
124
117
|
---
|
|
125
118
|
|
|
119
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
120
|
+
|
|
121
|
+
By default, Intlayer will load, merge and synchronize 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 a Intlayer plugin, you can also implement per-component management of JSON localized 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
|
+
internationalization: {
|
|
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 `./public/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 }) => `./public/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
|
+
|
|
126
162
|
## Git Configuration
|
|
127
163
|
|
|
128
164
|
Exclude generated files from version control:
|
|
@@ -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
|
|
@@ -27,6 +30,7 @@ While Intlayer provides an excellent standalone i18n solution (see our [Next.js
|
|
|
27
30
|
1. **Existing codebase**: You have an established next-intl implementation and want to gradually migrate to Intlayer's improved developer experience.
|
|
28
31
|
2. **Legacy requirements**: Your project requires compatibility with existing next-intl plugins or workflows.
|
|
29
32
|
3. **Team familiarity**: Your team is comfortable with next-intl but wants better content management.
|
|
33
|
+
4. **Using Intlayer features**: You want to use Intlayer features like content declaration, translation automation, testing translations, and more.
|
|
30
34
|
|
|
31
35
|
**For that, Intlayer can be implemented as an adapter for next-intl to help automating your JSON translations in CLI or CI/CD pipelines, testing your translations, and more.**
|
|
32
36
|
|
|
@@ -54,6 +58,10 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
54
58
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
55
59
|
```
|
|
56
60
|
|
|
61
|
+
```bash packageManager="bun"
|
|
62
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
63
|
+
```
|
|
64
|
+
|
|
57
65
|
**Package descriptions:**
|
|
58
66
|
|
|
59
67
|
- **intlayer**: Core library for internationalization management, content declaration, and building
|
|
@@ -95,6 +103,47 @@ If changes are made using the CLI to translate the JSON, or using the CMS, Intla
|
|
|
95
103
|
|
|
96
104
|
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).
|
|
97
105
|
|
|
106
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
107
|
+
|
|
108
|
+
By default, Intlayer will load, merge and synchronize 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 a Intlayer plugin, you can also implement per-component management of JSON localized 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
|
+
|
|
98
147
|
## Git Configuration
|
|
99
148
|
|
|
100
149
|
It's recommended to ignore auto-generated Intlayer files:
|
|
@@ -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,6 +41,7 @@ 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 automating your JSON translations in CLI or CI/CD pipelines, testing your translations, and more.**
|
|
43
47
|
|
|
@@ -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 internationalization management, content declaration, and building
|
|
@@ -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
|
};
|
|
@@ -106,6 +114,47 @@ If changes are made using the CLI to translate the JSON, or using the CMS, Intla
|
|
|
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/plugins/sync-json.md).
|
|
108
116
|
|
|
117
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
118
|
+
|
|
119
|
+
By default, Intlayer will load, merge and synchronize 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 a Intlayer plugin, you can also implement per-component management of JSON localized 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
|
+
internationalization: {
|
|
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.
|
|
157
|
+
|
|
109
158
|
## Git Configuration
|
|
110
159
|
|
|
111
160
|
It's recommended to ignore auto-generated Intlayer files:
|
|
@@ -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 internationalization 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 automating your JSON translations in CLI or CI/CD pipelines, testing 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 internationalization management, content declaration, and building
|
|
@@ -104,6 +116,47 @@ If changes are made using the CLI to translate the JSON, or using the CMS, Intla
|
|
|
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).
|
|
106
118
|
|
|
119
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
120
|
+
|
|
121
|
+
By default, Intlayer will load, merge and synchronize 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 a Intlayer plugin, you can also implement per-component management of JSON localized 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
|
+
internationalization: {
|
|
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.
|
|
159
|
+
|
|
107
160
|
## Git Configuration
|
|
108
161
|
|
|
109
162
|
It's recommended to ignore auto-generated Intlayer files:
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-08-23
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
|
+
title: Intlayer and vue-i18n
|
|
5
|
+
description: Integrate Intlayer with vue-i18n for a comprehensive Vue.js internationalization solution
|
|
6
|
+
keywords:
|
|
7
|
+
- vue-i18n
|
|
8
|
+
- Intlayer
|
|
9
|
+
- Internationalization
|
|
10
|
+
- Blog
|
|
11
|
+
- Vue.js
|
|
12
|
+
- Nuxt
|
|
13
|
+
- JavaScript
|
|
14
|
+
- Vue
|
|
15
|
+
slugs:
|
|
16
|
+
- blog
|
|
17
|
+
- intlayer-with-vue-i18n
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.0.6
|
|
20
|
+
date: 2025-11-01
|
|
21
|
+
changes: Add loadJSON plugin
|
|
22
|
+
- version: 7.0.0
|
|
23
|
+
date: 2025-10-29
|
|
24
|
+
changes: Change to syncJSON plugin and comprehensive rewrite
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Vue.js Internationalization (i18n) with vue-i18n and Intlayer
|
|
28
|
+
|
|
29
|
+
## Table of Contents
|
|
30
|
+
|
|
31
|
+
<TOC/>
|
|
32
|
+
|
|
33
|
+
## What is Intlayer?
|
|
34
|
+
|
|
35
|
+
**Intlayer** is an innovative, open-source internationalization library designed to address the shortcomings of traditional i18n solutions. It offers a modern approach to content management in Vue.js and Nuxt applications.
|
|
36
|
+
|
|
37
|
+
See a concrete comparison with vue-i18n in our [vue-i18n vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/vue-i18n_vs_intlayer.md) blog post.
|
|
38
|
+
|
|
39
|
+
## Why Combine Intlayer with vue-i18n?
|
|
40
|
+
|
|
41
|
+
While Intlayer provides an excellent standalone i18n solution (see our [Vue.js integration guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite+vue.md)), you might want to combine it with vue-i18n for several reasons:
|
|
42
|
+
|
|
43
|
+
1. **Existing codebase**: You have an established vue-i18n implementation and want to gradually migrate to Intlayer's improved developer experience.
|
|
44
|
+
2. **Legacy requirements**: Your project requires compatibility with existing vue-i18n plugins or workflows.
|
|
45
|
+
3. **Team familiarity**: Your team is comfortable with vue-i18n 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.
|
|
47
|
+
|
|
48
|
+
**For that, Intlayer can be implemented as an adapter for vue-i18n to help automating your JSON translations in CLI or CI/CD pipelines, testing your translations, and more.**
|
|
49
|
+
|
|
50
|
+
This guide shows you how to leverage Intlayer's superior content declaration system while maintaining compatibility with vue-i18n.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Step-by-Step Guide to Set Up Intlayer with vue-i18n
|
|
55
|
+
|
|
56
|
+
### Step 1: Install Dependencies
|
|
57
|
+
|
|
58
|
+
Install the necessary packages using your preferred package manager:
|
|
59
|
+
|
|
60
|
+
```bash packageManager="npm"
|
|
61
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```bash packageManager="pnpm"
|
|
65
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```bash packageManager="yarn"
|
|
69
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```bash packageManager="bun"
|
|
73
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Package explanations:**
|
|
77
|
+
|
|
78
|
+
- **intlayer**: Core library for content declaration and management
|
|
79
|
+
- **@intlayer/sync-json-plugin**: Plugin to sync Intlayer content declarations to vue-i18n JSON format
|
|
80
|
+
|
|
81
|
+
### Step 2: Implement the Intlayer plugin to wrap the JSON
|
|
82
|
+
|
|
83
|
+
Create an Intlayer configuration file to define your supported locales:
|
|
84
|
+
|
|
85
|
+
**If you want to also export JSON dictionaries for vue-i18n**, add the `syncJSON` plugin:
|
|
86
|
+
|
|
87
|
+
```typescript fileName="intlayer.config.ts"
|
|
88
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
89
|
+
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
90
|
+
|
|
91
|
+
const config: IntlayerConfig = {
|
|
92
|
+
internationalization: {
|
|
93
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
94
|
+
defaultLocale: Locales.ENGLISH,
|
|
95
|
+
},
|
|
96
|
+
plugins: [
|
|
97
|
+
syncJSON({
|
|
98
|
+
source: ({ key, locale }) => `./src/locales/${locale}/${key}.json`,
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default config;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The `syncJSON` plugin will automatically wrap the JSON. It will read and write the JSON files without changing the content architecture.
|
|
107
|
+
|
|
108
|
+
If you want to make coexist that JSON with intlayer content declaration files (`.content` files), Intlayer will proceed this way:
|
|
109
|
+
|
|
110
|
+
1. load both JSON and content declaration files and transform them into a intlayer dictionary.
|
|
111
|
+
2. if there is conflicts between the JSON and the content declaration files, Intlayer will process to the merge of that all dictionaries. Depending of the priority of the plugins, and the one of the content declaration file (all are configurable).
|
|
112
|
+
|
|
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.
|
|
114
|
+
|
|
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/plugins/sync-json.md).
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### (Optional) Step 3: Implement per-component JSON translations
|
|
120
|
+
|
|
121
|
+
By default, Intlayer will load, merge and synchronize 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 a Intlayer plugin, you can also implement per-component management of JSON localized 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
|
+
internationalization: {
|
|
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 }) => `./src/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
|
+
|
|
162
|
+
## Git Configuration
|
|
163
|
+
|
|
164
|
+
Exclude generated files from version control:
|
|
165
|
+
|
|
166
|
+
```plaintext fileName=".gitignore"
|
|
167
|
+
# Ignore files generated by Intlayer
|
|
168
|
+
.intlayer
|
|
169
|
+
intl
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
These files are automatically regenerated during the build process and don't need to be committed to your repository.
|
|
173
|
+
|
|
174
|
+
### VS Code Extension
|
|
175
|
+
|
|
176
|
+
For improved developer experience, install the official **Intlayer VS Code Extension**:
|
|
177
|
+
|
|
178
|
+
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|