@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.
Files changed (107) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  2. package/dist/cjs/blog.cjs +21 -1
  3. package/dist/cjs/blog.cjs.map +1 -1
  4. package/dist/cjs/common.cjs +81 -1
  5. package/dist/cjs/common.cjs.map +1 -0
  6. package/dist/cjs/doc.cjs +21 -1
  7. package/dist/cjs/doc.cjs.map +1 -1
  8. package/dist/cjs/frequentQuestions.cjs +21 -1
  9. package/dist/cjs/frequentQuestions.cjs.map +1 -1
  10. package/dist/cjs/generated/blog.entry.cjs +572 -1
  11. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  12. package/dist/cjs/generated/docs.entry.cjs +3032 -1
  13. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  14. package/dist/cjs/generated/frequentQuestions.entry.cjs +352 -1
  15. package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
  16. package/dist/cjs/generated/legal.entry.cjs +72 -1
  17. package/dist/cjs/generated/legal.entry.cjs.map +1 -1
  18. package/dist/cjs/index.cjs +34 -1
  19. package/dist/cjs/legal.cjs +21 -1
  20. package/dist/cjs/legal.cjs.map +1 -1
  21. package/dist/esm/blog.mjs +14 -1
  22. package/dist/esm/blog.mjs.map +1 -1
  23. package/dist/esm/common.mjs +67 -1
  24. package/dist/esm/common.mjs.map +1 -1
  25. package/dist/esm/doc.mjs +14 -1
  26. package/dist/esm/doc.mjs.map +1 -1
  27. package/dist/esm/frequentQuestions.mjs +14 -1
  28. package/dist/esm/frequentQuestions.mjs.map +1 -1
  29. package/dist/esm/generated/blog.entry.mjs +570 -1
  30. package/dist/esm/generated/blog.entry.mjs.map +1 -1
  31. package/dist/esm/generated/docs.entry.mjs +3030 -1
  32. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  33. package/dist/esm/generated/frequentQuestions.entry.mjs +350 -1
  34. package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
  35. package/dist/esm/generated/legal.entry.mjs +70 -1
  36. package/dist/esm/generated/legal.entry.mjs.map +1 -1
  37. package/dist/esm/index.mjs +6 -1
  38. package/dist/esm/legal.mjs +14 -1
  39. package/dist/esm/legal.mjs.map +1 -1
  40. package/dist/types/blog.d.ts +2 -2
  41. package/dist/types/common.d.ts +37 -2
  42. package/dist/types/common.d.ts.map +1 -0
  43. package/dist/types/doc.d.ts +2 -2
  44. package/dist/types/frequentQuestions.d.ts +2 -2
  45. package/dist/types/generated/blog.entry.d.ts +35 -2
  46. package/dist/types/generated/blog.entry.d.ts.map +1 -0
  47. package/dist/types/generated/docs.entry.d.ts +158 -2
  48. package/dist/types/generated/docs.entry.d.ts.map +1 -0
  49. package/dist/types/generated/frequentQuestions.entry.d.ts +24 -2
  50. package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -0
  51. package/dist/types/generated/legal.entry.d.ts +10 -2
  52. package/dist/types/generated/legal.entry.d.ts.map +1 -0
  53. package/dist/types/legal.d.ts +2 -2
  54. package/docs/ar/configuration.md +520 -722
  55. package/docs/ar/intlayer_with_storybook.md +521 -0
  56. package/docs/bn/configuration.md +922 -0
  57. package/docs/bn/intlayer_with_hono.md +428 -0
  58. package/docs/de/configuration.md +369 -743
  59. package/docs/de/intlayer_with_storybook.md +521 -0
  60. package/docs/en/configuration.md +181 -507
  61. package/docs/en/intlayer_with_storybook.md +521 -0
  62. package/docs/en-GB/configuration.md +456 -657
  63. package/docs/en-GB/intlayer_with_storybook.md +521 -0
  64. package/docs/es/configuration.md +379 -754
  65. package/docs/es/intlayer_with_storybook.md +521 -0
  66. package/docs/fr/configuration.md +376 -757
  67. package/docs/fr/intlayer_with_storybook.md +521 -0
  68. package/docs/hi/configuration.md +532 -728
  69. package/docs/hi/intlayer_with_storybook.md +521 -0
  70. package/docs/id/configuration.md +371 -684
  71. package/docs/id/intlayer_with_storybook.md +521 -0
  72. package/docs/it/configuration.md +397 -775
  73. package/docs/it/intlayer_with_storybook.md +521 -0
  74. package/docs/ja/configuration.md +525 -724
  75. package/docs/ja/intlayer_with_storybook.md +521 -0
  76. package/docs/ko/configuration.md +525 -724
  77. package/docs/ko/intlayer_with_storybook.md +521 -0
  78. package/docs/pl/configuration.md +430 -734
  79. package/docs/pl/intlayer_with_storybook.md +521 -0
  80. package/docs/pt/configuration.md +375 -746
  81. package/docs/pt/intlayer_with_storybook.md +521 -0
  82. package/docs/ru/configuration.md +532 -701
  83. package/docs/ru/intlayer_with_storybook.md +521 -0
  84. package/docs/tr/configuration.md +527 -719
  85. package/docs/tr/intlayer_with_storybook.md +521 -0
  86. package/docs/uk/configuration.md +425 -744
  87. package/docs/uk/intlayer_with_storybook.md +521 -0
  88. package/docs/ur/configuration.md +922 -0
  89. package/docs/ur/intlayer_with_hono.md +428 -0
  90. package/docs/vi/configuration.md +412 -753
  91. package/docs/vi/intlayer_with_storybook.md +521 -0
  92. package/docs/zh/configuration.md +521 -714
  93. package/docs/zh/intlayer_with_storybook.md +521 -0
  94. package/package.json +6 -6
  95. package/src/generated/docs.entry.ts +20 -0
  96. package/dist/cjs/common-a-l0ULP6.cjs +0 -2
  97. package/dist/cjs/common-a-l0ULP6.cjs.map +0 -1
  98. package/dist/types/blog.entry-D5IgxPXY.d.ts +0 -35
  99. package/dist/types/blog.entry-D5IgxPXY.d.ts.map +0 -1
  100. package/dist/types/common-B45TZvLQ.d.ts +0 -37
  101. package/dist/types/common-B45TZvLQ.d.ts.map +0 -1
  102. package/dist/types/docs.entry-CergjAYt.d.ts +0 -157
  103. package/dist/types/docs.entry-CergjAYt.d.ts.map +0 -1
  104. package/dist/types/frequentQuestions.entry-BHglVS-U.d.ts +0 -24
  105. package/dist/types/frequentQuestions.entry-BHglVS-U.d.ts.map +0 -1
  106. package/dist/types/legal.entry-B5Lg5eeH.d.ts +0 -10
  107. 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-12
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: Move 'baseDir' from 'content' to 'system' config
22
+ changes: Moved 'baseDir' from 'content' configuration to 'system' configuration
20
23
  - version: 8.2.0
21
24
  date: 2026-03-09
22
- changes: Update compiler options, add 'output' and 'noMetadata' support
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: Update compiler options
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: Add support for Open Router, Alibaba, Amazon, Google Vertex Bedrock, Fireworks, Groq, Hugging Face, and Together.ai providers
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: Add `dataSerialization` to the AI configuration
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: Move `importMode` build configuration to `dictionary` configuration.
46
+ changes: Added `rewrite` option to routing configuration
35
47
  - version: 8.0.0
36
48
  date: 2026-01-18
37
- changes: Separate system configuration from content configuration. Move internal paths to `system` property. Add `codeDir` to separate content files from code transformation.
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: Add `location` and `schema` dictionary options
52
+ changes: Added dictionary options `location` and `schema`
41
53
  - version: 7.5.1
42
54
  date: 2026-01-10
43
- changes: Add support for JSON5 and JSONC file formats
55
+ changes: Added support for JSON5 and JSONC file formats
44
56
  - version: 7.5.0
45
57
  date: 2025-12-17
46
- changes: Add `buildMode` option
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: Add `live` import mode
79
+ changes: Added `live` import mode
50
80
  - version: 6.0.0
51
81
  date: 2025-09-04
52
- changes: Replace `hotReload` field with `liveSync` and add `liveSyncPort` and `liveSyncURL` fields
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: Replace `activateDynamicImport` with `importMode` option
85
+ changes: Replaced `activateDynamicImport` with `importMode` option
56
86
  - version: 5.6.0
57
87
  date: 2025-07-13
58
- changes: Change default contentDir from `['src']` to `['.']`
88
+ changes: Changed default contentDir from `['src']` to `['.']`
59
89
  - version: 5.5.11
60
90
  date: 2025-06-29
61
- changes: Add `docs` commands
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 customisation of various aspects of the plugin, such as internationalisation, middleware, and content handling. This document provides a detailed description of each property in the configuration.
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 Support
108
+ ## Supported Configuration File Formats
79
109
 
80
- Intlayer accepts JSON, JS, MJS, and TS configuration file formats:
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
- ## Example config file
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 showing all available options.
131
+ * Example Intlayer configuration file displaying all available options.
102
132
  */
103
133
  const config: IntlayerConfig = {
104
134
  /**
105
- * Configuration for internationalization settings.
135
+ * Configuration for internationalisation settings.
106
136
  */
107
137
  internationalization: {
108
138
  /**
109
- * List of supported locales in the application.
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 required locales that must be defined in every dictionary.
116
- * If empty, all locales are required in `strict` mode.
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
- * Strictness level for internationalized content.
123
- * - "strict": Errors if any declared locale is missing or undeclared.
124
- * - "inclusive": Warnings if a declared locale is missing.
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 that control dictionary operations and fallback behavior.
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": Fetched dynamically via the live sync API.
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 for auto-filling missing translations using AI.
152
- * Can be a boolean or a path pattern to store filled content.
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 the dictionary files.
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 in the local filesystem and the Intlayer CMS.
162
- * - "plugin" (or any custom string): Provided by a plugin or a custom source.
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 to automatically transform content (e.g., Markdown to HTML).
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": Prefix all except the default locale (e.g., /dashboard, /fr/dashboard).
181
- * - "prefix-all": Prefix all locales (e.g., /en/dashboard, /fr/dashboard).
182
- * - "no-prefix": No locale in the URL.
183
- * - "search-params": Use ?locale=...
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's selected locale.
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 the application URLs.
226
+ * Base path for application URLs.
197
227
  * Default: ""
198
228
  */
199
229
  basePath: "",
200
230
 
201
231
  /**
202
- * Custom URL rewriting rules for locale-specific paths.
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 for finding and processing content files.
243
+ * Settings pertaining to finding and processing content files.
214
244
  */
215
245
  content: {
216
246
  /**
217
- * File extensions to scan for dictionaries.
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
- * Directories where source code is located.
230
- * Used for build optimization and code transformation.
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 to exclude from scanning.
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 watch for changes and rebuild dictionaries in development.
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 synchronization.
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-powered translation and generation settings.
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 to use from the selected provider.
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 the AI in generating translations.
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 the AI API.
357
+ * Base URL for AI API.
328
358
  */
329
359
  baseURL: "http://localhost:3000",
330
360
 
331
361
  /**
332
- * Data serialisation
362
+ * Data Serialization
333
363
  *
334
364
  * Options:
335
- * - "json": Standard, reliable; uses more tokens.
336
- * - "toon": Fewer tokens, less consistent than JSON.
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 optimization settings.
374
+ * Build and optimisation settings.
345
375
  */
346
376
  build: {
347
377
  /**
348
378
  * Build execution mode.
349
- * - "auto": Automatic build during app build.
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 optimize the final bundle by pruning unused dictionaries.
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: ['esm', 'cjs']
393
+ * Default: ['cjs', 'esm']
364
394
  */
365
- outputFormat: ["esm"],
395
+ outputFormat: ["cjs", "esm"],
366
396
 
367
397
  /**
368
- * Indicates if the build should check TypeScript types.
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": Detailed debug logging.
382
- * - "disabled": No logging.
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 configuration (Advanced use cases)
425
+ * System Configuration (For advanced use)
396
426
  */
397
427
  system: {
398
428
  /**
399
- * Directory for storing localization dictionaries.
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 configuration (Advanced use cases)
465
+ * Compiler Configuration (For advanced use)
436
466
  */
437
467
  compiler: {
438
468
  /**
439
- * Indicates if the compiler should be enabled.
469
+ * Indicates whether the compiler should be enabled.
440
470
  *
441
- * - false : Disables the compiler.
442
- * - true : Enables the compiler.
443
- * - "build-only" : Skips the compiler during development to speed up start times.
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 the output files path. Replaces `outputDir`.
480
+ * Defines path for output files. Replaces `outputDir`.
451
481
  *
452
- * - Paths starting with `./` are resolved relatively to the component directory.
453
- * - Paths starting with `/` are resolved relatively to the project root (`baseDir`).
482
+ * - `./` paths are resolved relative to the component directory.
483
+ * - `/` paths are resolved relative to the project root (`baseDir`).
454
484
  *
455
- * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
485
+ * - Including `{{locale}}` variable in path will trigger the creation of separate dictionaries per-language.
456
486
  *
457
- * Examples:
487
+ * Example:
458
488
  * ```ts
459
489
  * {
460
- * // Create multi-locale .content.ts files next to the component
490
+ * // Create multilingual .content.ts files next to component
461
491
  * output: ({ fileName, extension }) => `./${fileName}${extension}`,
462
492
  *
463
- * // output: './{{fileName}}{{extension}}', // Equivalent using a string template
493
+ * // output: './{{fileName}}{{extension}}', // Equivalent using template string
464
494
  * }
465
495
  * ```
466
496
  *
467
497
  * ```ts
468
498
  * {
469
- * // Create centralised JSON files by locale in the project root
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 a string template
502
+ * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
473
503
  * }
474
504
  * ```
475
505
  *
476
- * List of variables:
477
- * - `fileName`: The file name.
478
- * - `key`: The content key.
479
- * - `locale`: The content locale.
480
- * - `extension`: The file extension.
481
- * - `componentFileName`: The component file name.
482
- * - `componentExtension`: The component file extension.
483
- * - `format`: The dictionary format.
484
- * - `componentFormat`: The component dictionary format.
485
- * - `componentDirPath`: The component directory path.
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 if the components should be saved after being transformed.
491
- * That way, the compiler can be run only once to transform the app, and then it can be removed.
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
- * Insert only content into the generated file. Useful for per-locale i18next or ICU MessageFormat JSON outputs.
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 for the extracted dictionary keys
533
+ dictionaryKeyPrefix: "", // Add an optional prefix to the extracted dictionary keys
504
534
  },
505
535
 
506
536
  /**
507
- * Custom schemas to validate the dictionaries content.
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 for Intlayer.
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
- #### Properties
535
-
536
- - **locales**:
537
- - _Type_: `string[]`
538
- - _Default_: `['en']`
539
- - _Description_: The list of supported locales in the application.
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 active status.
569
-
570
- #### Properties
571
-
572
- - **applicationURL**:
573
- - _Type_: `string`
574
- - _Default_: `http://localhost:3000`
575
- - _Description_: The URL of the application. Used to restrict the origin of the editor for security reasons.
576
- - _Example_:
577
- - `'http://localhost:3000'`
578
- - `'https://example.com'`
579
- - `process.env.INTLAYER_EDITOR_URL`
580
- - _Note_: The URL of the application. Used to restrict the origin of the editor for security reasons. If set to `'*'`, the editor is accessible from any origin.
581
-
582
- - **port**:
583
- - _Type_: `number`
584
- - _Default_: `8000`
585
- - _Description_: The port used by the visual editor server.
586
-
587
- - **editorURL**:
588
- - _Type_: `string`
589
- - _Default_: `'http://localhost:8000'`
590
- - _Description_: The URL of the editor server. Used to restrict the origin of the editor for security reasons.
591
- - `'http://localhost:3000'`
592
- - `'https://example.com'`
593
- - `process.env.INTLAYER_EDITOR_URL`
594
- - _Note_: The URL of the editor server to reach from the application. Used to restrict the origins that can interact with the application for security reasons. If set to `'*'`, the editor is accessible from any origin. Should be set if the port is changed, or if the editor is hosted on a different domain.
595
-
596
- - **cmsURL**:
597
- - _Type_: `string`
598
- - _Default_: `'https://intlayer.org'`
599
- - _Description_: The URL of the Intlayer CMS.
600
- - _Example_: `'https://intlayer.org'`
601
- - _Note_: The URL of the Intlayer CMS.
602
-
603
- - **backendURL**:
604
- - _Type_: `string`
605
- - _Default_: `https://back.intlayer.org`
606
- - _Description_: The URL of the backend server.
607
- - _Example_: `http://localhost:4000`
608
-
609
- - **enabled**:
610
- - _Type_: `boolean`
611
- - _Default_: `true`
612
- - _Description_: Indicates if the application interacts with the visual editor.
613
- - _Example_: `process.env.NODE_ENV !== 'production'`
614
- - _Note_: If true, the editor will be able to interact with the application. If false, the editor will not be able to interact with the application. In any case, the editor can only be enabled by the visual editor. Disabling the editor for specific environments is a way to enforce security.
615
-
616
- - **clientId**:
617
- - _Type_: `string` | `undefined`
618
- - _Default_: `undefined`
619
- - _Description_: clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication. An access token is used to authenticate the user related to the project. To obtain an access token, visit https://app.intlayer.org/project and create an account.
620
- - _Example_: `true`
621
- - _Note_: Important: The clientId and clientSecret should be kept confidential and not shared publicly. Please ensure they are stored securely, such as in environment variables.
622
-
623
- - **clientSecret**:
624
- - _Type_: `string` | `undefined`
625
- - _Default_: `undefined`
626
- - _Description_: clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication. An access token is used to authenticate the user related to the project. To obtain an access token, visit https://app.intlayer.org/project and create an account.
627
- - _Example_: `true`
628
- - _Note_: Important: The clientId and clientSecret should be kept confidential and not shared publicly. Please ensure they are stored securely, such as in environment variables.
629
-
630
- - **dictionaryPriorityStrategy**:
631
- - _Type_: `string`
632
- - _Default_: `'local_first'`
633
- - _Description_: The strategy to prioritise dictionaries in the case of both local and distant dictionaries being present. If set to `'distant_first'`, the application will prioritise distant dictionaries over local dictionaries. If set to `'local_first'`, the application will prioritise local dictionaries over distant dictionaries.
634
- - _Example_: `'distant_first'`
635
-
636
- - **liveSync**:
637
- - _Type_: `boolean`
638
- - _Default_: `false`
639
- - _Description_: Indicates if the application server should hot reload the content of the application when a change is detected on the CMS / Visual Editor / Backend.
640
- - _Example_: `true`
641
- - _Note_: For example, when a new dictionary is added or updated, the application will update the content to display on the page.
642
- - _Note_: Live sync needs to externalise the content of the application to another server. This means that it can slightly impact the performance of the application. To limit this, we recommend hosting the application and the live sync server on the same machine. Also, the combination of live sync and `optimize` can generate a considerable number of requests to the live sync server. Depending on your infrastructure, we recommend testing both options and their combination.
643
-
644
- - **liveSyncPort**:
645
- - _Type_: `number`
646
- - _Default_: `4000`
647
- - _Description_: The port of the live sync server.
648
- - _Example_: `4000`
649
- - _Note_: The port of the live sync server.
650
-
651
- - **liveSyncURL**:
652
- - _Type_: `string`
653
- - _Default_: `'http://localhost:{liveSyncPort}'`
654
- - _Description_: The URL of the live sync server.
655
- - _Example_: `'https://example.com'`
656
- - _Note_: Points to localhost by default but can be changed to any URL in the case of a remote live sync server.
657
-
658
- ### Middleware Configuration
659
-
660
- Settings that control middleware behaviour, including how the application handles cookies, headers, and URL prefixes for locale management.
661
-
662
- #### Properties
663
-
664
- - **headerName**:
665
- - _Type_: `string`
666
- - _Default_: `'x-intlayer-locale'`
667
- - _Description_: The name of the HTTP header used to determine the locale.
668
- - _Example_: `'x-custom-locale'`
669
- - _Note_: This is useful for API-based locale determination.
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 &#124; 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 &#124; 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' &#124; 'prefix-all' &#124; 'no-prefix' &#124; '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 &#124; 'cookie' &#124; 'localStorage' &#124; 'sessionStorage' &#124; 'header' &#124; CookiesAttributes &#124; StorageAttributes &#124; 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' &#124; 'lax' &#124; 'none'` | SameSite policy. |
648
+ | `expires` | `Date &#124; 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' &#124; '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
- ### Content Configuration
683
+ **GDPR Compliant Configuration**:
751
684
 
752
- Settings related to content handling within the application, including directory names, file extensions, and derived configurations.
753
-
754
- #### Properties
755
-
756
- - **autoFill**:
757
- - _Type_: `boolean | string | FilePathPattern | { [key in Locales]?: string }`
758
- - _Default_: `undefined`
759
- - _Description_: Indicates how the content should be automatically filled using AI. Can be declared globally in the `intlayer.config.ts` file.
760
- - _Example_: true
761
- - _Example_: `'./{{fileName}}.content.json'`
762
- - _Example_: `{ fr: './{{fileName}}.fr.content.json', es: './{{fileName}}.es.content.json' }`
763
- - _Note_: The auto fill configuration. It can be:
764
- - boolean: Enable auto fill for all locales
765
- - string: Path to a single file or template with variables
766
- - object: Per-locale file paths
767
-
768
- - **watch**:
769
- - _Type_: `boolean`
770
- - _Default_: `process.env.NODE_ENV === 'development'`
771
- - _Description_: Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.
772
-
773
- - **fileExtensions**:
774
- - _Type_: `string[]`
775
- - _Default_: `['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']`
776
- - _Description_: File extensions to look for when building dictionaries.
777
- - _Example_: `['.data.ts', '.data.js', '.data.json']`
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
- ### System Configuration
715
+ **Search Parameters Mode**:
813
716
 
814
- Settings related to internal paths and output results of Intlayer. These settings are typically internal and should not need to be modified by the user.
815
-
816
- #### Properties
817
-
818
- - **baseDir**:
819
- - _Type_: `string`
820
- - _Default_: `process.cwd()`
821
- - _Description_: The base directory for the project.
822
- - _Example_: `'/path/to/project'`
823
- - _Note_: This is used to resolve all Intlayer-related directories.
824
-
825
- - **dictionariesDir**:
826
- - _Type_: `string`
827
- - _Default_: `'.intlayer/dictionary'`
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
- ### Dictionary Configuration
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
- Settings that control dictionary operations, including auto-fill behaviour and content generation.
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
- This dictionary configuration serves two main purposes:
789
+ export default config;
790
+ ```
867
791
 
868
- 1. **Default Values**: Define default values when creating content declaration files
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
- For more information about content declaration files and how configuration values are applied, see the [Content File Documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/content_file.md).
794
+ ### Content Configuration
872
795
 
873
- #### Properties
796
+ Settings pertaining to the processing of content within the application (directory names, file extensions, and derived configurations).
874
797
 
875
- - **fill**
876
- - **description**
877
- - **locale**
878
- - **location**
879
- - **importMode**:
880
- - _Note_: **Deprecated**: Use `dictionary.importMode` instead.
881
- - _Type_: `'static' | 'dynamic' | 'fetch'`
882
- - _Default_: `'static'`
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
- ### Logger Configuration
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
- Settings that control the logger, including the prefix to use.
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
- #### Properties
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
- - **mode**:
901
- - _Type_: `string`
902
- - _Default_: `default`
903
- - _Description_: Indicates the mode of the logger.
904
- - _Options_: `default`, `verbose`, `disabled`
905
- - _Example_: `default`
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 &#124; FilePathPattern &#124; Partial<Record<Locale, boolean &#124; 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' &#124; 'dynamic' &#124; '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' &#124; 'remote' &#124; 'hybrid' &#124; 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
- - **prefix**:
909
- - _Type_: `string`
910
- - _Default_: `'[intlayer] '`
911
- - _Description_: The prefix of the logger.
912
- - _Example_: `'[my custom prefix] '`
913
- - _Note_: The prefix of the logger.
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
- Settings that control the AI features of Intlayer, including the provider, model, and API key.
918
-
919
- This configuration is optional if you are registered on the [Intlayer Dashboard](https://app.intlayer.org/project) using an access key. Intlayer will automatically manage the most efficient and cost-effective AI solution for your needs. Using the default options ensures better long-term maintainability as Intlayer continuously updates to use the most relevant models.
920
-
921
- If you prefer to use your own API key or specific model, you can define your custom AI configuration.
922
- This AI configuration will be used globally across your Intlayer environment. CLI commands will use these settings as defaults for the commands (e.g. `fill`), as well as the SDK, Visual Editor, and CMS. You can override these default values for specific use cases using command parameters.
923
-
924
- Intlayer supports multiple AI providers for enhanced flexibility and choice. Currently supported providers are:
925
-
926
- - **OpenAI** (default)
927
- - **Anthropic Claude**
928
- - **Mistral AI**
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' &#124; '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 that control how Intlayer optimises and builds your application's internationalisation.
997
-
998
- Build options apply to the `@intlayer/babel` and `@intlayer/swc` plugins.
999
-
1000
- > In development mode, Intlayer uses static imports for dictionaries to simplify the development experience.
1001
-
1002
- > When optimised, Intlayer will replace dictionary calls to optimise chunking, so the final bundle only imports dictionaries that are actually used.
1003
-
1004
- #### Properties
1005
-
1006
- - **mode**:
1007
- - _Type_: `'auto' | 'manual'`
1008
- - _Default_: `'auto'`
1009
- - _Description_: Controls the mode of the build.
1010
- - _Example_: `'manual'`
1011
- - _Note_: If 'auto', the build will be enabled automatically when the application is built.
1012
- - _Note_: If 'manual', the build will be set only when the build command is executed.
1013
- - _Note_: Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.
1014
-
1015
- - **checkTypes**:
1016
- - _Type_: `boolean`
1017
- - _Default_: `false`
1018
- - _Description_: Indicates if the build should check TypeScript types and log errors.
1019
- - _Note_: This can slow down the build.
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' &#124; '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' &#124; '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 that control the Intlayer compiler, which extracts dictionaries straight from your components.
1052
-
1053
- #### Properties
1054
-
1055
- - **enabled**:
1056
- - _Type_: `boolean | 'build-only'`
1057
- - _Default_: `true`
1058
- - _Description_: Indicates if the compiler should be enabled to extract the dictionaries.
1059
- - _Example_: `'build-only'`
1060
- - _Note_: Setting it to `'build-only'` will skip the compiler during development mode to speed up build times. It will only run on build commands.
1061
-
1062
- - **dictionaryKeyPrefix**:
1063
- - _Type_: `string`
1064
- - _Default_: `''`
1065
- - _Description_: Prefix for the extracted dictionary keys.
1066
- - _Example_: `'my-key-'`
1067
- - _Note_: When dictionaries are extracted, the key is generated based on the file name. This prefix is added to the generated key to prevent conflicts.
1068
-
1069
- - **saveComponents**:
1070
- - _Type_: `boolean`
1071
- - _Default_: `false`
1072
- - _Description_: Indicates if the components should be saved after being transformed.
1073
- - _Note_: If true, the compiler will replace the original files with the transformed files. That way, the compiler can be run only once to transform the app, and then it can be removed.
1074
-
1075
- - **transformPattern**:
1076
- - _Type_: `string | string[]`
1077
- - _Default_: `['**/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**/node_modules/**']`
1078
- - _Description_: Patterns that define which files should be traversed during optimisation.
1079
- - _Example_: `['src/**/*.{ts,tsx}', '!**/node_modules/**']`
1080
- - _Note_: Use this to limit optimisation to relevant code files and improve build performance.
1081
-
1082
- - **excludePattern**:
1083
- - _Type_: `string | string[]`
1084
- - _Default_: `['**/node_modules/**']`
1085
- - _Description_: Patterns that define which files should be excluded during optimisation.
1086
- - _Example_: `['**/node_modules/**', '!**/node_modules/react/**']`
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 &#124; 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' &#124; 'verbose' &#124; '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. |