@intlayer/docs 8.4.5 → 8.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  2. package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  3. package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  4. package/blog/id/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  5. package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  6. package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  7. package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  8. package/blog/uk/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  9. package/blog/vi/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  10. package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +1 -3
  11. package/dist/cjs/generated/docs.entry.cjs +20 -0
  12. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  13. package/dist/esm/generated/docs.entry.mjs +20 -0
  14. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  15. package/dist/types/generated/docs.entry.d.ts +1 -0
  16. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  17. package/docs/ar/intlayer_with_storybook.md +521 -0
  18. package/docs/bn/intlayer_with_hono.md +428 -0
  19. package/docs/de/intlayer_with_storybook.md +521 -0
  20. package/docs/en/configuration.md +160 -508
  21. package/docs/en/intlayer_with_storybook.md +521 -0
  22. package/docs/en-GB/intlayer_with_storybook.md +521 -0
  23. package/docs/es/configuration.md +387 -754
  24. package/docs/es/intlayer_with_storybook.md +521 -0
  25. package/docs/fr/configuration.md +384 -757
  26. package/docs/fr/intlayer_with_storybook.md +521 -0
  27. package/docs/hi/intlayer_with_storybook.md +521 -0
  28. package/docs/id/intlayer_with_storybook.md +521 -0
  29. package/docs/it/intlayer_with_storybook.md +521 -0
  30. package/docs/ja/intlayer_with_storybook.md +521 -0
  31. package/docs/ko/intlayer_with_storybook.md +521 -0
  32. package/docs/pl/intlayer_with_storybook.md +521 -0
  33. package/docs/pt/intlayer_with_storybook.md +521 -0
  34. package/docs/ru/intlayer_with_storybook.md +521 -0
  35. package/docs/tr/intlayer_with_storybook.md +521 -0
  36. package/docs/uk/intlayer_with_storybook.md +521 -0
  37. package/docs/ur/intlayer_with_hono.md +428 -0
  38. package/docs/vi/intlayer_with_storybook.md +521 -0
  39. package/docs/zh/intlayer_with_storybook.md +521 -0
  40. package/package.json +6 -6
  41. package/src/generated/docs.entry.ts +20 -0
  42. package/docs/ar/configuration.md +0 -1124
  43. package/docs/de/configuration.md +0 -1296
  44. package/docs/en-GB/configuration.md +0 -1123
  45. package/docs/hi/configuration.md +0 -1118
  46. package/docs/id/configuration.md +0 -1235
  47. package/docs/it/configuration.md +0 -1301
  48. package/docs/ja/configuration.md +0 -1121
  49. package/docs/ko/configuration.md +0 -1121
  50. package/docs/pl/configuration.md +0 -1226
  51. package/docs/pt/configuration.md +0 -1293
  52. package/docs/ru/configuration.md +0 -1112
  53. package/docs/tr/configuration.md +0 -1114
  54. package/docs/uk/configuration.md +0 -1241
  55. package/docs/vi/configuration.md +0 -1263
  56. package/docs/zh/configuration.md +0 -1115
@@ -1,1123 +0,0 @@
1
- ---
2
- createdAt: 2024-08-13
3
- updatedAt: 2026-03-12
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.
6
- keywords:
7
- - Configuration
8
- - Settings
9
- - Customisation
10
- - Intlayer
11
- - Options
12
- slugs:
13
- - doc
14
- - concept
15
- - configuration
16
- history:
17
- - version: 8.3.0
18
- date: 2026-03-11
19
- changes: Move 'baseDir' from 'content' to 'system' config
20
- - version: 8.2.0
21
- date: 2026-03-09
22
- changes: Update compiler options, add 'output' and 'noMetadata' support
23
- - version: 8.1.7
24
- date: 2026-02-25
25
- changes: Update compiler options
26
- - version: 8.0.6
27
- date: 2026-02-12
28
- changes: Add support for Open Router, Alibaba, Amazon, Google Vertex Bedrock, Fireworks, Groq, Hugging Face, and Together.ai providers
29
- - version: 8.0.5
30
- date: 2026-02-06
31
- changes: Add `dataSerialization` to the AI configuration
32
- - version: 8.0.0
33
- date: 2026-01-22
34
- changes: Move `importMode` build configuration to `dictionary` configuration.
35
- - version: 8.0.0
36
- 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.
38
- - version: 8.0.0
39
- date: 2026-01-18
40
- changes: Add `location` and `schema` dictionary options
41
- - version: 7.5.1
42
- date: 2026-01-10
43
- changes: Add support for JSON5 and JSONC file formats
44
- - version: 7.5.0
45
- date: 2025-12-17
46
- changes: Add `buildMode` option
47
- - version: 6.0.0
48
- date: 2025-09-16
49
- changes: Add `live` import mode
50
- - version: 6.0.0
51
- date: 2025-09-04
52
- changes: Replace `hotReload` field with `liveSync` and add `liveSyncPort` and `liveSyncURL` fields
53
- - version: 5.6.1
54
- date: 2025-07-25
55
- changes: Replace `activateDynamicImport` with `importMode` option
56
- - version: 5.6.0
57
- date: 2025-07-13
58
- changes: Change default contentDir from `['src']` to `['.']`
59
- - version: 5.5.11
60
- date: 2025-06-29
61
- changes: Add `docs` commands
62
- ---
63
-
64
- # Intlayer Configuration Documentation
65
-
66
- ## Overview
67
-
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.
69
-
70
- ---
71
-
72
- ## Table of Contents
73
-
74
- <TOC/>
75
-
76
- ---
77
-
78
- ## Configuration File Support
79
-
80
- Intlayer accepts JSON, JS, MJS, and TS configuration file formats:
81
-
82
- - `intlayer.config.ts`
83
- - `intlayer.config.js`
84
- - `intlayer.config.json`
85
- - `intlayer.config.json5`
86
- - `intlayer.config.jsonc`
87
- - `intlayer.config.cjs`
88
- - `intlayer.config.mjs`
89
- - `.intlayerrc`
90
-
91
- ---
92
-
93
- ## Example config file
94
-
95
- ````typescript fileName="intlayer.config.ts" codeFormat="typescript"
96
- import { Locales, type IntlayerConfig } from "intlayer";
97
- import { nextjsRewrite } from "intlayer/routing";
98
- import { z } from "zod";
99
-
100
- /**
101
- * Example Intlayer configuration file showing all available options.
102
- */
103
- const config: IntlayerConfig = {
104
- /**
105
- * Configuration for internationalization settings.
106
- */
107
- internationalization: {
108
- /**
109
- * List of supported locales in the application.
110
- * Default: [Locales.ENGLISH]
111
- */
112
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
113
-
114
- /**
115
- * List of required locales that must be defined in every dictionary.
116
- * If empty, all locales are required in `strict` mode.
117
- * Default: []
118
- */
119
- requiredLocales: [Locales.ENGLISH],
120
-
121
- /**
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.
125
- * - "loose": Accepts any existing locale.
126
- * Default: "inclusive"
127
- */
128
- strictMode: "inclusive",
129
-
130
- /**
131
- * Default locale used as a fallback if the requested locale is not found.
132
- * Default: Locales.ENGLISH
133
- */
134
- defaultLocale: Locales.ENGLISH,
135
- },
136
-
137
- /**
138
- * Settings that control dictionary operations and fallback behavior.
139
- */
140
- dictionary: {
141
- /**
142
- * Controls how dictionaries are imported.
143
- * - "static": Statically imported at build time.
144
- * - "dynamic": Dynamically imported using Suspense.
145
- * - "fetch": Fetched dynamically via the live sync API.
146
- * Default: "static"
147
- */
148
- importMode: "static",
149
-
150
- /**
151
- * Strategy for auto-filling missing translations using AI.
152
- * Can be a boolean or a path pattern to store filled content.
153
- * Default: true
154
- */
155
- fill: true,
156
-
157
- /**
158
- * Physical location of the dictionary files.
159
- * - "local": Stored in the local filesystem.
160
- * - "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.
163
- * Default: "local"
164
- */
165
- location: "local",
166
-
167
- /**
168
- * Whether to automatically transform content (e.g., Markdown to HTML).
169
- * Default: false
170
- */
171
- contentAutoTransformation: false,
172
- },
173
-
174
- /**
175
- * Routing and middleware configuration.
176
- */
177
- routing: {
178
- /**
179
- * 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=...
184
- * Default: "prefix-no-default"
185
- */
186
- mode: "prefix-no-default",
187
-
188
- /**
189
- * Where to store the user's selected locale.
190
- * Options: 'cookie', 'localStorage', 'sessionStorage', 'header', or an array of these.
191
- * Default: ['cookie', 'header']
192
- */
193
- storage: ["cookie", "header"],
194
-
195
- /**
196
- * Base path for the application URLs.
197
- * Default: ""
198
- */
199
- basePath: "",
200
-
201
- /**
202
- * Custom URL rewriting rules for locale-specific paths.
203
- */
204
- rewrite: nextjsRewrite({
205
- "/[locale]/about": {
206
- en: "/[locale]/about",
207
- fr: "/[locale]/a-propos",
208
- },
209
- }),
210
- },
211
-
212
- /**
213
- * Settings for finding and processing content files.
214
- */
215
- content: {
216
- /**
217
- * File extensions to scan for dictionaries.
218
- * Default: ['.content.ts', '.content.js', '.content.json', etc.]
219
- */
220
- fileExtensions: [".content.ts", ".content.js", ".content.json"],
221
-
222
- /**
223
- * Directories where .content files are located.
224
- * Default: ["."]
225
- */
226
- contentDir: ["src"],
227
-
228
- /**
229
- * Directories where source code is located.
230
- * Used for build optimization and code transformation.
231
- * Default: ["."]
232
- */
233
- codeDir: ["src"],
234
-
235
- /**
236
- * Patterns to exclude from scanning.
237
- * Default: ['node_modules', '.intlayer', etc.]
238
- */
239
- excludedPath: ["node_modules"],
240
-
241
- /**
242
- * Whether to watch for changes and rebuild dictionaries in development.
243
- * Default: true in development
244
- */
245
- watch: true,
246
-
247
- /**
248
- * Command to format newly created / updated .content files.
249
- */
250
- formatCommand: 'npx prettier --write "{{file}}"',
251
- },
252
-
253
- /**
254
- * Visual Editor configuration.
255
- */
256
- editor: {
257
- /**
258
- * Whether the visual editor is enabled.
259
- * Default: false
260
- */
261
- enabled: true,
262
-
263
- /**
264
- * URL of your application for origin validation.
265
- * Default: ""
266
- */
267
- applicationURL: "http://localhost:3000",
268
-
269
- /**
270
- * Port for the local editor server.
271
- * Default: 8000
272
- */
273
- port: 8000,
274
-
275
- /**
276
- * Public URL for the editor.
277
- * Default: "http://localhost:8000"
278
- */
279
- editorURL: "http://localhost:8000",
280
-
281
- /**
282
- * Intlayer CMS URL.
283
- * Default: "https://app.intlayer.org"
284
- */
285
- cmsURL: "https://app.intlayer.org",
286
-
287
- /**
288
- * Backend API URL.
289
- * Default: "https://back.intlayer.org"
290
- */
291
- backendURL: "https://back.intlayer.org",
292
-
293
- /**
294
- * Whether to enable real-time content synchronization.
295
- * Default: false
296
- */
297
- liveSync: true,
298
- },
299
-
300
- /**
301
- * AI-powered translation and generation settings.
302
- */
303
- ai: {
304
- /**
305
- * AI provider to use.
306
- * Options: 'openai', 'anthropic', 'mistral', 'deepseek', 'gemini', 'ollama', 'openrouter', 'alibaba', 'fireworks', 'groq', 'huggingface', 'bedrock', 'googlevertex', 'togetherai'
307
- * Default: 'openai'
308
- */
309
- provider: "openai",
310
-
311
- /**
312
- * Model to use from the selected provider.
313
- */
314
- model: "gpt-4o",
315
-
316
- /**
317
- * Provider API key.
318
- */
319
- apiKey: process.env.OPENAI_API_KEY,
320
-
321
- /**
322
- * Global context to guide the AI in generating translations.
323
- */
324
- applicationContext: "This is a travel booking application.",
325
-
326
- /**
327
- * Base URL for the AI API.
328
- */
329
- baseURL: "http://localhost:3000",
330
-
331
- /**
332
- * Data serialisation
333
- *
334
- * Options:
335
- * - "json": Standard, reliable; uses more tokens.
336
- * - "toon": Fewer tokens, less consistent than JSON.
337
- *
338
- * Default: "json"
339
- */
340
- dataSerialization: "json",
341
- },
342
-
343
- /**
344
- * Build and optimization settings.
345
- */
346
- build: {
347
- /**
348
- * Build execution mode.
349
- * - "auto": Automatic build during app build.
350
- * - "manual": Requires explicit build command.
351
- * Default: "auto"
352
- */
353
- mode: "auto",
354
-
355
- /**
356
- * Whether to optimize the final bundle by pruning unused dictionaries.
357
- * Default: true in production
358
- */
359
- optimize: true,
360
-
361
- /**
362
- * Output format for generated dictionary files.
363
- * Default: ['esm', 'cjs']
364
- */
365
- outputFormat: ["esm"],
366
-
367
- /**
368
- * Indicates if the build should check TypeScript types.
369
- * Default: false
370
- */
371
- checkTypes: false,
372
- },
373
-
374
- /**
375
- * Logger configuration.
376
- */
377
- log: {
378
- /**
379
- * Logging level.
380
- * - "default": Standard logging.
381
- * - "verbose": Detailed debug logging.
382
- * - "disabled": No logging.
383
- * Default: "default"
384
- */
385
- mode: "default",
386
-
387
- /**
388
- * Prefix for all log messages.
389
- * Default: "[intlayer]"
390
- */
391
- prefix: "[intlayer]",
392
- },
393
-
394
- /**
395
- * System configuration (Advanced use cases)
396
- */
397
- system: {
398
- /**
399
- * Directory for storing localization dictionaries.
400
- */
401
- dictionariesDir: ".intlayer/dictionary",
402
-
403
- /**
404
- * Directory for module augmentation.
405
- */
406
- moduleAugmentationDir: ".intlayer/types",
407
-
408
- /**
409
- * Directory for storing unmerged dictionaries.
410
- */
411
- unmergedDictionariesDir: ".intlayer/unmerged_dictionary",
412
-
413
- /**
414
- * Directory for storing dictionary types.
415
- */
416
- typesDir: ".intlayer/types",
417
-
418
- /**
419
- * Directory where main application files are stored.
420
- */
421
- mainDir: ".intlayer/main",
422
-
423
- /**
424
- * Directory where the configuration files are stored.
425
- */
426
- configDir: ".intlayer/config",
427
-
428
- /**
429
- * Directory where the cache files are stored.
430
- */
431
- cacheDir: ".intlayer/cache",
432
- },
433
-
434
- /**
435
- * Compiler configuration (Advanced use cases)
436
- */
437
- compiler: {
438
- /**
439
- * Indicates if the compiler should be enabled.
440
- *
441
- * - false : Disables the compiler.
442
- * - true : Enables the compiler.
443
- * - "build-only" : Skips the compiler during development to speed up start times.
444
- *
445
- * Default: false
446
- */
447
- enabled: true,
448
-
449
- /**
450
- * Defines the output files path. Replaces `outputDir`.
451
- *
452
- * - Paths starting with `./` are resolved relatively to the component directory.
453
- * - Paths starting with `/` are resolved relatively to the project root (`baseDir`).
454
- *
455
- * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
456
- *
457
- * Examples:
458
- * ```ts
459
- * {
460
- * // Create multi-locale .content.ts files next to the component
461
- * output: ({ fileName, extension }) => `./${fileName}${extension}`,
462
- *
463
- * // output: './{{fileName}}{{extension}}', // Equivalent using a string template
464
- * }
465
- * ```
466
- *
467
- * ```ts
468
- * {
469
- * // Create centralised JSON files by locale in the project root
470
- * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
471
- *
472
- * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using a string template
473
- * }
474
- * ```
475
- *
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.
486
- */
487
- output: ({ locale, key }) => `compiler/${locale}/${key}.json`,
488
-
489
- /**
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.
492
- */
493
- saveComponents: false,
494
-
495
- /**
496
- * Insert only content into the generated file. Useful for per-locale i18next or ICU MessageFormat JSON outputs.
497
- */
498
- noMetadata: false,
499
-
500
- /**
501
- * Dictionary key prefix
502
- */
503
- dictionaryKeyPrefix: "", // Add optional prefix for the extracted dictionary keys
504
- },
505
-
506
- /**
507
- * Custom schemas to validate the dictionaries content.
508
- */
509
- schemas: {
510
- "my-schema": z.object({
511
- title: z.string(),
512
- }),
513
- },
514
-
515
- /**
516
- * Plugins configuration.
517
- */
518
- plugins: [],
519
- };
520
-
521
- export default config;
522
- ````
523
-
524
- ## Configuration Reference
525
-
526
- The following sections describe the various configuration settings available for Intlayer.
527
-
528
- ---
529
-
530
- ### Internationalisation Configuration
531
-
532
- Defines settings related to internationalisation, including available locales and the default locale for the application.
533
-
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.
563
-
564
- ---
565
-
566
- ### Editor Configuration
567
-
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`
747
-
748
- ---
749
-
750
- ### Content Configuration
751
-
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.
809
-
810
- ---
811
-
812
- ### System Configuration
813
-
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.
861
-
862
- ### Dictionary Configuration
863
-
864
- Settings that control dictionary operations, including auto-fill behaviour and content generation.
865
-
866
- This dictionary configuration serves two main purposes:
867
-
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
870
-
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).
872
-
873
- #### Properties
874
-
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**
891
-
892
- ---
893
-
894
- ### Logger Configuration
895
-
896
- Settings that control the logger, including the prefix to use.
897
-
898
- #### Properties
899
-
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.
907
-
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.
914
-
915
- ### AI Configuration
916
-
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.
993
-
994
- ### Build Configuration
995
-
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.
1046
-
1047
- ---
1048
-
1049
- ### Compiler Configuration
1050
-
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
- ```