@intlayer/docs 8.4.4 → 8.4.6
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/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/blog.cjs +21 -1
- package/dist/cjs/blog.cjs.map +1 -1
- package/dist/cjs/common.cjs +81 -1
- package/dist/cjs/common.cjs.map +1 -0
- package/dist/cjs/doc.cjs +21 -1
- package/dist/cjs/doc.cjs.map +1 -1
- package/dist/cjs/frequentQuestions.cjs +21 -1
- package/dist/cjs/frequentQuestions.cjs.map +1 -1
- package/dist/cjs/generated/blog.entry.cjs +572 -1
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +3032 -1
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +352 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +72 -1
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/cjs/index.cjs +34 -1
- package/dist/cjs/legal.cjs +21 -1
- package/dist/cjs/legal.cjs.map +1 -1
- package/dist/esm/blog.mjs +14 -1
- package/dist/esm/blog.mjs.map +1 -1
- package/dist/esm/common.mjs +67 -1
- package/dist/esm/common.mjs.map +1 -1
- package/dist/esm/doc.mjs +14 -1
- package/dist/esm/doc.mjs.map +1 -1
- package/dist/esm/frequentQuestions.mjs +14 -1
- package/dist/esm/frequentQuestions.mjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +570 -1
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +3030 -1
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/esm/generated/frequentQuestions.entry.mjs +350 -1
- package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
- package/dist/esm/generated/legal.entry.mjs +70 -1
- package/dist/esm/generated/legal.entry.mjs.map +1 -1
- package/dist/esm/index.mjs +6 -1
- package/dist/esm/legal.mjs +14 -1
- package/dist/esm/legal.mjs.map +1 -1
- package/dist/types/blog.d.ts +2 -2
- package/dist/types/common.d.ts +37 -2
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/doc.d.ts +2 -2
- package/dist/types/frequentQuestions.d.ts +2 -2
- package/dist/types/generated/blog.entry.d.ts +35 -2
- package/dist/types/generated/blog.entry.d.ts.map +1 -0
- package/dist/types/generated/docs.entry.d.ts +158 -2
- package/dist/types/generated/docs.entry.d.ts.map +1 -0
- package/dist/types/generated/frequentQuestions.entry.d.ts +24 -2
- package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -0
- package/dist/types/generated/legal.entry.d.ts +10 -2
- package/dist/types/generated/legal.entry.d.ts.map +1 -0
- package/dist/types/legal.d.ts +2 -2
- package/docs/ar/configuration.md +520 -722
- package/docs/ar/intlayer_with_storybook.md +521 -0
- package/docs/bn/configuration.md +922 -0
- package/docs/bn/intlayer_with_hono.md +428 -0
- package/docs/de/configuration.md +369 -743
- package/docs/de/intlayer_with_storybook.md +521 -0
- package/docs/en/configuration.md +181 -507
- package/docs/en/intlayer_with_storybook.md +521 -0
- package/docs/en-GB/configuration.md +456 -657
- package/docs/en-GB/intlayer_with_storybook.md +521 -0
- package/docs/es/configuration.md +379 -754
- package/docs/es/intlayer_with_storybook.md +521 -0
- package/docs/fr/configuration.md +376 -757
- package/docs/fr/intlayer_with_storybook.md +521 -0
- package/docs/hi/configuration.md +532 -728
- package/docs/hi/intlayer_with_storybook.md +521 -0
- package/docs/id/configuration.md +371 -684
- package/docs/id/intlayer_with_storybook.md +521 -0
- package/docs/it/configuration.md +397 -775
- package/docs/it/intlayer_with_storybook.md +521 -0
- package/docs/ja/configuration.md +525 -724
- package/docs/ja/intlayer_with_storybook.md +521 -0
- package/docs/ko/configuration.md +525 -724
- package/docs/ko/intlayer_with_storybook.md +521 -0
- package/docs/pl/configuration.md +430 -734
- package/docs/pl/intlayer_with_storybook.md +521 -0
- package/docs/pt/configuration.md +375 -746
- package/docs/pt/intlayer_with_storybook.md +521 -0
- package/docs/ru/configuration.md +532 -701
- package/docs/ru/intlayer_with_storybook.md +521 -0
- package/docs/tr/configuration.md +527 -719
- package/docs/tr/intlayer_with_storybook.md +521 -0
- package/docs/uk/configuration.md +425 -744
- package/docs/uk/intlayer_with_storybook.md +521 -0
- package/docs/ur/configuration.md +922 -0
- package/docs/ur/intlayer_with_hono.md +428 -0
- package/docs/vi/configuration.md +412 -753
- package/docs/vi/intlayer_with_storybook.md +521 -0
- package/docs/zh/configuration.md +521 -714
- package/docs/zh/intlayer_with_storybook.md +521 -0
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +20 -0
- package/dist/cjs/common-a-l0ULP6.cjs +0 -2
- package/dist/cjs/common-a-l0ULP6.cjs.map +0 -1
- package/dist/types/blog.entry-D5IgxPXY.d.ts +0 -35
- package/dist/types/blog.entry-D5IgxPXY.d.ts.map +0 -1
- package/dist/types/common-B45TZvLQ.d.ts +0 -37
- package/dist/types/common-B45TZvLQ.d.ts.map +0 -1
- package/dist/types/docs.entry-CergjAYt.d.ts +0 -157
- package/dist/types/docs.entry-CergjAYt.d.ts.map +0 -1
- package/dist/types/frequentQuestions.entry-BHglVS-U.d.ts +0 -24
- package/dist/types/frequentQuestions.entry-BHglVS-U.d.ts.map +0 -1
- package/dist/types/legal.entry-B5Lg5eeH.d.ts +0 -10
- package/dist/types/legal.entry-B5Lg5eeH.d.ts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2024-08-13
|
|
3
|
-
updatedAt: 2026-03-
|
|
3
|
+
updatedAt: 2026-03-20
|
|
4
4
|
title: Configuration
|
|
5
|
-
description: Learn how to configure Intlayer for your application. Understand the various settings and options available to customise Intlayer to your needs.
|
|
5
|
+
description: Learn how to configure Intlayer for your application. Understand the various settings and options available to customise Intlayer according to your needs.
|
|
6
6
|
keywords:
|
|
7
7
|
- Configuration
|
|
8
8
|
- Settings
|
|
@@ -14,58 +14,88 @@ slugs:
|
|
|
14
14
|
- concept
|
|
15
15
|
- configuration
|
|
16
16
|
history:
|
|
17
|
+
- version: 8.4.0
|
|
18
|
+
date: 2026-03-20
|
|
19
|
+
changes: Added per-locale object notation for 'compiler.output' and 'dictionary.fill'
|
|
17
20
|
- version: 8.3.0
|
|
18
21
|
date: 2026-03-11
|
|
19
|
-
changes:
|
|
22
|
+
changes: Moved 'baseDir' from 'content' configuration to 'system' configuration
|
|
20
23
|
- version: 8.2.0
|
|
21
24
|
date: 2026-03-09
|
|
22
|
-
changes:
|
|
25
|
+
changes: Updated compiler options, added support for 'output' and 'noMetadata'
|
|
23
26
|
- version: 8.1.7
|
|
24
27
|
date: 2026-02-25
|
|
25
|
-
changes:
|
|
28
|
+
changes: Updated compiler options
|
|
29
|
+
- version: 8.1.5
|
|
30
|
+
date: 2026-02-23
|
|
31
|
+
changes: Added compiler option 'build-only' and dictionary prefix
|
|
26
32
|
- version: 8.0.6
|
|
27
33
|
date: 2026-02-12
|
|
28
|
-
changes:
|
|
34
|
+
changes: Added support for Open Router, Alibaba, Amazon, Google Vertex Bedrock, Fireworks, Groq, Hugging Face and Together.ai providers
|
|
29
35
|
- version: 8.0.5
|
|
30
36
|
date: 2026-02-06
|
|
31
|
-
changes:
|
|
37
|
+
changes: Added `dataSerialization` to AI configuration
|
|
38
|
+
- version: 8.0.0
|
|
39
|
+
date: 2026-01-24
|
|
40
|
+
changes: Renamed import mode `live` to `fetch` to better describe the underlying mechanism.
|
|
41
|
+
- version: 8.0.0
|
|
42
|
+
date: 2026-01-22
|
|
43
|
+
changes: Moved build configuration `importMode` to `dictionary` configuration.
|
|
32
44
|
- version: 8.0.0
|
|
33
45
|
date: 2026-01-22
|
|
34
|
-
changes:
|
|
46
|
+
changes: Added `rewrite` option to routing configuration
|
|
35
47
|
- version: 8.0.0
|
|
36
48
|
date: 2026-01-18
|
|
37
|
-
changes:
|
|
49
|
+
changes: Separated system configuration from content configuration. Moved internal paths to `system` property. Added `codeDir` to separate content files and code transformation.
|
|
38
50
|
- version: 8.0.0
|
|
39
51
|
date: 2026-01-18
|
|
40
|
-
changes:
|
|
52
|
+
changes: Added dictionary options `location` and `schema`
|
|
41
53
|
- version: 7.5.1
|
|
42
54
|
date: 2026-01-10
|
|
43
|
-
changes:
|
|
55
|
+
changes: Added support for JSON5 and JSONC file formats
|
|
44
56
|
- version: 7.5.0
|
|
45
57
|
date: 2025-12-17
|
|
46
|
-
changes:
|
|
58
|
+
changes: Added `buildMode` option
|
|
59
|
+
- version: 7.0.0
|
|
60
|
+
date: 2025-10-25
|
|
61
|
+
changes: Added `dictionary` configuration
|
|
62
|
+
- version: 7.0.0
|
|
63
|
+
date: 2025-10-21
|
|
64
|
+
changes: Replaced `middleware` by `routing` configuration
|
|
65
|
+
- version: 7.0.0
|
|
66
|
+
date: 2025-10-12
|
|
67
|
+
changes: Added `formatCommand` option
|
|
68
|
+
- version: 6.2.0
|
|
69
|
+
date: 2025-10-12
|
|
70
|
+
changes: Updated `excludedPath` option
|
|
71
|
+
- version: 6.0.2
|
|
72
|
+
date: 2025-09-23
|
|
73
|
+
changes: Added `outputFormat` option
|
|
74
|
+
- version: 6.0.0
|
|
75
|
+
date: 2025-09-21
|
|
76
|
+
changes: Deleted `dictionaryOutput` field and `i18nextResourcesDir` field
|
|
47
77
|
- version: 6.0.0
|
|
48
78
|
date: 2025-09-16
|
|
49
|
-
changes:
|
|
79
|
+
changes: Added `live` import mode
|
|
50
80
|
- version: 6.0.0
|
|
51
81
|
date: 2025-09-04
|
|
52
|
-
changes:
|
|
82
|
+
changes: Replaced `hotReload` field with `liveSync` and added `liveSyncPort` and `liveSyncURL` fields
|
|
53
83
|
- version: 5.6.1
|
|
54
84
|
date: 2025-07-25
|
|
55
|
-
changes:
|
|
85
|
+
changes: Replaced `activateDynamicImport` with `importMode` option
|
|
56
86
|
- version: 5.6.0
|
|
57
87
|
date: 2025-07-13
|
|
58
|
-
changes:
|
|
88
|
+
changes: Changed default contentDir from `['src']` to `['.']`
|
|
59
89
|
- version: 5.5.11
|
|
60
90
|
date: 2025-06-29
|
|
61
|
-
changes:
|
|
91
|
+
changes: Added `docs` commands
|
|
62
92
|
---
|
|
63
93
|
|
|
64
94
|
# Intlayer Configuration Documentation
|
|
65
95
|
|
|
66
96
|
## Overview
|
|
67
97
|
|
|
68
|
-
Intlayer configuration files allow
|
|
98
|
+
Intlayer configuration files allow you to customise various aspects of the plugin, such as internationalisation (internationalisation), middleware, and content handling. This documentation provides an in-depth description of each property in the configuration.
|
|
69
99
|
|
|
70
100
|
---
|
|
71
101
|
|
|
@@ -75,9 +105,9 @@ Intlayer configuration files allow customisation of various aspects of the plugi
|
|
|
75
105
|
|
|
76
106
|
---
|
|
77
107
|
|
|
78
|
-
## Configuration File
|
|
108
|
+
## Supported Configuration File Formats
|
|
79
109
|
|
|
80
|
-
Intlayer accepts JSON, JS, MJS, and TS
|
|
110
|
+
Intlayer accepts configuration file formats including JSON, JS, MJS, and TS:
|
|
81
111
|
|
|
82
112
|
- `intlayer.config.ts`
|
|
83
113
|
- `intlayer.config.js`
|
|
@@ -90,7 +120,7 @@ Intlayer accepts JSON, JS, MJS, and TS configuration file formats:
|
|
|
90
120
|
|
|
91
121
|
---
|
|
92
122
|
|
|
93
|
-
##
|
|
123
|
+
## Configuration File Example
|
|
94
124
|
|
|
95
125
|
````typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
96
126
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -98,30 +128,30 @@ import { nextjsRewrite } from "intlayer/routing";
|
|
|
98
128
|
import { z } from "zod";
|
|
99
129
|
|
|
100
130
|
/**
|
|
101
|
-
* Example Intlayer configuration file
|
|
131
|
+
* Example Intlayer configuration file displaying all available options.
|
|
102
132
|
*/
|
|
103
133
|
const config: IntlayerConfig = {
|
|
104
134
|
/**
|
|
105
|
-
* Configuration for
|
|
135
|
+
* Configuration for internationalisation settings.
|
|
106
136
|
*/
|
|
107
137
|
internationalization: {
|
|
108
138
|
/**
|
|
109
|
-
* List of supported
|
|
139
|
+
* List of locales supported in the application.
|
|
110
140
|
* Default: [Locales.ENGLISH]
|
|
111
141
|
*/
|
|
112
142
|
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
113
143
|
|
|
114
144
|
/**
|
|
115
|
-
* List of
|
|
116
|
-
* If empty, all locales are
|
|
145
|
+
* List of mandatory locales that must be defined in each dictionary.
|
|
146
|
+
* If empty, all locales are mandatory in `strict` mode.
|
|
117
147
|
* Default: []
|
|
118
148
|
*/
|
|
119
149
|
requiredLocales: [Locales.ENGLISH],
|
|
120
150
|
|
|
121
151
|
/**
|
|
122
|
-
*
|
|
123
|
-
* - "strict":
|
|
124
|
-
* - "inclusive":
|
|
152
|
+
* Level of strictness for internationalised content.
|
|
153
|
+
* - "strict": Error if any declared locale is missing or undeclared.
|
|
154
|
+
* - "inclusive": Warning if a declared locale is missing.
|
|
125
155
|
* - "loose": Accepts any existing locale.
|
|
126
156
|
* Default: "inclusive"
|
|
127
157
|
*/
|
|
@@ -135,37 +165,37 @@ const config: IntlayerConfig = {
|
|
|
135
165
|
},
|
|
136
166
|
|
|
137
167
|
/**
|
|
138
|
-
* Settings
|
|
168
|
+
* Settings controlling dictionary operations and fallback behaviour.
|
|
139
169
|
*/
|
|
140
170
|
dictionary: {
|
|
141
171
|
/**
|
|
142
172
|
* Controls how dictionaries are imported.
|
|
143
173
|
* - "static": Statically imported at build time.
|
|
144
174
|
* - "dynamic": Dynamically imported using Suspense.
|
|
145
|
-
* - "fetch":
|
|
175
|
+
* - "fetch": Dynamically fetched via the live sync API.
|
|
146
176
|
* Default: "static"
|
|
147
177
|
*/
|
|
148
178
|
importMode: "static",
|
|
149
179
|
|
|
150
180
|
/**
|
|
151
|
-
* Strategy
|
|
152
|
-
* Can be a boolean or a path pattern to
|
|
181
|
+
* Strategy to fill missing translations automatically using AI.
|
|
182
|
+
* Can be a boolean value or a path pattern to save the filled content.
|
|
153
183
|
* Default: true
|
|
154
184
|
*/
|
|
155
185
|
fill: true,
|
|
156
186
|
|
|
157
187
|
/**
|
|
158
|
-
* Physical location of
|
|
188
|
+
* Physical location of dictionary files.
|
|
159
189
|
* - "local": Stored in the local filesystem.
|
|
160
190
|
* - "remote": Stored in the Intlayer CMS.
|
|
161
|
-
* - "hybrid": Stored
|
|
162
|
-
* - "plugin" (or any custom string): Provided by a plugin or
|
|
191
|
+
* - "hybrid": Stored both locally and in the Intlayer CMS.
|
|
192
|
+
* - "plugin" (or any custom string): Provided by a plugin or custom source.
|
|
163
193
|
* Default: "local"
|
|
164
194
|
*/
|
|
165
195
|
location: "local",
|
|
166
196
|
|
|
167
197
|
/**
|
|
168
|
-
* Whether
|
|
198
|
+
* Whether the content should be automatically transformed (e.g. Markdown to HTML).
|
|
169
199
|
* Default: false
|
|
170
200
|
*/
|
|
171
201
|
contentAutoTransformation: false,
|
|
@@ -177,29 +207,29 @@ const config: IntlayerConfig = {
|
|
|
177
207
|
routing: {
|
|
178
208
|
/**
|
|
179
209
|
* Locale routing strategy.
|
|
180
|
-
* - "prefix-no-default":
|
|
181
|
-
* - "prefix-all":
|
|
182
|
-
* - "no-prefix": No locale in
|
|
183
|
-
* - "search-params":
|
|
210
|
+
* - "prefix-no-default": Prefixes all but the default locale (e.g. /dashboard, /fr/dashboard).
|
|
211
|
+
* - "prefix-all": Prefixes all locales (e.g. /en/dashboard, /fr/dashboard).
|
|
212
|
+
* - "no-prefix": No locale in URL.
|
|
213
|
+
* - "search-params": Uses ?locale=...
|
|
184
214
|
* Default: "prefix-no-default"
|
|
185
215
|
*/
|
|
186
216
|
mode: "prefix-no-default",
|
|
187
217
|
|
|
188
218
|
/**
|
|
189
|
-
* Where to store the user
|
|
219
|
+
* Where to store the user-selected locale.
|
|
190
220
|
* Options: 'cookie', 'localStorage', 'sessionStorage', 'header', or an array of these.
|
|
191
221
|
* Default: ['cookie', 'header']
|
|
192
222
|
*/
|
|
193
223
|
storage: ["cookie", "header"],
|
|
194
224
|
|
|
195
225
|
/**
|
|
196
|
-
* Base path for
|
|
226
|
+
* Base path for application URLs.
|
|
197
227
|
* Default: ""
|
|
198
228
|
*/
|
|
199
229
|
basePath: "",
|
|
200
230
|
|
|
201
231
|
/**
|
|
202
|
-
* Custom URL
|
|
232
|
+
* Custom URL rewrite rules for specific paths on a per-locale basis.
|
|
203
233
|
*/
|
|
204
234
|
rewrite: nextjsRewrite({
|
|
205
235
|
"/[locale]/about": {
|
|
@@ -210,11 +240,11 @@ const config: IntlayerConfig = {
|
|
|
210
240
|
},
|
|
211
241
|
|
|
212
242
|
/**
|
|
213
|
-
* Settings
|
|
243
|
+
* Settings pertaining to finding and processing content files.
|
|
214
244
|
*/
|
|
215
245
|
content: {
|
|
216
246
|
/**
|
|
217
|
-
* File extensions
|
|
247
|
+
* File extensions for scanning dictionaries.
|
|
218
248
|
* Default: ['.content.ts', '.content.js', '.content.json', etc.]
|
|
219
249
|
*/
|
|
220
250
|
fileExtensions: [".content.ts", ".content.js", ".content.json"],
|
|
@@ -226,26 +256,26 @@ const config: IntlayerConfig = {
|
|
|
226
256
|
contentDir: ["src"],
|
|
227
257
|
|
|
228
258
|
/**
|
|
229
|
-
*
|
|
230
|
-
* Used for build
|
|
259
|
+
* Where the source code is located.
|
|
260
|
+
* Used for build optimisation and code transformation.
|
|
231
261
|
* Default: ["."]
|
|
232
262
|
*/
|
|
233
263
|
codeDir: ["src"],
|
|
234
264
|
|
|
235
265
|
/**
|
|
236
|
-
* Patterns
|
|
266
|
+
* Patterns excluded from scanning.
|
|
237
267
|
* Default: ['node_modules', '.intlayer', etc.]
|
|
238
268
|
*/
|
|
239
269
|
excludedPath: ["node_modules"],
|
|
240
270
|
|
|
241
271
|
/**
|
|
242
|
-
* Whether to
|
|
272
|
+
* Whether to monitor changes and rebuild dictionaries during development.
|
|
243
273
|
* Default: true in development
|
|
244
274
|
*/
|
|
245
275
|
watch: true,
|
|
246
276
|
|
|
247
277
|
/**
|
|
248
|
-
* Command to format newly created / updated .content files.
|
|
278
|
+
* Command used to format newly created / updated .content files.
|
|
249
279
|
*/
|
|
250
280
|
formatCommand: 'npx prettier --write "{{file}}"',
|
|
251
281
|
},
|
|
@@ -261,7 +291,7 @@ const config: IntlayerConfig = {
|
|
|
261
291
|
enabled: true,
|
|
262
292
|
|
|
263
293
|
/**
|
|
264
|
-
* URL of your application for origin validation.
|
|
294
|
+
* The URL of your application for origin validation.
|
|
265
295
|
* Default: ""
|
|
266
296
|
*/
|
|
267
297
|
applicationURL: "http://localhost:3000",
|
|
@@ -291,14 +321,14 @@ const config: IntlayerConfig = {
|
|
|
291
321
|
backendURL: "https://back.intlayer.org",
|
|
292
322
|
|
|
293
323
|
/**
|
|
294
|
-
* Whether to enable real-time content
|
|
324
|
+
* Whether to enable real-time content sync.
|
|
295
325
|
* Default: false
|
|
296
326
|
*/
|
|
297
327
|
liveSync: true,
|
|
298
328
|
},
|
|
299
329
|
|
|
300
330
|
/**
|
|
301
|
-
* AI-
|
|
331
|
+
* AI-based translation and construction settings.
|
|
302
332
|
*/
|
|
303
333
|
ai: {
|
|
304
334
|
/**
|
|
@@ -309,7 +339,7 @@ const config: IntlayerConfig = {
|
|
|
309
339
|
provider: "openai",
|
|
310
340
|
|
|
311
341
|
/**
|
|
312
|
-
* Model
|
|
342
|
+
* Model of the selected provider to use.
|
|
313
343
|
*/
|
|
314
344
|
model: "gpt-4o",
|
|
315
345
|
|
|
@@ -319,21 +349,21 @@ const config: IntlayerConfig = {
|
|
|
319
349
|
apiKey: process.env.OPENAI_API_KEY,
|
|
320
350
|
|
|
321
351
|
/**
|
|
322
|
-
* Global context to guide
|
|
352
|
+
* Global context to guide AI in generating translations.
|
|
323
353
|
*/
|
|
324
354
|
applicationContext: "This is a travel booking application.",
|
|
325
355
|
|
|
326
356
|
/**
|
|
327
|
-
* Base URL for
|
|
357
|
+
* Base URL for AI API.
|
|
328
358
|
*/
|
|
329
359
|
baseURL: "http://localhost:3000",
|
|
330
360
|
|
|
331
361
|
/**
|
|
332
|
-
* Data
|
|
362
|
+
* Data Serialization
|
|
333
363
|
*
|
|
334
364
|
* Options:
|
|
335
|
-
* - "json":
|
|
336
|
-
* - "toon":
|
|
365
|
+
* - "json": Default, robust; consumes more tokens.
|
|
366
|
+
* - "toon": Consumes fewer tokens, may not be as consistent as JSON.
|
|
337
367
|
*
|
|
338
368
|
* Default: "json"
|
|
339
369
|
*/
|
|
@@ -341,31 +371,31 @@ const config: IntlayerConfig = {
|
|
|
341
371
|
},
|
|
342
372
|
|
|
343
373
|
/**
|
|
344
|
-
* Build and
|
|
374
|
+
* Build and optimisation settings.
|
|
345
375
|
*/
|
|
346
376
|
build: {
|
|
347
377
|
/**
|
|
348
378
|
* Build execution mode.
|
|
349
|
-
* - "auto":
|
|
350
|
-
* - "manual": Requires explicit build command.
|
|
379
|
+
* - "auto": Builds automatically during application build.
|
|
380
|
+
* - "manual": Requires an explicit build command.
|
|
351
381
|
* Default: "auto"
|
|
352
382
|
*/
|
|
353
383
|
mode: "auto",
|
|
354
384
|
|
|
355
385
|
/**
|
|
356
|
-
* Whether to
|
|
386
|
+
* Whether to optimise final bundle by removing unused dictionaries.
|
|
357
387
|
* Default: true in production
|
|
358
388
|
*/
|
|
359
389
|
optimize: true,
|
|
360
390
|
|
|
361
391
|
/**
|
|
362
392
|
* Output format for generated dictionary files.
|
|
363
|
-
* Default: ['
|
|
393
|
+
* Default: ['cjs', 'esm']
|
|
364
394
|
*/
|
|
365
|
-
outputFormat: ["esm"],
|
|
395
|
+
outputFormat: ["cjs", "esm"],
|
|
366
396
|
|
|
367
397
|
/**
|
|
368
|
-
* Indicates
|
|
398
|
+
* Indicates whether the build should check TypeScript types.
|
|
369
399
|
* Default: false
|
|
370
400
|
*/
|
|
371
401
|
checkTypes: false,
|
|
@@ -378,8 +408,8 @@ const config: IntlayerConfig = {
|
|
|
378
408
|
/**
|
|
379
409
|
* Logging level.
|
|
380
410
|
* - "default": Standard logging.
|
|
381
|
-
* - "verbose":
|
|
382
|
-
* - "disabled":
|
|
411
|
+
* - "verbose": In-depth debug logging.
|
|
412
|
+
* - "disabled": Disables logging.
|
|
383
413
|
* Default: "default"
|
|
384
414
|
*/
|
|
385
415
|
mode: "default",
|
|
@@ -392,16 +422,16 @@ const config: IntlayerConfig = {
|
|
|
392
422
|
},
|
|
393
423
|
|
|
394
424
|
/**
|
|
395
|
-
* System
|
|
425
|
+
* System Configuration (For advanced use)
|
|
396
426
|
*/
|
|
397
427
|
system: {
|
|
398
428
|
/**
|
|
399
|
-
* Directory for storing
|
|
429
|
+
* Directory for storing localised dictionaries.
|
|
400
430
|
*/
|
|
401
431
|
dictionariesDir: ".intlayer/dictionary",
|
|
402
432
|
|
|
403
433
|
/**
|
|
404
|
-
* Directory for module augmentation.
|
|
434
|
+
* Directory for TypeScript module augmentation.
|
|
405
435
|
*/
|
|
406
436
|
moduleAugmentationDir: ".intlayer/types",
|
|
407
437
|
|
|
@@ -416,7 +446,7 @@ const config: IntlayerConfig = {
|
|
|
416
446
|
typesDir: ".intlayer/types",
|
|
417
447
|
|
|
418
448
|
/**
|
|
419
|
-
* Directory where main application files are stored.
|
|
449
|
+
* Directory where the main application files are stored.
|
|
420
450
|
*/
|
|
421
451
|
mainDir: ".intlayer/main",
|
|
422
452
|
|
|
@@ -432,79 +462,79 @@ const config: IntlayerConfig = {
|
|
|
432
462
|
},
|
|
433
463
|
|
|
434
464
|
/**
|
|
435
|
-
* Compiler
|
|
465
|
+
* Compiler Configuration (For advanced use)
|
|
436
466
|
*/
|
|
437
467
|
compiler: {
|
|
438
468
|
/**
|
|
439
|
-
* Indicates
|
|
469
|
+
* Indicates whether the compiler should be enabled.
|
|
440
470
|
*
|
|
441
|
-
* - false
|
|
442
|
-
* - true
|
|
443
|
-
* - "build-only"
|
|
471
|
+
* - false: Disables the compiler.
|
|
472
|
+
* - true: Enables the compiler.
|
|
473
|
+
* - "build-only": Skips the compiler during development and speeds up startup time.
|
|
444
474
|
*
|
|
445
475
|
* Default: false
|
|
446
476
|
*/
|
|
447
477
|
enabled: true,
|
|
448
478
|
|
|
449
479
|
/**
|
|
450
|
-
* Defines
|
|
480
|
+
* Defines path for output files. Replaces `outputDir`.
|
|
451
481
|
*
|
|
452
|
-
* -
|
|
453
|
-
* -
|
|
482
|
+
* - `./` paths are resolved relative to the component directory.
|
|
483
|
+
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
454
484
|
*
|
|
455
|
-
* - Including
|
|
485
|
+
* - Including `{{locale}}` variable in path will trigger the creation of separate dictionaries per-language.
|
|
456
486
|
*
|
|
457
|
-
*
|
|
487
|
+
* Example:
|
|
458
488
|
* ```ts
|
|
459
489
|
* {
|
|
460
|
-
* // Create
|
|
490
|
+
* // Create multilingual .content.ts files next to component
|
|
461
491
|
* output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
462
492
|
*
|
|
463
|
-
* // output: './{{fileName}}{{extension}}', // Equivalent using
|
|
493
|
+
* // output: './{{fileName}}{{extension}}', // Equivalent using template string
|
|
464
494
|
* }
|
|
465
495
|
* ```
|
|
466
496
|
*
|
|
467
497
|
* ```ts
|
|
468
498
|
* {
|
|
469
|
-
* // Create centralised JSON
|
|
499
|
+
* // Create centralised JSON per language on project root
|
|
470
500
|
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
471
501
|
*
|
|
472
|
-
* // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using
|
|
502
|
+
* // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
|
|
473
503
|
* }
|
|
474
504
|
* ```
|
|
475
505
|
*
|
|
476
|
-
*
|
|
477
|
-
* - `fileName`:
|
|
478
|
-
* - `key`:
|
|
479
|
-
* - `locale`:
|
|
480
|
-
* - `extension`:
|
|
481
|
-
* - `componentFileName`:
|
|
482
|
-
* - `componentExtension`:
|
|
483
|
-
* - `format`:
|
|
484
|
-
* - `componentFormat`:
|
|
485
|
-
* - `componentDirPath`:
|
|
506
|
+
* Variable list:
|
|
507
|
+
* - `fileName`: File name.
|
|
508
|
+
* - `key`: Content key.
|
|
509
|
+
* - `locale`: Content locale.
|
|
510
|
+
* - `extension`: File extension.
|
|
511
|
+
* - `componentFileName`: Component file name.
|
|
512
|
+
* - `componentExtension`: Component file extension.
|
|
513
|
+
* - `format`: Dictionary format.
|
|
514
|
+
* - `componentFormat`: Component dictionary format.
|
|
515
|
+
* - `componentDirPath`: Component directory path.
|
|
486
516
|
*/
|
|
487
517
|
output: ({ locale, key }) => `compiler/${locale}/${key}.json`,
|
|
488
518
|
|
|
489
519
|
/**
|
|
490
|
-
* Indicates
|
|
491
|
-
*
|
|
520
|
+
* Indicates whether components should be saved after being transformed.
|
|
521
|
+
* In this way, the compiler can be run only once to transform the application and can then be removed.
|
|
492
522
|
*/
|
|
493
523
|
saveComponents: false,
|
|
494
524
|
|
|
495
525
|
/**
|
|
496
|
-
*
|
|
526
|
+
* Only insert content into the generated file. Useful for per-language JSON output for i18next or ICU MessageFormat.
|
|
497
527
|
*/
|
|
498
528
|
noMetadata: false,
|
|
499
529
|
|
|
500
530
|
/**
|
|
501
531
|
* Dictionary key prefix
|
|
502
532
|
*/
|
|
503
|
-
dictionaryKeyPrefix: "", // Add optional prefix
|
|
533
|
+
dictionaryKeyPrefix: "", // Add an optional prefix to the extracted dictionary keys
|
|
504
534
|
},
|
|
505
535
|
|
|
506
536
|
/**
|
|
507
|
-
* Custom schemas
|
|
537
|
+
* Custom schemas for validating dictionary content.
|
|
508
538
|
*/
|
|
509
539
|
schemas: {
|
|
510
540
|
"my-schema": z.object({
|
|
@@ -521,9 +551,11 @@ const config: IntlayerConfig = {
|
|
|
521
551
|
export default config;
|
|
522
552
|
````
|
|
523
553
|
|
|
554
|
+
---
|
|
555
|
+
|
|
524
556
|
## Configuration Reference
|
|
525
557
|
|
|
526
|
-
The following sections describe the various configuration settings available
|
|
558
|
+
The following sections describe the various configuration settings available in Intlayer.
|
|
527
559
|
|
|
528
560
|
---
|
|
529
561
|
|
|
@@ -531,593 +563,360 @@ The following sections describe the various configuration settings available for
|
|
|
531
563
|
|
|
532
564
|
Defines settings related to internationalisation, including available locales and the default locale for the application.
|
|
533
565
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
- _Example_: `['en', 'fr', 'es']`
|
|
541
|
-
|
|
542
|
-
- **requiredLocales**:
|
|
543
|
-
- _Type_: `string[]`
|
|
544
|
-
- _Default_: `[]`
|
|
545
|
-
- _Description_: The list of required locales in the application.
|
|
546
|
-
- _Example_: `[]`
|
|
547
|
-
- _Note_: If empty, all locales are required in `strict` mode.
|
|
548
|
-
- _Note_: Ensure required locales are also defined in the `locales` field.
|
|
549
|
-
- **strictMode**:
|
|
550
|
-
- _Type_: `string`
|
|
551
|
-
- _Default_: `inclusive`
|
|
552
|
-
- _Description_: Ensures strong implementations of internationalised content using TypeScript.
|
|
553
|
-
- _Note_: If set to "strict", the translation `t` function will require each declared locale to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.
|
|
554
|
-
- _Note_: If set to "inclusive", the translation `t` function will require each declared locale to be defined. If one locale is missing, it will throw a warning. But it will accept if a locale is not declared in your config, but exists.
|
|
555
|
-
- _Note_: If set to "loose", the translation `t` function will accept any existing locale.
|
|
556
|
-
|
|
557
|
-
- **defaultLocale**:
|
|
558
|
-
- _Type_: `string`
|
|
559
|
-
- _Default_: `'en'`
|
|
560
|
-
- _Description_: The default locale used as a fallback if the requested locale is not found.
|
|
561
|
-
- _Example_: `'en'`
|
|
562
|
-
- _Note_: This is used to determine the locale when none is specified in the URL, cookie, or header.
|
|
566
|
+
| Field | Type | Description | Example | Note |
|
|
567
|
+
| ----------------- | ---------- | -------------------------------------------------------------------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
568
|
+
| `locales` | `string[]` | List of locales supported in the application. Default: `[Locales.ENGLISH]` | `['en', 'fr', 'es']` | |
|
|
569
|
+
| `requiredLocales` | `string[]` | List of mandatory locales in the application. Default: `[]` | `[]` | If empty, all locales are mandatory in `strict` mode. Ensure mandatory locales are also defined in the `locales` field. |
|
|
570
|
+
| `strictMode` | `string` | Guarantees robust internationalised content implementation using TypeScript. Default: `inclusive` | | If `"strict"`: the `t` function requires every declared locale to be defined — throws an error if any are missing or undeclared. If `"inclusive"`: warns about missing locales but accepts existing undeclared ones. If `"loose"`: accepts any existing locale. |
|
|
571
|
+
| `defaultLocale` | `string` | Default locale used as a fallback if the requested locale is not found. Default: `Locales.ENGLISH` | `'en'` | Used to determine the locale when no locale is specified in the URL, cookie, or header. |
|
|
563
572
|
|
|
564
573
|
---
|
|
565
574
|
|
|
566
575
|
### Editor Configuration
|
|
567
576
|
|
|
568
|
-
Defines settings related to the integrated editor, including server port and
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
- **cookieName**:
|
|
672
|
-
- _Type_: `string`
|
|
673
|
-
- _Default_: `'intlayer-locale'`
|
|
674
|
-
- _Description_: The name of the cookie used to store the locale.
|
|
675
|
-
- _Example_: `'custom-locale'`
|
|
676
|
-
- _Note_: Used to persist the locale across sessions.
|
|
677
|
-
|
|
678
|
-
- **prefixDefault**:
|
|
679
|
-
- _Type_: `boolean`
|
|
680
|
-
- _Default_: `false`
|
|
681
|
-
- _Description_: Whether to include the default locale in the URL.
|
|
682
|
-
- _Example_: `true`
|
|
683
|
-
- _Note_:
|
|
684
|
-
- If `true` and `defaultLocale = 'en'`: path = `/en/dashboard` or `/fr/dashboard`
|
|
685
|
-
- If `false` and `defaultLocale = 'en'`: path = `/dashboard` or `/fr/dashboard`
|
|
686
|
-
|
|
687
|
-
- **basePath**:
|
|
688
|
-
- _Type_: `string`
|
|
689
|
-
- _Default_: `''`
|
|
690
|
-
- _Description_: The base path for the application URLs.
|
|
691
|
-
- _Example_: `'/my-app'`
|
|
692
|
-
- _Note_:
|
|
693
|
-
- If the application is hosted at `https://example.com/my-app`
|
|
694
|
-
- The base path is `'/my-app'`
|
|
695
|
-
- The URL will be `https://example.com/my-app/en`
|
|
696
|
-
- If the base path is not set, the URL will be `https://example.com/en`
|
|
697
|
-
|
|
698
|
-
- **rewrite**:
|
|
699
|
-
- _Type_: `Record<string, StrictModeLocaleMap<string>>`
|
|
700
|
-
- _Default_: `undefined`
|
|
701
|
-
- _Description_: Custom URL rewriting rules that override the default routing mode for specific paths. Allows you to define locale-specific paths that differ from the standard routing behaviour. Supports dynamic route parameters using `[param]` syntax.
|
|
702
|
-
- _Example_:
|
|
703
|
-
```typescript
|
|
704
|
-
routing: {
|
|
705
|
-
mode: "prefix-no-default", // Fallback strategy
|
|
706
|
-
rewrite: nextjsRewrite({
|
|
707
|
-
"/[locale]/about": {
|
|
708
|
-
en: "/[locale]/about",
|
|
709
|
-
fr: "/[locale]/a-propos",
|
|
710
|
-
},
|
|
711
|
-
"/[locale]/product/[slug]": {
|
|
712
|
-
en: "/[locale]/product/[slug]",
|
|
713
|
-
fr: "/[locale]/produit/[slug]",
|
|
714
|
-
},
|
|
715
|
-
"/[locale]/blog/[category]/[id]": {
|
|
716
|
-
en: "/[locale]/blog/[category]/[id]",
|
|
717
|
-
fr: "/[locale]/journal/[category]/[id]",
|
|
718
|
-
},
|
|
719
|
-
}),
|
|
720
|
-
}
|
|
721
|
-
```
|
|
722
|
-
- _Note_: The rewrite rules take precedence over the default `mode` behaviour. If a path matches a rewrite rule, the localised path from the rewrite configuration will be used instead of the standard locale prefixing.
|
|
723
|
-
- _Note_: Dynamic route parameters are supported using bracket notation (e.g., `[slug]`, `[id]`). The parameter values are automatically extracted from the URL and interpolated into the rewritten path.
|
|
724
|
-
- _Note_: Works with both Next.js and Vite applications. The middleware/proxy will automatically rewrite incoming requests to match the internal route structure.
|
|
725
|
-
- _Note_: When generating URLs with `getLocalizedUrl()`, the rewrite rules are automatically applied if they match the provided path.
|
|
726
|
-
- _Reference_: For more information, see [Custom URL Rewrites](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/custom_url_rewrites.md).
|
|
727
|
-
|
|
728
|
-
- **serverSetCookie**:
|
|
729
|
-
- _Type_: `string`
|
|
730
|
-
- _Default_: `'always'`
|
|
731
|
-
- _Description_: Rule for setting the locale cookie on the server.
|
|
732
|
-
- _Options_: `'always'`, `'never'`
|
|
733
|
-
- _Example_: `'never'`
|
|
734
|
-
- _Note_: Controls whether the locale cookie is set on every request or never.
|
|
735
|
-
|
|
736
|
-
- **noPrefix**:
|
|
737
|
-
- _Type_: `boolean`
|
|
738
|
-
- _Default_: `false`
|
|
739
|
-
- _Description_: Whether to omit the locale prefix from URLs.
|
|
740
|
-
- _Example_: `true`
|
|
741
|
-
- _Note_:
|
|
742
|
-
- If `true`: No prefix in the URL
|
|
743
|
-
- If `false`: Prefix in the URL
|
|
744
|
-
- Example with `basePath = '/my-app'`:
|
|
745
|
-
- If `noPrefix = false`: URL will be `https://example.com/my-app/en`
|
|
746
|
-
- If `noPrefix = true`: URL will be `https://example.com`
|
|
577
|
+
Defines settings related to the integrated editor, including server port and activity state.
|
|
578
|
+
|
|
579
|
+
| Field | Type | Description | Example | Note |
|
|
580
|
+
| ---------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
581
|
+
| `applicationURL` | `string` | The URL of your application. Default: `''` | `'http://localhost:3000'`, `'https://example.com'`, `process.env.INTLAYER_EDITOR_URL` | Used to restrict the origin of the editor for security reasons. If set to `'*'`, the editor can be accessed from any origin. |
|
|
582
|
+
| `port` | `number` | Port used by the Visual Editor server. Default: `8000` | | |
|
|
583
|
+
| `editorURL` | `string` | Editor server URL. Default: `'http://localhost:8000'` | `'http://localhost:3000'`, `'https://example.com'`, `process.env.INTLAYER_EDITOR_URL` | Used to restrict the origins that can interact with the application. If set to `'*'`, accessible from any origin. Must be set if changing the port or if the editor is hosted on a different domain. |
|
|
584
|
+
| `cmsURL` | `string` | Intlayer CMS URL. Default: `'https://intlayer.org'` | `'https://intlayer.org'` | |
|
|
585
|
+
| `backendURL` | `string` | Backend server URL. Default: `https://back.intlayer.org` | `http://localhost:4000` | |
|
|
586
|
+
| `enabled` | `boolean` | Indicates whether the app will interact with the visual editor. Default: `true` | `process.env.NODE_ENV !== 'production'` | If `false`, the editor cannot interact with the app. Disabling it for specific environments strengthens security. |
|
|
587
|
+
| `clientId` | `string | undefined` | Enables intlayer packages to authenticate with the backend using oAuth2. To get an access token, go to [intlayer.org/project](https://app.intlayer.org/project). Default: `undefined` | | Keep secret; store in environment variables. |
|
|
588
|
+
| `clientSecret` | `string | undefined` | Enables intlayer packages to authenticate with the backend using oAuth2. To get an access token, go to [intlayer.org/project](https://app.intlayer.org/project). Default: `undefined` | | Keep secret; store in environment variables. |
|
|
589
|
+
| `dictionaryPriorityStrategy` | `string` | Strategy for prioritising dictionaries when both local and distant dictionaries are present. Default: `'local_first'` | `'distant_first'` | `'distant_first'`: prioritises distant over local. `'local_first'`: prioritises local over distant. |
|
|
590
|
+
| `liveSync` | `boolean` | Indicates whether the app server should hot-reload content when a change is detected on the CMS / Visual Editor / Backend. Default: `true` | `true` | When a dictionary is added/updated, the app updates the page content. Live sync outsources content to another server, which may slightly affect performance. It is recommended to host both on the same machine. |
|
|
591
|
+
| `liveSyncPort` | `number` | Live sync server port. Default: `4000` | `4000` | |
|
|
592
|
+
| `liveSyncURL` | `string` | Live sync server URL. Default: `'http://localhost:{liveSyncPort}'` | `'https://example.com'` | Points to localhost by default; can be changed to a remote live sync server. |
|
|
593
|
+
|
|
594
|
+
### Routing Configuration
|
|
595
|
+
|
|
596
|
+
Settings that control routing behaviour, including URL structure, locale storage, and middleware handling.
|
|
597
|
+
|
|
598
|
+
| Field | Type | Description | Example | Note |
|
|
599
|
+
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
600
|
+
| `mode` | `'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params'` | URL routing mode for locale handling. Default: `'prefix-no-default'` | `'prefix-no-default'`: `/dashboard` (en) or `/fr/dashboard` (fr). `'prefix-all'`: `/en/dashboard`. `'no-prefix'`: locale is handled by other means. `'search-params'`: `/dashboard?locale=fr` | Does not affect cookie or locale storage management. |
|
|
601
|
+
| `storage` | `false | 'cookie' | 'localStorage' | 'sessionStorage' | 'header' | CookiesAttributes | StorageAttributes | Array` | Configuration for storing the locale on the client. Default: `['cookie', 'header']` | `'localStorage'`, `[{ type: 'cookie', name: 'custom-locale', secure: true }]` | See the Storage Options table below. |
|
|
602
|
+
| `basePath` | `string` | Base path for application URLs. Default: `''` | `'/my-app'` | If the app is at `https://example.com/my-app`, basePath is `'/my-app'` and URLs become `https://example.com/my-app/en`. |
|
|
603
|
+
| `rewrite` | `Record<string, StrictModeLocaleMap<string>>` | Custom URL rewrite rules that override the default routing mode for specific paths. Supports dynamic parameters `[param]`. Default: `undefined` | See example below | Rewrite rules take priority over the `mode`. Works with Next.js and Vite. `getLocalizedUrl()` automatically applies matching rules. See [Custom URL Rewrites](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/custom_url_rewrites.md). |
|
|
604
|
+
|
|
605
|
+
**`rewrite` Example**:
|
|
606
|
+
|
|
607
|
+
```typescript
|
|
608
|
+
routing: {
|
|
609
|
+
mode: "prefix-no-default", // Fallback strategy
|
|
610
|
+
rewrite: nextjsRewrite({
|
|
611
|
+
"/about": {
|
|
612
|
+
en: "/about",
|
|
613
|
+
fr: "/a-propos",
|
|
614
|
+
},
|
|
615
|
+
"/product/[slug]": {
|
|
616
|
+
en: "/product/[slug]",
|
|
617
|
+
fr: "/produit/[slug]",
|
|
618
|
+
},
|
|
619
|
+
"/blog/[category]/[id]": {
|
|
620
|
+
en: "/blog/[category]/[id]",
|
|
621
|
+
fr: "/journal/[category]/[id]",
|
|
622
|
+
},
|
|
623
|
+
}),
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
#### Storage Options
|
|
628
|
+
|
|
629
|
+
| Value | Description | Note |
|
|
630
|
+
| ------------------ | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
631
|
+
| `'cookie'` | Stores locale in cookies — accessible by both client and server sides. | For GDPR compliance, ensure proper user consent is obtained. Customisable via `CookiesAttributes` (`{ type: 'cookie', name: 'custom-locale', secure: true, httpOnly: false }`). |
|
|
632
|
+
| `'localStorage'` | Stores locale in the browser with no expiry date — client-side only. | Does not expire unless explicitly cleared. Intlayer proxy cannot access it. Customisable via `StorageAttributes` (`{ type: 'localStorage', name: 'custom-locale' }`). |
|
|
633
|
+
| `'sessionStorage'` | Stores locale for the duration of the page session — client-side only. | Cleared when tab/window is closed. Intlayer proxy cannot access it. Customisable via `StorageAttributes` (`{ type: 'sessionStorage', name: 'custom-locale' }`). |
|
|
634
|
+
| `'header'` | Stores or transmits locale via HTTP headers — server-side only. | Useful for API calls. Client-side cannot access it. Customisable via `StorageAttributes` (`{ type: 'header', name: 'custom-locale' }`). |
|
|
635
|
+
|
|
636
|
+
#### Cookie Attributes
|
|
637
|
+
|
|
638
|
+
When using cookie storage, you can configure additional cookie attributes:
|
|
639
|
+
|
|
640
|
+
| Field | Type | Description |
|
|
641
|
+
| ---------- | ------------------------------------- | --------------------------------------------------- |
|
|
642
|
+
| `name` | `string` | Cookie name. Default: `'INTLAYER_LOCALE'` |
|
|
643
|
+
| `domain` | `string` | Cookie domain. Default: `undefined` |
|
|
644
|
+
| `path` | `string` | Cookie path. Default: `undefined` |
|
|
645
|
+
| `secure` | `boolean` | Requires HTTPS. Default: `undefined` |
|
|
646
|
+
| `httpOnly` | `boolean` | HTTP-only flag. Default: `undefined` |
|
|
647
|
+
| `sameSite` | `'strict' | 'lax' | 'none'` | SameSite policy. |
|
|
648
|
+
| `expires` | `Date | number` | Expiry date or number of days. Default: `undefined` |
|
|
649
|
+
|
|
650
|
+
#### Locale Storage Attributes
|
|
651
|
+
|
|
652
|
+
When using localStorage or sessionStorage:
|
|
653
|
+
|
|
654
|
+
| Field | Type | Description |
|
|
655
|
+
| ------ | ---------------------------------------- | ---------------------------------------------- |
|
|
656
|
+
| `type` | `'localStorage' | 'sessionStorage'` | Storage type. |
|
|
657
|
+
| `name` | `string` | Storage key name. Default: `'INTLAYER_LOCALE'` |
|
|
658
|
+
|
|
659
|
+
#### Configuration Examples
|
|
660
|
+
|
|
661
|
+
Here are some common configuration examples for the new v7 routing structure:
|
|
662
|
+
|
|
663
|
+
**Basic Configuration (Default)**:
|
|
664
|
+
|
|
665
|
+
```typescript
|
|
666
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
667
|
+
// intlayer.config.ts
|
|
668
|
+
const config: IntlayerConfig = {
|
|
669
|
+
internationalization: {
|
|
670
|
+
locales: ["en", "fr", "es"],
|
|
671
|
+
defaultLocale: "en",
|
|
672
|
+
},
|
|
673
|
+
routing: {
|
|
674
|
+
mode: "prefix-no-default",
|
|
675
|
+
storage: "localStorage",
|
|
676
|
+
basePath: "",
|
|
677
|
+
},
|
|
678
|
+
};
|
|
747
679
|
|
|
748
|
-
|
|
680
|
+
export default config;
|
|
681
|
+
```
|
|
749
682
|
|
|
750
|
-
|
|
683
|
+
**GDPR Compliant Configuration**:
|
|
751
684
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
- _Note_: Customising file extensions can help avoid conflicts.
|
|
779
|
-
|
|
780
|
-
- **contentDir**:
|
|
781
|
-
- _Type_: `string[]`
|
|
782
|
-
- _Default_: `['.']`
|
|
783
|
-
- _Example_: `['src', '../../ui-library', require.resolve("@my-package/content")]`
|
|
784
|
-
- _Description_: The directory path where content definition files (`.content.*`) are stored.
|
|
785
|
-
- _Note_: This is used to watch for content files to rebuild dictionaries.
|
|
786
|
-
|
|
787
|
-
- **codeDir**:
|
|
788
|
-
- _Type_: `string[]`
|
|
789
|
-
- _Default_: `['.']`
|
|
790
|
-
- _Example_: `['src', '../../ui-library']`
|
|
791
|
-
- _Description_: The directory path where the code is stored, relative to the base directory.
|
|
792
|
-
- _Note_: This is used to watch for code files to transform (prune, optimise). Keeping this separate from `contentDir` can improve build performance by avoiding unnecessary scans of content files.
|
|
793
|
-
|
|
794
|
-
- **excludedPath**:
|
|
795
|
-
- _Type_: `string[]`
|
|
796
|
-
- _Default_: `['**/node_modules/**', '**/dist/**', '**/build/**', '**/.intlayer/**', '**/.next/**', '**/.nuxt/**', '**/.expo/**', '**/.vercel/**', '**/.turbo/**', '**/.tanstack/**']`
|
|
797
|
-
- _Description_: Directories excluded from content search.
|
|
798
|
-
- _Note_: This setting is not yet used, but planned for future implementation.
|
|
799
|
-
|
|
800
|
-
- **formatCommand**:
|
|
801
|
-
- _Type_: `string`
|
|
802
|
-
- _Default_: `undefined`
|
|
803
|
-
- _Description_: The command to format the content. When Intlayer writes your .content files locally, this command will be used to format the content.
|
|
804
|
-
- _Example_: `'npx prettier --write "{{file}}" --log-level silent'` Using Prettier
|
|
805
|
-
- _Example_: `'npx biome format "{{file}}" --write --log-level none'` Using Biome
|
|
806
|
-
- _Example_: `'npx eslint --fix "{{file}}" --quiet'` Using ESLint
|
|
807
|
-
- _Note_: Intlayer will replace the {{file}} with the path of the file to format.
|
|
808
|
-
- _Note_: If not set, Intlayer will try to detect the format command automatically. By trying to resolve the following commands: prettier, biome, eslint.
|
|
685
|
+
```typescript
|
|
686
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
687
|
+
// intlayer.config.ts
|
|
688
|
+
const config: IntlayerConfig = {
|
|
689
|
+
internationalization: {
|
|
690
|
+
locales: ["en", "fr", "es"],
|
|
691
|
+
defaultLocale: "en",
|
|
692
|
+
},
|
|
693
|
+
routing: {
|
|
694
|
+
mode: "prefix-no-default",
|
|
695
|
+
storage: [
|
|
696
|
+
{
|
|
697
|
+
type: "localStorage",
|
|
698
|
+
name: "user-locale",
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
type: "cookie",
|
|
702
|
+
name: "user-locale",
|
|
703
|
+
secure: true,
|
|
704
|
+
sameSite: "strict",
|
|
705
|
+
httpOnly: false,
|
|
706
|
+
},
|
|
707
|
+
],
|
|
708
|
+
basePath: "",
|
|
709
|
+
},
|
|
710
|
+
};
|
|
809
711
|
|
|
810
|
-
|
|
712
|
+
export default config;
|
|
713
|
+
```
|
|
811
714
|
|
|
812
|
-
|
|
715
|
+
**Search Parameters Mode**:
|
|
813
716
|
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
- _Description_: The directory path for storing localisation dictionaries.
|
|
829
|
-
|
|
830
|
-
- **moduleAugmentationDir**:
|
|
831
|
-
- _Type_: `string`
|
|
832
|
-
- _Default_: `'.intlayer/types'`
|
|
833
|
-
- _Description_: Directory for module augmentation, allowing better IDE suggestions and type checking.
|
|
834
|
-
- _Example_: `'intlayer-types'`
|
|
835
|
-
- _Note_: Be sure to include this in `tsconfig.json`.
|
|
836
|
-
|
|
837
|
-
- **unmergedDictionariesDir**:
|
|
838
|
-
- _Type_: `string`
|
|
839
|
-
- _Default_: `'.intlayer/unmerged_dictionary'`
|
|
840
|
-
- _Description_: The directory for storing unmerged dictionaries.
|
|
841
|
-
|
|
842
|
-
- **typesDir**:
|
|
843
|
-
- _Type_: `string`
|
|
844
|
-
- _Default_: `'.intlayer/types'`
|
|
845
|
-
- _Description_: The directory for storing dictionary types.
|
|
846
|
-
|
|
847
|
-
- **mainDir**:
|
|
848
|
-
- _Type_: `string`
|
|
849
|
-
- _Default_: `'.intlayer/main'`
|
|
850
|
-
- _Description_: The directory where main application files are stored.
|
|
851
|
-
|
|
852
|
-
- **configDir**:
|
|
853
|
-
- _Type_: `string`
|
|
854
|
-
- _Default_: `'.intlayer/config'`
|
|
855
|
-
- _Description_: The directory where the configuration files are stored.
|
|
856
|
-
|
|
857
|
-
- **cacheDir**:
|
|
858
|
-
- _Type_: `string`
|
|
859
|
-
- _Default_: `'.intlayer/cache'`
|
|
860
|
-
- _Description_: The directory where the cache files are stored.
|
|
717
|
+
```typescript
|
|
718
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
719
|
+
// intlayer.config.ts
|
|
720
|
+
const config: IntlayerConfig = {
|
|
721
|
+
internationalization: {
|
|
722
|
+
locales: ["en", "fr", "es"],
|
|
723
|
+
defaultLocale: "en",
|
|
724
|
+
},
|
|
725
|
+
routing: {
|
|
726
|
+
mode: "search-params",
|
|
727
|
+
storage: "localStorage",
|
|
728
|
+
basePath: "",
|
|
729
|
+
},
|
|
730
|
+
};
|
|
861
731
|
|
|
862
|
-
|
|
732
|
+
export default config;
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
**No Prefix Mode with Custom Storage**:
|
|
736
|
+
|
|
737
|
+
```typescript
|
|
738
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
739
|
+
// intlayer.config.ts
|
|
740
|
+
const config: IntlayerConfig = {
|
|
741
|
+
internationalization: {
|
|
742
|
+
locales: ["en", "fr", "es"],
|
|
743
|
+
defaultLocale: "en",
|
|
744
|
+
},
|
|
745
|
+
routing: {
|
|
746
|
+
mode: "no-prefix",
|
|
747
|
+
storage: {
|
|
748
|
+
type: "sessionStorage",
|
|
749
|
+
name: "app-locale",
|
|
750
|
+
},
|
|
751
|
+
basePath: "/my-app",
|
|
752
|
+
},
|
|
753
|
+
};
|
|
863
754
|
|
|
864
|
-
|
|
755
|
+
export default config;
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
**Custom URL Rewrite with Dynamic Paths**:
|
|
759
|
+
|
|
760
|
+
```typescript
|
|
761
|
+
// intlayer.config.ts
|
|
762
|
+
import { nextjsRewrite } from "intlayer/routing";
|
|
763
|
+
|
|
764
|
+
const config: IntlayerConfig = {
|
|
765
|
+
internationalization: {
|
|
766
|
+
locales: ["en", "fr"],
|
|
767
|
+
defaultLocale: "en",
|
|
768
|
+
},
|
|
769
|
+
routing: {
|
|
770
|
+
mode: "prefix-no-default", // Fallback for paths not rewritten
|
|
771
|
+
storage: "cookie",
|
|
772
|
+
rewrite: nextjsRewrite({
|
|
773
|
+
"/about": {
|
|
774
|
+
en: "/about",
|
|
775
|
+
fr: "/a-propos",
|
|
776
|
+
},
|
|
777
|
+
"/product/[slug]": {
|
|
778
|
+
en: "/product/[slug]",
|
|
779
|
+
fr: "/produit/[slug]",
|
|
780
|
+
},
|
|
781
|
+
"/blog/[category]/[id]": {
|
|
782
|
+
en: "/blog/[category]/[id]",
|
|
783
|
+
fr: "/journal/[category]/[id]",
|
|
784
|
+
},
|
|
785
|
+
}),
|
|
786
|
+
},
|
|
787
|
+
};
|
|
865
788
|
|
|
866
|
-
|
|
789
|
+
export default config;
|
|
790
|
+
```
|
|
867
791
|
|
|
868
|
-
|
|
869
|
-
2. **Fallback Behaviour**: Provide fallback values when specific fields are not defined, allowing you to define dictionary operation behaviour globally
|
|
792
|
+
---
|
|
870
793
|
|
|
871
|
-
|
|
794
|
+
### Content Configuration
|
|
872
795
|
|
|
873
|
-
|
|
796
|
+
Settings pertaining to the processing of content within the application (directory names, file extensions, and derived configurations).
|
|
874
797
|
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
- _Description_: Controls how dictionaries are imported.
|
|
884
|
-
- _Example_: `'dynamic'`
|
|
885
|
-
- **priority**
|
|
886
|
-
- **live**
|
|
887
|
-
- **schema**
|
|
888
|
-
- **title**
|
|
889
|
-
- **tags**
|
|
890
|
-
- **version**
|
|
798
|
+
| Field | Type | Description | Example | Note |
|
|
799
|
+
| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
800
|
+
| `watch` | `boolean` | Indicates whether Intlayer should watch for changes in content declaration files to rebuild dictionaries. Default: `process.env.NODE_ENV === 'development'` | | |
|
|
801
|
+
| `fileExtensions` | `string[]` | File extensions used for scanning content declaration files. Default: `['.content.ts', '.content.js', '.content.mjs', '.content.cjs', '.content.json', '.content.json5', '.content.jsonc']` | `['.content.ts', '.content.js']` | |
|
|
802
|
+
| `contentDir` | `string[]` | Paths to the directories where the content declaration files are located. Default: `['.']` | `['src/content']` | |
|
|
803
|
+
| `codeDir` | `string[]` | Paths to the directories where your application's source code files are located. Default: `['.']` | `['src']` | Used to optimise the build and ensure that code transformation and hot reloading only apply to necessary files. |
|
|
804
|
+
| `excludedPath` | `string[]` | Paths excluded from content scanning. Default: `['node_modules', '.intlayer', '.next', 'dist', 'build']` | `['src/styles']` | |
|
|
805
|
+
| `formatCommand` | `string` | Command that will be run to format newly created or updated content files. Default: `undefined` | `'npx prettier --write "{{file}}"'` | Used during content extraction or through the visual editor. |
|
|
891
806
|
|
|
892
807
|
---
|
|
893
808
|
|
|
894
|
-
###
|
|
809
|
+
### Dictionary Configuration
|
|
810
|
+
|
|
811
|
+
Settings that control dictionary operations, including auto-filling behaviour and content creation.
|
|
812
|
+
|
|
813
|
+
This dictionary configuration has two main purposes:
|
|
895
814
|
|
|
896
|
-
|
|
815
|
+
1. **Default values**: Defining default values when creating content declaration files.
|
|
816
|
+
2. **Fallback behaviour**: Allows setting up the behaviour of dictionary operations globally, providing fallback values when specific fields are not defined.
|
|
897
817
|
|
|
898
|
-
|
|
818
|
+
For more information on how content declaration files and configuration values are applied, see the [content file documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/content_file.md).
|
|
899
819
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
- _Note_: The mode of the logger. Verbose mode will log more information, but can be used for debugging purposes. Disabled mode will disable the logger.
|
|
820
|
+
| Field | Type | Description | Example | Note |
|
|
821
|
+
| --------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
822
|
+
| `fill` | `boolean | FilePathPattern | Partial<Record<Locale, boolean | FilePathPattern>>` | Controls how auto-fill (AI translation) output files are generated. Default: `true` | See example below | `true`: default path (same file as source). `false`: disabled. String/function patterns generate files per language. Object per language: each language maps to its own pattern; `false` skips that language. Including a `{{locale}}` variable triggers per-language generation. Dictionary-level `fill` always takes precedence over this global configuration. |
|
|
823
|
+
| `importMode` | `'static' | 'dynamic' | 'fetch'` | Controls how dictionaries are imported. Default: `'static'` | `'dynamic'` | `'static'`: Statically imported. `'dynamic'`: Dynamically imported via 'Suspense'. `'fetch'`: Dynamically fetched via 'Live Sync API'. Does not affect `getIntlayer`, `getDictionary`, `useDictionary`, etc. |
|
|
824
|
+
| `location` | `'local' | 'remote' | 'hybrid' | string` | Where dictionaries are stored. Default: `'local'` | `'remote'` | `'local'`: filesystem. `'remote'`: Intlayer CMS. `'hybrid'`: both. |
|
|
825
|
+
| `contentAutoTransformation` | `boolean` | Indicates whether content files should be automatically transformed (e.g. from Markdown to HTML). Default: `false` | `true` | Useful for processing Markdown fields via @intlayer/markdown. |
|
|
907
826
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
827
|
+
**`fill` example**:
|
|
828
|
+
|
|
829
|
+
```ts
|
|
830
|
+
dictionary: {
|
|
831
|
+
fill: {
|
|
832
|
+
en: '/locales/en/{{key}}.content.json',
|
|
833
|
+
fr: ({ key }) => `/locales/fr/${key}.content.json`,
|
|
834
|
+
es: false,
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
---
|
|
914
840
|
|
|
915
841
|
### AI Configuration
|
|
916
842
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
- **DeepSeek**
|
|
930
|
-
- **Google Gemini**
|
|
931
|
-
- **Google AI Studio**
|
|
932
|
-
- **Google Vertex**
|
|
933
|
-
- **Meta Llama**
|
|
934
|
-
- **Ollama**
|
|
935
|
-
- **OpenRouter**
|
|
936
|
-
- **Alibaba Cloud**
|
|
937
|
-
- **Fireworks**
|
|
938
|
-
- **Hugging Face**
|
|
939
|
-
- **Groq**
|
|
940
|
-
- **Amazon Bedrock**
|
|
941
|
-
- **Together.ai**
|
|
942
|
-
- **ollama**
|
|
943
|
-
|
|
944
|
-
#### Properties
|
|
945
|
-
|
|
946
|
-
- **provider**:
|
|
947
|
-
- _Type_: `string`
|
|
948
|
-
- _Default_: `'openai'`
|
|
949
|
-
- _Description_: The provider to use for the AI features of Intlayer.
|
|
950
|
-
- _Options_: `'openai'`, `'anthropic'`, `'mistral'`, `'deepseek'`, `'gemini'`, `'ollama'`, `'openrouter'`, `'alibaba'`, `'fireworks'`, `'groq'`, `'huggingface'`, `'bedrock'`, `'googleaistudio'`, `'googlevertex'`, `'togetherai'`
|
|
951
|
-
- _Example_: `'anthropic'`
|
|
952
|
-
- _Note_: Different providers may require different API keys and have different pricing models.
|
|
953
|
-
|
|
954
|
-
- **model**:
|
|
955
|
-
- _Type_: `string`
|
|
956
|
-
- _Default_: None
|
|
957
|
-
- _Description_: The model to use for the AI features of Intlayer.
|
|
958
|
-
- _Example_: `'gpt-4o-2024-11-20'`
|
|
959
|
-
- _Note_: The specific model to use varies by provider.
|
|
960
|
-
|
|
961
|
-
- **temperature**:
|
|
962
|
-
- _Type_: `number`
|
|
963
|
-
- _Default_: None
|
|
964
|
-
- _Description_: The temperature controls the randomness of the AI's responses.
|
|
965
|
-
- _Example_: `0.1`
|
|
966
|
-
- _Note_: A higher temperature will make the AI more creative and less predictable.
|
|
967
|
-
|
|
968
|
-
- **apiKey**:
|
|
969
|
-
- _Type_: `string`
|
|
970
|
-
- _Default_: None
|
|
971
|
-
- _Description_: Your API key for the selected provider.
|
|
972
|
-
- _Example_: `process.env.OPENAI_API_KEY`
|
|
973
|
-
- _Note_: Important: API keys should be kept confidential and not shared publicly. Please ensure they are stored securely, such as in environment variables.
|
|
974
|
-
|
|
975
|
-
- **applicationContext**:
|
|
976
|
-
- _Type_: `string`
|
|
977
|
-
- _Default_: None
|
|
978
|
-
- _Description_: Provides additional context about your application to the AI model, assisting it in generating more accurate and contextually appropriate translations. This can include information about your app's domain, target audience, tone, or specific terminology.
|
|
979
|
-
|
|
980
|
-
- **baseURL**:
|
|
981
|
-
- _Type_: `string`
|
|
982
|
-
- _Default_: None
|
|
983
|
-
- _Description_: The base URL for the AI API.
|
|
984
|
-
- _Example_: `'https://api.openai.com/v1'`
|
|
985
|
-
- _Note_: Can be used to point to a local, or custom AI API endpoint.
|
|
986
|
-
|
|
987
|
-
- **dataSerialization**:
|
|
988
|
-
- _Type_: `'json' | 'toon'`
|
|
989
|
-
- _Default_: `'json'`
|
|
990
|
-
- _Description_: The data serialization format to use for the AI features of Intlayer.
|
|
991
|
-
- _Example_: `'toon'`
|
|
992
|
-
- _Note_: `json`: Standard, reliable; uses more tokens. `toon`: Fewer tokens, less consistent than JSON.
|
|
843
|
+
Defines settings for Intlayer's AI-powered features, such as translation construction.
|
|
844
|
+
|
|
845
|
+
| Field | Type | Description | Example | Note |
|
|
846
|
+
| -------------------- | ---------------------- | ---------------------------------------------------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
847
|
+
| `provider` | `string` | AI provider to use. | `'openai'`, `'anthropic'`, `'googlevertex'` | |
|
|
848
|
+
| `model` | `string` | AI model to use. | `'gpt-4o'`, `'claude-3-5-sonnet-20240620'` | |
|
|
849
|
+
| `apiKey` | `string` | API key for the selected provider. | `process.env.OPENAI_API_KEY` | |
|
|
850
|
+
| `applicationContext` | `string` | Extra context about your app to improve AI translation accuracy. | `'A learning platform for children.'` | |
|
|
851
|
+
| `baseURL` | `string` | Optional base URL for API calls. | | Useful if you are using a proxy or local AI deployment. |
|
|
852
|
+
| `dataSerialization` | `'json' | 'toon'` | Defines how data is sent to the AI. Default: `'json'` | `'json'` | `'json'`: more robust and accurate. `'toon'`: uses fewer tokens but might be less stable. |
|
|
853
|
+
|
|
854
|
+
---
|
|
993
855
|
|
|
994
856
|
### Build Configuration
|
|
995
857
|
|
|
996
|
-
Settings
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
- **optimize**:
|
|
1022
|
-
- _Type_: `boolean`
|
|
1023
|
-
- _Default_: `process.env.NODE_ENV === 'production'`
|
|
1024
|
-
- _Description_: Controls whether the build should be optimised.
|
|
1025
|
-
- _Example_: `true`
|
|
1026
|
-
- _Note_: When enabled, Intlayer will replace all calls of dictionaries to optimise chunking. That way the final bundle will import only the dictionaries that are used. All imports will remain as static imports to avoid async processing when loading the dictionaries.
|
|
1027
|
-
- _Note_: Intlayer will replace all calls of `useIntlayer` with the defined mode by the `importMode` option and `getIntlayer` with `getDictionary`.
|
|
1028
|
-
- _Note_: This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
1029
|
-
- _Note_: Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
1030
|
-
|
|
1031
|
-
- **outputFormat**:
|
|
1032
|
-
- _Type_: `'esm' | 'cjs'`
|
|
1033
|
-
- _Default_: `'esm'`
|
|
1034
|
-
- _Description_: Controls the output format of the dictionaries.
|
|
1035
|
-
- _Example_: `'cjs'`
|
|
1036
|
-
- _Note_: The output format of the dictionaries.
|
|
1037
|
-
|
|
1038
|
-
- **traversePattern**:
|
|
1039
|
-
- _Type_: `string[]`
|
|
1040
|
-
- _Default_: `['**\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\/node_modules/**']`
|
|
1041
|
-
- _Description_: Patterns that define which files should be traversed during optimisation.
|
|
1042
|
-
- _Example_: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**/node_modules/**']`
|
|
1043
|
-
- _Note_: Use this to limit optimisation to relevant code files and improve build performance.
|
|
1044
|
-
- _Note_: This option will be ignored if `optimise` is disabled.
|
|
1045
|
-
- _Note_: Use glob pattern.
|
|
858
|
+
Settings for the Intlayer build process and optimisations.
|
|
859
|
+
|
|
860
|
+
| Field | Type | Description | Example | Note |
|
|
861
|
+
| -------------- | ------------------------ | ------------------------------------------------------------------------------------------------------- | ------- | ---- |
|
|
862
|
+
| `mode` | `'auto' | 'manual'` | Indicates whether Intlayer should run automatically during the app's pre-build steps. Default: `'auto'` | | |
|
|
863
|
+
| `optimize` | `boolean` | Indicates whether compiled dictionaries should be optimised for runtime. Default: `true` in production | | |
|
|
864
|
+
| `outputFormat` | `('cjs' | 'esm')[]` | Output format for generated dictionary files. Default: `['cjs', 'esm']` | | |
|
|
865
|
+
| `checkTypes` | `boolean` | Indicates whether Intlayer should check types in the generated files. Default: `false` | | |
|
|
866
|
+
|
|
867
|
+
---
|
|
868
|
+
|
|
869
|
+
### System Configuration
|
|
870
|
+
|
|
871
|
+
These settings are for advanced use cases and Intlayer's internal configuration.
|
|
872
|
+
|
|
873
|
+
| Field | Type | Description | Default |
|
|
874
|
+
| ------------------------- | -------- | ----------------------------------------- | --------------------------------- |
|
|
875
|
+
| `dictionariesDir` | `string` | Compiled dictionaries directory. | `'.intlayer/dictionary'` |
|
|
876
|
+
| `moduleAugmentationDir` | `string` | TypeScript module augmentation directory. | `'.intlayer/types'` |
|
|
877
|
+
| `unmergedDictionariesDir` | `string` | Unmerged dictionaries directory. | `'.intlayer/unmerged_dictionary'` |
|
|
878
|
+
| `typesDir` | `string` | Generated types directory. | `'.intlayer/types'` |
|
|
879
|
+
| `mainDir` | `string` | Main Intlayer file directory. | `'.intlayer/main'` |
|
|
880
|
+
| `configDir` | `string` | Compiled configuration files directory. | `'.intlayer/config'` |
|
|
881
|
+
| `cacheDir` | `string` | Cache files directory. | `'.intlayer/cache'` |
|
|
1046
882
|
|
|
1047
883
|
---
|
|
1048
884
|
|
|
1049
885
|
### Compiler Configuration
|
|
1050
886
|
|
|
1051
|
-
Settings
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
- **output**:
|
|
1089
|
-
- _Type_: `FilePathPattern`
|
|
1090
|
-
- _Default_: `undefined`
|
|
1091
|
-
- _Description_: Defines the output files path. Replaces `outputDir`. Supports dynamic variables via a template string or a function. Supported variables: `{{fileName}}`, `{{key}}`, `{{locale}}`, `{{extension}}`, `{{componentFileName}}`, `{{componentExtension}}`, `{{format}}`, `{{componentFormat}}`, `{{componentDirPath}}`.
|
|
1092
|
-
- _Note_: Paths starting with `./` are resolved relatively to the component directory. Paths starting with `/` are resolved relatively to the project root (`baseDir`).
|
|
1093
|
-
- _Note_: Including the `{{locale}}` variable in the path will enable the generation of separate dictionaries per locale.
|
|
1094
|
-
- _Example_:
|
|
1095
|
-
- **Create multi-locale files next to the component**:
|
|
1096
|
-
- String: `'./{{fileName}}{{extension}}'`
|
|
1097
|
-
- Function: `({ fileName, extension }) => \`./${fileName}${extension}\``
|
|
1098
|
-
|
|
1099
|
-
- **Output centralised JSON files per locale**:
|
|
1100
|
-
- String: `'/locales/{{locale}}/{{key}}.content.json'`
|
|
1101
|
-
- Function: `({ key, locale }) => \`/locales/${locale}/${key}.content.json\``
|
|
1102
|
-
|
|
1103
|
-
- **noMetadata**:
|
|
1104
|
-
- _Type_: `boolean`
|
|
1105
|
-
- _Default_: `false`
|
|
1106
|
-
- _Description_: Indicates if the metadata should be saved in the file. If true, the compiler will not save the metadata of the dictionaries (key, content wrapper). Useful for per-locale i18next or ICU MessageFormat JSON outputs.
|
|
1107
|
-
- _Note_: Useful if used with `loadJSON` plugin.
|
|
1108
|
-
- _Example_:
|
|
1109
|
-
If `true`:
|
|
1110
|
-
```json
|
|
1111
|
-
{
|
|
1112
|
-
"key": "value"
|
|
1113
|
-
}
|
|
1114
|
-
```
|
|
1115
|
-
If `false`:
|
|
1116
|
-
```json
|
|
1117
|
-
{
|
|
1118
|
-
"key": "value",
|
|
1119
|
-
"content": {
|
|
1120
|
-
"key": "value"
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
```
|
|
887
|
+
Settings for the Intlayer compiler (`intlayer compiler`).
|
|
888
|
+
|
|
889
|
+
| Field | Type | Description | Default |
|
|
890
|
+
| --------------------- | ------------------------ | ---------------------------------------------------------------------------------------- | ------- |
|
|
891
|
+
| `enabled` | `boolean` | Indicates whether the compiler is active. | `false` |
|
|
892
|
+
| `output` | `string | Function` | Output path for extracted dictionaries. | |
|
|
893
|
+
| `saveComponents` | `boolean` | Indicates whether original source files should be overwritten with transformed versions. | `false` |
|
|
894
|
+
| `noMetadata` | `boolean` | If `true`, the compiler will not include metadata in the generated files. | `false` |
|
|
895
|
+
| `dictionaryKeyPrefix` | `string` | Optional dictionary key prefix. | `''` |
|
|
896
|
+
|
|
897
|
+
---
|
|
898
|
+
|
|
899
|
+
### Logger Configuration
|
|
900
|
+
|
|
901
|
+
Settings for customising Intlayer log output.
|
|
902
|
+
|
|
903
|
+
| Field | Type | Description | Default |
|
|
904
|
+
| -------- | ---------------------------------------------- | ------------------- | -------------- |
|
|
905
|
+
| `mode` | `'default' | 'verbose' | 'disabled'` | Logging mode. | `'default'` |
|
|
906
|
+
| `prefix` | `string` | Log message prefix. | `'[intlayer]'` |
|
|
907
|
+
|
|
908
|
+
---
|
|
909
|
+
|
|
910
|
+
### Custom Schemas
|
|
911
|
+
|
|
912
|
+
| Field | Type | Description |
|
|
913
|
+
| --------- | --------------------------- | ------------------------------------------------------------------------ |
|
|
914
|
+
| `schemas` | `Record<string, ZodSchema>` | Allows defining Zod schemas for validating your dictionaries' structure. |
|
|
915
|
+
|
|
916
|
+
---
|
|
917
|
+
|
|
918
|
+
### Plugins
|
|
919
|
+
|
|
920
|
+
| Field | Type | Description |
|
|
921
|
+
| --------- | ------------------ | ------------------------------------- |
|
|
922
|
+
| `plugins` | `IntlayerPlugin[]` | List of Intlayer plugins to activate. |
|