@intlayer/docs 7.0.4-canary.0 → 7.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blog/ar/intlayer_with_i18next.md +68 -106
- package/blog/ar/intlayer_with_next-i18next.md +84 -288
- package/blog/ar/intlayer_with_next-intl.md +58 -337
- package/blog/ar/intlayer_with_react-i18next.md +68 -290
- package/blog/ar/intlayer_with_react-intl.md +63 -266
- package/blog/de/intlayer_with_i18next.md +77 -97
- package/blog/de/intlayer_with_next-i18next.md +69 -296
- package/blog/de/intlayer_with_next-intl.md +59 -340
- package/blog/de/intlayer_with_react-i18next.md +68 -290
- package/blog/de/intlayer_with_react-intl.md +62 -264
- package/blog/en/intlayer_with_i18next.md +36 -1638
- package/blog/en/intlayer_with_next-i18next.md +22 -847
- package/blog/en/intlayer_with_next-intl.md +32 -1053
- package/blog/en/intlayer_with_react-i18next.md +38 -764
- package/blog/en/intlayer_with_react-intl.md +42 -1018
- package/blog/en-GB/intlayer_with_i18next.md +67 -103
- package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
- package/blog/en-GB/intlayer_with_next-intl.md +58 -337
- package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
- package/blog/en-GB/intlayer_with_react-intl.md +61 -264
- package/blog/es/intlayer_with_i18next.md +67 -103
- package/blog/es/intlayer_with_next-i18next.md +71 -296
- package/blog/es/intlayer_with_next-intl.md +57 -338
- package/blog/es/intlayer_with_react-i18next.md +68 -290
- package/blog/es/intlayer_with_react-intl.md +62 -265
- package/blog/fr/intlayer_with_i18next.md +66 -104
- package/blog/fr/intlayer_with_next-i18next.md +82 -285
- package/blog/fr/intlayer_with_next-intl.md +57 -338
- package/blog/fr/intlayer_with_react-i18next.md +67 -289
- package/blog/fr/intlayer_with_react-intl.md +61 -264
- package/blog/hi/intlayer_with_i18next.md +68 -104
- package/blog/hi/intlayer_with_next-i18next.md +74 -299
- package/blog/hi/intlayer_with_next-intl.md +57 -239
- package/blog/hi/intlayer_with_react-i18next.md +69 -291
- package/blog/hi/intlayer_with_react-intl.md +65 -268
- package/blog/id/intlayer_with_i18next.md +126 -0
- package/blog/id/intlayer_with_next-i18next.md +142 -0
- package/blog/id/intlayer_with_next-intl.md +113 -0
- package/blog/id/intlayer_with_react-i18next.md +124 -0
- package/blog/id/intlayer_with_react-intl.md +122 -0
- package/blog/it/intlayer_with_i18next.md +67 -103
- package/blog/it/intlayer_with_next-i18next.md +71 -296
- package/blog/it/intlayer_with_next-intl.md +57 -338
- package/blog/it/intlayer_with_react-i18next.md +68 -290
- package/blog/it/intlayer_with_react-intl.md +62 -265
- package/blog/ja/intlayer_with_i18next.md +68 -103
- package/blog/ja/intlayer_with_next-i18next.md +85 -283
- package/blog/ja/intlayer_with_next-intl.md +58 -336
- package/blog/ja/intlayer_with_react-i18next.md +68 -290
- package/blog/ja/intlayer_with_react-intl.md +62 -264
- package/blog/ko/intlayer_with_i18next.md +80 -96
- package/blog/ko/intlayer_with_next-i18next.md +85 -287
- package/blog/ko/intlayer_with_next-intl.md +68 -327
- package/blog/ko/intlayer_with_react-i18next.md +68 -290
- package/blog/ko/intlayer_with_react-intl.md +64 -266
- package/blog/pl/intlayer_with_i18next.md +126 -0
- package/blog/pl/intlayer_with_next-i18next.md +142 -0
- package/blog/pl/intlayer_with_next-intl.md +111 -0
- package/blog/pl/intlayer_with_react-i18next.md +124 -0
- package/blog/pl/intlayer_with_react-intl.md +122 -0
- package/blog/pt/intlayer_with_i18next.md +67 -103
- package/blog/pt/intlayer_with_next-i18next.md +72 -293
- package/blog/pt/intlayer_with_next-intl.md +57 -256
- package/blog/pt/intlayer_with_react-i18next.md +104 -78
- package/blog/pt/intlayer_with_react-intl.md +62 -266
- package/blog/ru/intlayer_with_i18next.md +66 -104
- package/blog/ru/intlayer_with_next-i18next.md +71 -296
- package/blog/ru/intlayer_with_next-intl.md +58 -337
- package/blog/ru/intlayer_with_react-i18next.md +68 -290
- package/blog/ru/intlayer_with_react-intl.md +62 -265
- package/blog/tr/intlayer_with_i18next.md +71 -107
- package/blog/tr/intlayer_with_next-i18next.md +72 -297
- package/blog/tr/intlayer_with_next-intl.md +58 -339
- package/blog/tr/intlayer_with_react-i18next.md +69 -291
- package/blog/tr/intlayer_with_react-intl.md +63 -285
- package/blog/vi/intlayer_with_i18next.md +126 -0
- package/blog/vi/intlayer_with_next-i18next.md +142 -0
- package/blog/vi/intlayer_with_next-intl.md +111 -0
- package/blog/vi/intlayer_with_react-i18next.md +124 -0
- package/blog/vi/intlayer_with_react-intl.md +122 -0
- package/blog/zh/intlayer_with_i18next.md +67 -102
- package/blog/zh/intlayer_with_next-i18next.md +72 -296
- package/blog/zh/intlayer_with_next-intl.md +58 -336
- package/blog/zh/intlayer_with_react-i18next.md +68 -290
- package/blog/zh/intlayer_with_react-intl.md +63 -106
- package/docs/ar/plugins/sync-json.md +244 -0
- package/docs/de/plugins/sync-json.md +244 -0
- package/docs/en/intlayer_cli.md +25 -0
- package/docs/en/intlayer_with_nextjs_14.md +2 -0
- package/docs/en/intlayer_with_nextjs_15.md +2 -0
- package/docs/en/intlayer_with_nextjs_16.md +2 -0
- package/docs/en/plugins/sync-json.md +1 -1
- package/docs/en-GB/plugins/sync-json.md +244 -0
- package/docs/es/plugins/sync-json.md +244 -0
- package/docs/fr/plugins/sync-json.md +244 -0
- package/docs/hi/plugins/sync-json.md +244 -0
- package/docs/id/plugins/sync-json.md +244 -0
- package/docs/it/plugins/sync-json.md +244 -0
- package/docs/ja/plugins/sync-json.md +244 -0
- package/docs/ko/plugins/sync-json.md +244 -0
- package/docs/pl/plugins/sync-json.md +244 -0
- package/docs/pt/plugins/sync-json.md +244 -0
- package/docs/ru/plugins/sync-json.md +244 -0
- package/docs/tr/plugins/sync-json.md +245 -0
- package/docs/vi/plugins/sync-json.md +244 -0
- package/docs/zh/plugins/sync-json.md +244 -0
- package/package.json +14 -14
|
@@ -1,346 +1,124 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-01-02
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title:
|
|
5
|
-
description:
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
|
+
title: How to automate your react-i18next JSON translations using Intlayer
|
|
5
|
+
description: Automate your JSON translations with Intlayer and react-i18next for enhanced internationalisation in React applications.
|
|
6
6
|
keywords:
|
|
7
7
|
- react-i18next
|
|
8
8
|
- i18next
|
|
9
9
|
- Intlayer
|
|
10
10
|
- Internationalisation
|
|
11
|
+
- i18n
|
|
11
12
|
- Blog
|
|
12
|
-
- Next.js
|
|
13
|
-
- JavaScript
|
|
14
13
|
- React
|
|
14
|
+
- JavaScript
|
|
15
|
+
- TypeScript
|
|
16
|
+
- Content Management
|
|
15
17
|
slugs:
|
|
16
18
|
- blog
|
|
17
19
|
- intlayer-with-react-i18next
|
|
20
|
+
history:
|
|
21
|
+
- version: 7.0.0
|
|
22
|
+
date: 2025-10-29
|
|
23
|
+
changes: Change to syncJSON plugin
|
|
18
24
|
---
|
|
19
25
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
## Overview
|
|
23
|
-
|
|
24
|
-
- **Intlayer** helps you manage translations via **component-level** content declaration files.
|
|
25
|
-
- **react-i18next** is a popular React integration for **i18next** that provides hooks like `useTranslation` to fetch localized strings in your components.
|
|
26
|
-
|
|
27
|
-
When combined, Intlayer can **export** dictionaries in **i18next-compatible JSON** so that react-i18next can **consume** them at runtime.
|
|
28
|
-
|
|
29
|
-
## Why Use Intlayer with react-i18next?
|
|
30
|
-
|
|
31
|
-
**Intlayer** content declaration files offer a better developer experience because they are:
|
|
32
|
-
|
|
33
|
-
1. **Flexible in File Placement**
|
|
34
|
-
Put each content declaration file right next to the component that needs it. This structure allows you to keep translations co-located, preventing orphaned translations when components move or get deleted.
|
|
35
|
-
|
|
36
|
-
```bash codeFormat="typescript"
|
|
37
|
-
.
|
|
38
|
-
└── src
|
|
39
|
-
└── components
|
|
40
|
-
└── MyComponent
|
|
41
|
-
├── index.content.ts # Content declaration file
|
|
42
|
-
└── index.tsx
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
```bash codeFormat="esm"
|
|
46
|
-
.
|
|
47
|
-
└── src
|
|
48
|
-
└── components
|
|
49
|
-
└── MyComponent
|
|
50
|
-
├── index.content.mjs # Content declaration file
|
|
51
|
-
└── index.mjx
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
```bash codeFormat="cjs"
|
|
55
|
-
.
|
|
56
|
-
└── src
|
|
57
|
-
└── components
|
|
58
|
-
└── MyComponent
|
|
59
|
-
├── index.content.cjs # Content declaration file
|
|
60
|
-
└── index.cjx
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
```bash codeFormat="json"
|
|
64
|
-
.
|
|
65
|
-
└── src
|
|
66
|
-
└── components
|
|
67
|
-
└── MyComponent
|
|
68
|
-
├── index.content.json # Content declaration file
|
|
69
|
-
└── index.jsx
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
2. **Centralized Translations**
|
|
73
|
-
A single content declaration file collects all necessary translations for a component, making missing translations easier to catch.
|
|
74
|
-
With TypeScript, you even get compile-time errors if translations are missing.
|
|
75
|
-
|
|
76
|
-
## Installation
|
|
77
|
-
|
|
78
|
-
In a Create React App project, install these dependencies:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
# With npm
|
|
82
|
-
npm install intlayer react-i18next i18next i18next-resources-to-backend
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
# With yarn
|
|
87
|
-
yarn add intlayer react-i18next i18next i18next-resources-to-backend
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# With pnpm
|
|
92
|
-
pnpm add intlayer react-i18next i18next i18next-resources-to-backend
|
|
93
|
-
```
|
|
26
|
+
# How to automate your react-i18next JSON translations using Intlayer
|
|
94
27
|
|
|
95
|
-
|
|
28
|
+
## What is Intlayer?
|
|
96
29
|
|
|
97
|
-
|
|
98
|
-
- **react-intlayer** – React-specific integration for Intlayer, providing notably some script to automate the build of dictionaries.
|
|
99
|
-
- **react-i18next** – React-specific integration library for i18next, including the `useTranslation` hook.
|
|
100
|
-
- **i18next** – The underlying framework for translation handling.
|
|
101
|
-
- **i18next-resources-to-backend** – An i18next backend that dynamically imports JSON resources.
|
|
30
|
+
**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.
|
|
102
31
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
Create (or update) your `intlayer.config.ts` in the root of your project:
|
|
106
|
-
|
|
107
|
-
```typescript title="intlayer.config.ts"
|
|
108
|
-
import { Locales, type IntlayerConfig } from "intlayer";
|
|
109
|
-
|
|
110
|
-
const config: IntlayerConfig = {
|
|
111
|
-
internationalization: {
|
|
112
|
-
// Add as many locales as you wish
|
|
113
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
114
|
-
defaultLocale: Locales.ENGLISH,
|
|
115
|
-
},
|
|
116
|
-
content: {
|
|
117
|
-
// Tell Intlayer to create i18next-compatible JSON
|
|
118
|
-
dictionaryOutput: ["i18next"],
|
|
32
|
+
See a concrete comparison with react-i18next in our [react-i18next vs. react-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/react-i18next_vs_react-intl_vs_intlayer.md) blog post.
|
|
119
33
|
|
|
120
|
-
|
|
121
|
-
// This folder will be created if it doesn't exist yet.
|
|
122
|
-
i18nextResourcesDir: "./i18next/resources",
|
|
123
|
-
},
|
|
124
|
-
};
|
|
34
|
+
## Why Combine Intlayer with react-i18next?
|
|
125
35
|
|
|
126
|
-
|
|
127
|
-
```
|
|
36
|
+
While Intlayer provides an excellent standalone i18n solution (see our [React integration guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite+react.md)), you might want to combine it with react-i18next for several reasons:
|
|
128
37
|
|
|
129
|
-
|
|
38
|
+
1. **Existing codebase**: You have an established react-i18next implementation and want to gradually migrate to Intlayer's improved developer experience.
|
|
39
|
+
2. **Legacy requirements**: Your project requires compatibility with existing react-i18next plugins or workflows.
|
|
40
|
+
3. **Team familiarity**: Your team is comfortable with react-i18next but wants better content management.
|
|
130
41
|
|
|
131
|
-
|
|
42
|
+
**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.**
|
|
132
43
|
|
|
133
|
-
|
|
44
|
+
This guide shows you how to leverage Intlayer's superior content declaration system while maintaining compatibility with react-i18next.
|
|
134
45
|
|
|
135
|
-
|
|
136
|
-
# With npm
|
|
137
|
-
npx run intlayer build
|
|
138
|
-
```
|
|
46
|
+
## Table of Contents
|
|
139
47
|
|
|
140
|
-
|
|
141
|
-
# With yarn
|
|
142
|
-
yarn intlayer build
|
|
143
|
-
```
|
|
48
|
+
<TOC/>
|
|
144
49
|
|
|
145
|
-
|
|
146
|
-
# With pnpm
|
|
147
|
-
pnpm intlayer build
|
|
148
|
-
```
|
|
50
|
+
## Step-by-Step Guide to Set Up Intlayer with react-i18next
|
|
149
51
|
|
|
150
|
-
|
|
52
|
+
### Step 1: Install Dependencies
|
|
151
53
|
|
|
152
|
-
|
|
54
|
+
Install the necessary packages:
|
|
153
55
|
|
|
154
|
-
```bash
|
|
155
|
-
|
|
156
|
-
└── i18next
|
|
157
|
-
└── resources
|
|
158
|
-
├── en
|
|
159
|
-
│ └── my-content.json
|
|
160
|
-
├── fr
|
|
161
|
-
│ └── my-content.json
|
|
162
|
-
└── es
|
|
163
|
-
└── my-content.json
|
|
56
|
+
```bash packageManager="npm"
|
|
57
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
164
58
|
```
|
|
165
59
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
## Importing Dictionaries into Your react-i18next Configuration
|
|
169
|
-
|
|
170
|
-
To dynamically load these resources at runtime, use [`i18next-resources-to-backend`](https://www.npmjs.com/package/i18next-resources-to-backend). For instance, create an `i18n.ts` (or `.js`) file in your project:
|
|
171
|
-
|
|
172
|
-
```typescript title="i18n.ts"
|
|
173
|
-
import i18next from "i18next";
|
|
174
|
-
import { initReactI18next } from "react-i18next";
|
|
175
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
176
|
-
|
|
177
|
-
i18next
|
|
178
|
-
// react-i18next plugin
|
|
179
|
-
.use(initReactI18next)
|
|
180
|
-
// dynamically load resources
|
|
181
|
-
.use(
|
|
182
|
-
resourcesToBackend((language: string, namespace: string) => {
|
|
183
|
-
// Adjust the import path to your resources directory
|
|
184
|
-
return import(`../i18next/resources/${language}/${namespace}.json`);
|
|
185
|
-
})
|
|
186
|
-
)
|
|
187
|
-
// Initialize i18next
|
|
188
|
-
.init({
|
|
189
|
-
// Fallback locale
|
|
190
|
-
fallbackLng: "en",
|
|
191
|
-
|
|
192
|
-
// You can add other i18next config options here, see:
|
|
193
|
-
// https://www.i18next.com/overview/configuration-options
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
export default i18next;
|
|
60
|
+
```bash packageManager="pnpm"
|
|
61
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
197
62
|
```
|
|
198
63
|
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
import { initReactI18next } from "react-i18next";
|
|
202
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
203
|
-
|
|
204
|
-
i18next
|
|
205
|
-
.use(initReactI18next)
|
|
206
|
-
.use(
|
|
207
|
-
resourcesToBackend(
|
|
208
|
-
(language, namespace) =>
|
|
209
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
210
|
-
)
|
|
211
|
-
)
|
|
212
|
-
.init({
|
|
213
|
-
fallbackLng: "en",
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
export default i18next;
|
|
64
|
+
```bash packageManager="yarn"
|
|
65
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
217
66
|
```
|
|
218
67
|
|
|
219
|
-
|
|
68
|
+
**Package descriptions:**
|
|
220
69
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
import ReactDOM from "react-dom/client";
|
|
224
|
-
// Initialize i18n before anything else
|
|
225
|
-
import "./i18n";
|
|
226
|
-
import App from "./App";
|
|
70
|
+
- **intlayer**: Core library for internationalisation management, content declaration, and building
|
|
71
|
+
- **@intlayer/sync-json-plugin**: Plugin to export Intlayer content declarations to react-i18next compatible JSON format
|
|
227
72
|
|
|
228
|
-
|
|
229
|
-
<React.StrictMode>
|
|
230
|
-
<App />
|
|
231
|
-
</React.StrictMode>
|
|
232
|
-
);
|
|
233
|
-
```
|
|
73
|
+
### Step 2: Implement the Intlayer plugin to wrap the JSON
|
|
234
74
|
|
|
235
|
-
|
|
75
|
+
Create an Intlayer configuration file to define your supported locales:
|
|
236
76
|
|
|
237
|
-
|
|
238
|
-
Here’s a minimal example in TypeScript:
|
|
77
|
+
**If you want to also export JSON dictionaries for react-i18next**, add the `syncJSON` plugin:
|
|
239
78
|
|
|
240
|
-
```typescript
|
|
241
|
-
import {
|
|
79
|
+
```typescript fileName="intlayer.config.ts"
|
|
80
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
81
|
+
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
242
82
|
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// Each "t" call is a separate translation node
|
|
248
|
-
heading: t({
|
|
249
|
-
en: "Hello World",
|
|
250
|
-
es: "Hola Mundo",
|
|
251
|
-
fr: "Bonjour le monde",
|
|
252
|
-
}),
|
|
253
|
-
description: t({
|
|
254
|
-
en: "My i18n description text...",
|
|
255
|
-
fr: "Ma description en i18n...",
|
|
256
|
-
es: "Mi descripción en i18n...",
|
|
257
|
-
}),
|
|
83
|
+
const config: IntlayerConfig = {
|
|
84
|
+
internationalization: {
|
|
85
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
86
|
+
defaultLocale: Locales.ENGLISH,
|
|
258
87
|
},
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
If you prefer JSON, `.cjs`, or `.mjs`, refer to the [Intlayer docs](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/doc/concept/content).
|
|
265
|
-
|
|
266
|
-
> By default, valid content declarations match the file extension pattern:
|
|
267
|
-
|
|
268
|
-
> `*.content.{ts,tsx,js,jsx,mjs,mjx,cjs,cjx,json}`
|
|
269
|
-
|
|
270
|
-
## Using the Translations in React Components
|
|
271
|
-
|
|
272
|
-
After you’ve **built** your Intlayer resources and configured react-i18next, you can directly use the `useTranslation` hook from **react-i18next**.
|
|
273
|
-
For instance:
|
|
274
|
-
|
|
275
|
-
```tsx title="src/components/MyComponent/MyComponent.tsx"
|
|
276
|
-
import type { FC } from "react";
|
|
277
|
-
import { useTranslation } from "react-i18next";
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* The i18next "namespace" is the Intlayer `key` from "MyComponent.content.ts"
|
|
281
|
-
* so we'll pass "my-component" to useTranslation().
|
|
282
|
-
*/
|
|
283
|
-
const MyComponent: FC = () => {
|
|
284
|
-
const { t } = useTranslation("my-component");
|
|
285
|
-
|
|
286
|
-
return (
|
|
287
|
-
<div>
|
|
288
|
-
<h1>{t("heading")}</h1>
|
|
289
|
-
<p>{t("description")}</p>
|
|
290
|
-
</div>
|
|
291
|
-
);
|
|
88
|
+
plugins: [
|
|
89
|
+
syncJSON({
|
|
90
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
292
93
|
};
|
|
293
94
|
|
|
294
|
-
export default
|
|
95
|
+
export default config;
|
|
295
96
|
```
|
|
296
97
|
|
|
297
|
-
|
|
98
|
+
The `syncJSON` plugin will automatically wrap the JSON. It will read and write the JSON files without changing the content architecture.
|
|
298
99
|
|
|
299
|
-
|
|
100
|
+
If you want to make that JSON coexist with Intlayer content declaration files (`.content` files), Intlayer will proceed as follows:
|
|
300
101
|
|
|
301
|
-
|
|
102
|
+
1. load both JSON and content declaration files and transform them into an Intlayer dictionary.
|
|
103
|
+
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).
|
|
302
104
|
|
|
303
|
-
|
|
304
|
-
```bash
|
|
305
|
-
npm install react-intlayer --save-dev
|
|
306
|
-
```
|
|
307
|
-
2. **Adjust your `package.json` scripts** to use `react-intlayer` scripts:
|
|
105
|
+
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.
|
|
308
106
|
|
|
309
|
-
|
|
310
|
-
"scripts": {
|
|
311
|
-
"start": "react-intlayer start",
|
|
312
|
-
"build": "react-intlayer build",
|
|
313
|
-
"transpile": "intlayer build"
|
|
314
|
-
}
|
|
315
|
-
```
|
|
107
|
+
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).
|
|
316
108
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
Now, running `npm run build`, `yarn build`, or `pnpm build` triggers both Intlayer and CRA builds.
|
|
320
|
-
|
|
321
|
-
## TypeScript Configuration
|
|
109
|
+
## Git Configuration
|
|
322
110
|
|
|
323
|
-
|
|
111
|
+
It is recommended to ignore auto-generated Intlayer files:
|
|
324
112
|
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
// ...
|
|
329
|
-
},
|
|
330
|
-
"include": ["src", "types"],
|
|
331
|
-
}
|
|
113
|
+
```plaintext fileName=".gitignore"
|
|
114
|
+
# Ignore files generated by Intlayer
|
|
115
|
+
.intlayer
|
|
332
116
|
```
|
|
333
117
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
## Git Configuration
|
|
118
|
+
These files can be regenerated during your build process and do not need to be committed to version control.
|
|
337
119
|
|
|
338
|
-
|
|
120
|
+
### VS Code Extension
|
|
339
121
|
|
|
340
|
-
|
|
341
|
-
# Ignore the files generated by Intlayer
|
|
342
|
-
.intlayer
|
|
343
|
-
i18next
|
|
344
|
-
```
|
|
122
|
+
For an improved developer experience, install the official **Intlayer VS Code Extension**:
|
|
345
123
|
|
|
346
|
-
|
|
124
|
+
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|