@intlayer/docs 7.3.3 → 7.3.5
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/compiler_vs_declarative_i18n.md +137 -54
- package/blog/de/compiler_vs_declarative_i18n.md +131 -48
- package/blog/en/compiler_vs_declarative_i18n.md +112 -27
- package/blog/en-GB/compiler_vs_declarative_i18n.md +110 -27
- package/blog/es/compiler_vs_declarative_i18n.md +128 -45
- package/blog/fr/compiler_vs_declarative_i18n.md +133 -50
- package/blog/hi/compiler_vs_declarative_i18n.md +136 -53
- package/blog/id/compiler_vs_declarative_i18n.md +124 -41
- package/blog/it/compiler_vs_declarative_i18n.md +130 -47
- package/blog/ja/compiler_vs_declarative_i18n.md +140 -57
- package/blog/ko/compiler_vs_declarative_i18n.md +134 -51
- package/blog/pl/compiler_vs_declarative_i18n.md +134 -51
- package/blog/pt/compiler_vs_declarative_i18n.md +128 -45
- package/blog/ru/compiler_vs_declarative_i18n.md +135 -52
- package/blog/tr/compiler_vs_declarative_i18n.md +131 -48
- package/blog/vi/compiler_vs_declarative_i18n.md +136 -53
- package/blog/zh/compiler_vs_declarative_i18n.md +132 -49
- package/docs/en/interest_of_intlayer.md +4 -0
- package/docs/en/per_locale_file.md +98 -77
- package/package.json +6 -6
|
@@ -15,6 +15,9 @@ slugs:
|
|
|
15
15
|
- concept
|
|
16
16
|
- per-locale-file
|
|
17
17
|
history:
|
|
18
|
+
- version: 7.3.1
|
|
19
|
+
date: 2025-11-29
|
|
20
|
+
changes: Add global configuration for per-locale files
|
|
18
21
|
- version: 5.5.10
|
|
19
22
|
date: 2025-06-29
|
|
20
23
|
changes: Init history
|
|
@@ -33,83 +36,6 @@ This flexibility enables:
|
|
|
33
36
|
- Support for automated translation workflows
|
|
34
37
|
- Clear organization of translations into separate, locale-specific files
|
|
35
38
|
|
|
36
|
-
## Single File with Multiple Translations
|
|
37
|
-
|
|
38
|
-
This format is ideal for:
|
|
39
|
-
|
|
40
|
-
- Quick iteration in code.
|
|
41
|
-
- Seamless integration with the CMS.
|
|
42
|
-
|
|
43
|
-
This is the recommended approach for most use cases. It centralizes translations, making it easy to iterate and integrate with the CMS.
|
|
44
|
-
|
|
45
|
-
```tsx fileName="hello-world.content.ts" contentDeclarationFormat="typescript"
|
|
46
|
-
import { t, type Dictionary } from "intlayer";
|
|
47
|
-
|
|
48
|
-
const helloWorldContent = {
|
|
49
|
-
key: "hello-world",
|
|
50
|
-
content: {
|
|
51
|
-
multilingualContent: t({
|
|
52
|
-
en: "Title of my component",
|
|
53
|
-
es: "Título de mi componente",
|
|
54
|
-
}),
|
|
55
|
-
},
|
|
56
|
-
} satisfies Dictionary;
|
|
57
|
-
|
|
58
|
-
export default helloWorldContent;
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
```js fileName="hello-world.content.mjs" contentDeclarationFormat="esm"
|
|
62
|
-
import { t } from "intlayer";
|
|
63
|
-
|
|
64
|
-
/** @type {import('intlayer').Dictionary} */
|
|
65
|
-
const helloWorldContent = {
|
|
66
|
-
key: "hello-world",
|
|
67
|
-
content: {
|
|
68
|
-
multilingualContent: t({
|
|
69
|
-
en: "Title of my component",
|
|
70
|
-
es: "Título de mi componente",
|
|
71
|
-
}),
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default helloWorldContent;
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
```js fileName="hello-world.content.cjs" contentDeclarationFormat="json"
|
|
79
|
-
const { t } = require("intlayer");
|
|
80
|
-
|
|
81
|
-
/** @type {import('intlayer').Dictionary} */
|
|
82
|
-
const helloWorldContent = {
|
|
83
|
-
key: "hello-world",
|
|
84
|
-
content: {
|
|
85
|
-
multilingualContent: t({
|
|
86
|
-
en: "Title of my component",
|
|
87
|
-
es: "Título de mi componente",
|
|
88
|
-
}),
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
module.exports = helloWorldContent;
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
```json fileName="hello-world.content.ts" contentDeclarationFormat="json"
|
|
96
|
-
{
|
|
97
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
98
|
-
"key": "hello-world",
|
|
99
|
-
"content": {
|
|
100
|
-
"multilingualContent": {
|
|
101
|
-
"nodeType": "translation",
|
|
102
|
-
"translation": {
|
|
103
|
-
"en": "Title of my component",
|
|
104
|
-
"es": "Título de mi componente"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
> Recommended: This format is best when using Intlayer's visual editor or managing translations directly in the code.
|
|
112
|
-
|
|
113
39
|
## Per-Locale Format
|
|
114
40
|
|
|
115
41
|
This format is useful when:
|
|
@@ -225,6 +151,101 @@ module.exports = helloWorldContent;
|
|
|
225
151
|
|
|
226
152
|
> Note: In both cases, the content declaration file must follow the naming pattern `*.content.{ts,tsx,js,jsx,mjs,cjs,json}` to be recognized by Intlayer. The `.[locale]` suffix is optional and used only as a naming convention.
|
|
227
153
|
|
|
154
|
+
### Global Configuration for Per-Locale Files
|
|
155
|
+
|
|
156
|
+
You can configure the global configuration for per-locale files by adding the following to your `intlayer.config.ts` file:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
160
|
+
|
|
161
|
+
const config: IntlayerConfig = {
|
|
162
|
+
dictionary: {
|
|
163
|
+
locale: Locales.ENGLISH,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export default config;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Using this configuration, all per-locale files will be generated with the default locale set to English. It also include generation of `.content` files using the `transform` command, and the compiler. (See [Compiler](https://intlayer.org/doc/compiler) or [Transform](https://intlayer.org/doc/concept/cli/transform) for more information.)
|
|
171
|
+
|
|
172
|
+
## Single File with Multiple Translations
|
|
173
|
+
|
|
174
|
+
This format is ideal for:
|
|
175
|
+
|
|
176
|
+
- Quick iteration in code.
|
|
177
|
+
- Seamless integration with the CMS.
|
|
178
|
+
|
|
179
|
+
This is the recommended approach for most use cases. It centralizes translations, making it easy to iterate and integrate with the CMS.
|
|
180
|
+
|
|
181
|
+
```tsx fileName="hello-world.content.ts" contentDeclarationFormat="typescript"
|
|
182
|
+
import { t, type Dictionary } from "intlayer";
|
|
183
|
+
|
|
184
|
+
const helloWorldContent = {
|
|
185
|
+
key: "hello-world",
|
|
186
|
+
content: {
|
|
187
|
+
multilingualContent: t({
|
|
188
|
+
en: "Title of my component",
|
|
189
|
+
es: "Título de mi componente",
|
|
190
|
+
}),
|
|
191
|
+
},
|
|
192
|
+
} satisfies Dictionary;
|
|
193
|
+
|
|
194
|
+
export default helloWorldContent;
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```js fileName="hello-world.content.mjs" contentDeclarationFormat="esm"
|
|
198
|
+
import { t } from "intlayer";
|
|
199
|
+
|
|
200
|
+
/** @type {import('intlayer').Dictionary} */
|
|
201
|
+
const helloWorldContent = {
|
|
202
|
+
key: "hello-world",
|
|
203
|
+
content: {
|
|
204
|
+
multilingualContent: t({
|
|
205
|
+
en: "Title of my component",
|
|
206
|
+
es: "Título de mi componente",
|
|
207
|
+
}),
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export default helloWorldContent;
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```js fileName="hello-world.content.cjs" contentDeclarationFormat="json"
|
|
215
|
+
const { t } = require("intlayer");
|
|
216
|
+
|
|
217
|
+
/** @type {import('intlayer').Dictionary} */
|
|
218
|
+
const helloWorldContent = {
|
|
219
|
+
key: "hello-world",
|
|
220
|
+
content: {
|
|
221
|
+
multilingualContent: t({
|
|
222
|
+
en: "Title of my component",
|
|
223
|
+
es: "Título de mi componente",
|
|
224
|
+
}),
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
module.exports = helloWorldContent;
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
```json fileName="hello-world.content.ts" contentDeclarationFormat="json"
|
|
232
|
+
{
|
|
233
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
234
|
+
"key": "hello-world",
|
|
235
|
+
"content": {
|
|
236
|
+
"multilingualContent": {
|
|
237
|
+
"nodeType": "translation",
|
|
238
|
+
"translation": {
|
|
239
|
+
"en": "Title of my component",
|
|
240
|
+
"es": "Título de mi componente"
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
> Recommended: This format is best when using Intlayer's visual editor or managing translations directly in the code.
|
|
248
|
+
|
|
228
249
|
## Mixing Formats
|
|
229
250
|
|
|
230
251
|
You can combine both declaration approaches for the same content key. For example:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/docs",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Intlayer documentation",
|
|
6
6
|
"keywords": [
|
|
@@ -73,13 +73,13 @@
|
|
|
73
73
|
"watch": "webpack --config ./webpack.config.ts --watch"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@intlayer/config": "7.3.
|
|
77
|
-
"@intlayer/core": "7.3.
|
|
78
|
-
"@intlayer/types": "7.3.
|
|
76
|
+
"@intlayer/config": "7.3.5",
|
|
77
|
+
"@intlayer/core": "7.3.5",
|
|
78
|
+
"@intlayer/types": "7.3.5"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@intlayer/api": "7.3.
|
|
82
|
-
"@intlayer/cli": "7.3.
|
|
81
|
+
"@intlayer/api": "7.3.5",
|
|
82
|
+
"@intlayer/cli": "7.3.5",
|
|
83
83
|
"@types/node": "24.10.1",
|
|
84
84
|
"@utils/ts-config": "1.0.4",
|
|
85
85
|
"@utils/ts-config-types": "1.0.4",
|