@intlayer/docs 8.3.0-canary.4 → 8.3.1

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 (240) hide show
  1. package/docs/ar/compiler.md +84 -49
  2. package/docs/ar/configuration.md +80 -37
  3. package/docs/ar/intlayer_with_nextjs_16.md +174 -1
  4. package/docs/ar/intlayer_with_nextjs_compiler.md +174 -1
  5. package/docs/ar/intlayer_with_react_router_v7.md +224 -1
  6. package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +225 -1
  7. package/docs/ar/intlayer_with_svelte_kit.md +175 -2
  8. package/docs/ar/intlayer_with_tanstack.md +176 -1
  9. package/docs/ar/intlayer_with_vite+preact.md +174 -1
  10. package/docs/ar/intlayer_with_vite+react.md +174 -1
  11. package/docs/ar/intlayer_with_vite+solid.md +174 -1
  12. package/docs/ar/intlayer_with_vite+svelte.md +174 -1
  13. package/docs/ar/intlayer_with_vite+vue.md +174 -1
  14. package/docs/de/compiler.md +83 -48
  15. package/docs/de/configuration.md +434 -212
  16. package/docs/de/intlayer_with_nextjs_16.md +176 -1
  17. package/docs/de/intlayer_with_nextjs_compiler.md +106 -349
  18. package/docs/de/intlayer_with_react_router_v7.md +225 -2
  19. package/docs/de/intlayer_with_react_router_v7_fs_routes.md +221 -79
  20. package/docs/de/intlayer_with_svelte_kit.md +158 -2
  21. package/docs/de/intlayer_with_tanstack.md +159 -1
  22. package/docs/de/intlayer_with_vite+preact.md +157 -1
  23. package/docs/de/intlayer_with_vite+react.md +157 -1
  24. package/docs/de/intlayer_with_vite+solid.md +159 -3
  25. package/docs/de/intlayer_with_vite+svelte.md +157 -1
  26. package/docs/de/intlayer_with_vite+vue.md +157 -1
  27. package/docs/en/compiler.md +60 -33
  28. package/docs/en/configuration.md +80 -57
  29. package/docs/en/intlayer_with_nextjs_16.md +176 -0
  30. package/docs/en/intlayer_with_nextjs_compiler.md +179 -1
  31. package/docs/en/intlayer_with_react_router_v7.md +159 -0
  32. package/docs/en/intlayer_with_react_router_v7_fs_routes.md +159 -0
  33. package/docs/en/intlayer_with_svelte_kit.md +159 -0
  34. package/docs/en/intlayer_with_tanstack.md +160 -1
  35. package/docs/en/intlayer_with_vite+preact.md +159 -0
  36. package/docs/en/intlayer_with_vite+react.md +159 -0
  37. package/docs/en/intlayer_with_vite+solid.md +148 -27
  38. package/docs/en/intlayer_with_vite+svelte.md +159 -0
  39. package/docs/en/intlayer_with_vite+vue.md +142 -41
  40. package/docs/en-GB/compiler.md +66 -34
  41. package/docs/en-GB/configuration.md +78 -36
  42. package/docs/es/compiler.md +83 -48
  43. package/docs/es/configuration.md +429 -206
  44. package/docs/es/intlayer_with_adonisjs.md +1 -1
  45. package/docs/es/intlayer_with_express.md +1 -1
  46. package/docs/es/intlayer_with_fastify.md +1 -1
  47. package/docs/es/intlayer_with_hono.md +1 -1
  48. package/docs/es/intlayer_with_nestjs.md +1 -1
  49. package/docs/es/intlayer_with_nextjs_16.md +176 -3
  50. package/docs/es/intlayer_with_nextjs_compiler.md +175 -2
  51. package/docs/es/intlayer_with_nuxt.md +1 -1
  52. package/docs/es/intlayer_with_react_router_v7.md +227 -4
  53. package/docs/es/intlayer_with_react_router_v7_fs_routes.md +162 -4
  54. package/docs/es/intlayer_with_svelte_kit.md +158 -2
  55. package/docs/es/intlayer_with_tanstack.md +160 -2
  56. package/docs/es/intlayer_with_vite+preact.md +162 -6
  57. package/docs/es/intlayer_with_vite+react.md +160 -4
  58. package/docs/es/intlayer_with_vite+solid.md +163 -7
  59. package/docs/es/intlayer_with_vite+svelte.md +157 -1
  60. package/docs/es/intlayer_with_vite+vue.md +165 -9
  61. package/docs/fr/compiler.md +81 -46
  62. package/docs/fr/configuration.md +355 -134
  63. package/docs/fr/intlayer_with_adonisjs.md +1 -1
  64. package/docs/fr/intlayer_with_express.md +1 -1
  65. package/docs/fr/intlayer_with_fastify.md +1 -1
  66. package/docs/fr/intlayer_with_hono.md +1 -1
  67. package/docs/fr/intlayer_with_nestjs.md +1 -1
  68. package/docs/fr/intlayer_with_nextjs_16.md +183 -7
  69. package/docs/fr/intlayer_with_nextjs_compiler.md +179 -3
  70. package/docs/fr/intlayer_with_react_router_v7.md +229 -3
  71. package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +237 -6
  72. package/docs/fr/intlayer_with_svelte_kit.md +158 -2
  73. package/docs/fr/intlayer_with_tanstack.md +159 -1
  74. package/docs/fr/intlayer_with_vite+preact.md +164 -8
  75. package/docs/fr/intlayer_with_vite+react.md +162 -6
  76. package/docs/fr/intlayer_with_vite+solid.md +163 -7
  77. package/docs/fr/intlayer_with_vite+svelte.md +157 -1
  78. package/docs/fr/intlayer_with_vite+vue.md +164 -8
  79. package/docs/hi/compiler.md +81 -46
  80. package/docs/hi/configuration.md +87 -44
  81. package/docs/hi/intlayer_with_nextjs_16.md +174 -1
  82. package/docs/hi/intlayer_with_nextjs_compiler.md +174 -1
  83. package/docs/hi/intlayer_with_react_router_v7.md +224 -1
  84. package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +225 -1
  85. package/docs/hi/intlayer_with_svelte_kit.md +158 -2
  86. package/docs/hi/intlayer_with_tanstack.md +159 -1
  87. package/docs/hi/intlayer_with_vite+preact.md +157 -1
  88. package/docs/hi/intlayer_with_vite+react.md +157 -1
  89. package/docs/hi/intlayer_with_vite+solid.md +157 -1
  90. package/docs/hi/intlayer_with_vite+svelte.md +157 -1
  91. package/docs/hi/intlayer_with_vite+vue.md +157 -1
  92. package/docs/id/compiler.md +84 -51
  93. package/docs/id/configuration.md +83 -45
  94. package/docs/id/intlayer_with_nextjs_16.md +174 -1
  95. package/docs/id/intlayer_with_nextjs_compiler.md +174 -1
  96. package/docs/id/intlayer_with_react_router_v7.md +224 -1
  97. package/docs/id/intlayer_with_react_router_v7_fs_routes.md +225 -1
  98. package/docs/id/intlayer_with_svelte_kit.md +158 -2
  99. package/docs/id/intlayer_with_tanstack.md +159 -1
  100. package/docs/id/intlayer_with_vite+preact.md +157 -1
  101. package/docs/id/intlayer_with_vite+react.md +157 -1
  102. package/docs/id/intlayer_with_vite+solid.md +157 -1
  103. package/docs/id/intlayer_with_vite+svelte.md +157 -1
  104. package/docs/id/intlayer_with_vite+vue.md +157 -1
  105. package/docs/it/compiler.md +81 -46
  106. package/docs/it/configuration.md +426 -204
  107. package/docs/it/intlayer_with_nextjs_16.md +174 -1
  108. package/docs/it/intlayer_with_nextjs_compiler.md +174 -1
  109. package/docs/it/intlayer_with_react_router_v7.md +225 -2
  110. package/docs/it/intlayer_with_react_router_v7_fs_routes.md +226 -2
  111. package/docs/it/intlayer_with_svelte_kit.md +158 -2
  112. package/docs/it/intlayer_with_tanstack.md +159 -1
  113. package/docs/it/intlayer_with_vite+preact.md +157 -1
  114. package/docs/it/intlayer_with_vite+react.md +157 -1
  115. package/docs/it/intlayer_with_vite+solid.md +159 -3
  116. package/docs/it/intlayer_with_vite+svelte.md +157 -1
  117. package/docs/it/intlayer_with_vite+vue.md +157 -1
  118. package/docs/ja/compiler.md +94 -58
  119. package/docs/ja/configuration.md +88 -45
  120. package/docs/ja/intlayer_with_nextjs_16.md +174 -1
  121. package/docs/ja/intlayer_with_nextjs_compiler.md +174 -1
  122. package/docs/ja/intlayer_with_react_router_v7.md +184 -394
  123. package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +226 -2
  124. package/docs/ja/intlayer_with_svelte_kit.md +119 -595
  125. package/docs/ja/intlayer_with_tanstack.md +131 -642
  126. package/docs/ja/intlayer_with_vite+preact.md +111 -1231
  127. package/docs/ja/intlayer_with_vite+react.md +129 -1304
  128. package/docs/ja/intlayer_with_vite+solid.md +159 -3
  129. package/docs/ja/intlayer_with_vite+svelte.md +157 -1
  130. package/docs/ja/intlayer_with_vite+vue.md +157 -1
  131. package/docs/ko/compiler.md +88 -52
  132. package/docs/ko/configuration.md +87 -44
  133. package/docs/ko/intlayer_with_nextjs_16.md +174 -1
  134. package/docs/ko/intlayer_with_nextjs_compiler.md +174 -1
  135. package/docs/ko/intlayer_with_react_router_v7.md +225 -2
  136. package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +226 -2
  137. package/docs/ko/intlayer_with_svelte_kit.md +158 -2
  138. package/docs/ko/intlayer_with_tanstack.md +159 -1
  139. package/docs/ko/intlayer_with_vite+preact.md +157 -1
  140. package/docs/ko/intlayer_with_vite+react.md +157 -1
  141. package/docs/ko/intlayer_with_vite+solid.md +159 -3
  142. package/docs/ko/intlayer_with_vite+svelte.md +157 -1
  143. package/docs/ko/intlayer_with_vite+vue.md +157 -1
  144. package/docs/pl/compiler.md +84 -51
  145. package/docs/pl/configuration.md +83 -37
  146. package/docs/pl/intlayer_with_nextjs_16.md +174 -1
  147. package/docs/pl/intlayer_with_nextjs_compiler.md +174 -1
  148. package/docs/pl/intlayer_with_react_router_v7.md +224 -1
  149. package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +225 -1
  150. package/docs/pl/intlayer_with_svelte_kit.md +158 -2
  151. package/docs/pl/intlayer_with_tanstack.md +159 -1
  152. package/docs/pl/intlayer_with_vite+preact.md +157 -1
  153. package/docs/pl/intlayer_with_vite+react.md +157 -1
  154. package/docs/pl/intlayer_with_vite+solid.md +157 -1
  155. package/docs/pl/intlayer_with_vite+svelte.md +157 -1
  156. package/docs/pl/intlayer_with_vite+vue.md +157 -1
  157. package/docs/pt/compiler.md +81 -46
  158. package/docs/pt/configuration.md +404 -194
  159. package/docs/pt/intlayer_with_nextjs_16.md +174 -1
  160. package/docs/pt/intlayer_with_nextjs_compiler.md +174 -1
  161. package/docs/pt/intlayer_with_react_router_v7.md +224 -1
  162. package/docs/pt/intlayer_with_react_router_v7_fs_routes.md +225 -1
  163. package/docs/pt/intlayer_with_svelte_kit.md +158 -2
  164. package/docs/pt/intlayer_with_tanstack.md +159 -1
  165. package/docs/pt/intlayer_with_vite+preact.md +157 -1
  166. package/docs/pt/intlayer_with_vite+react.md +157 -1
  167. package/docs/pt/intlayer_with_vite+solid.md +157 -1
  168. package/docs/pt/intlayer_with_vite+svelte.md +157 -1
  169. package/docs/pt/intlayer_with_vite+vue.md +157 -1
  170. package/docs/ru/compiler.md +90 -57
  171. package/docs/ru/configuration.md +76 -46
  172. package/docs/ru/intlayer_with_nextjs_16.md +174 -1
  173. package/docs/ru/intlayer_with_nextjs_compiler.md +174 -1
  174. package/docs/ru/intlayer_with_react_router_v7.md +224 -1
  175. package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +225 -1
  176. package/docs/ru/intlayer_with_svelte_kit.md +158 -2
  177. package/docs/ru/intlayer_with_tanstack.md +159 -1
  178. package/docs/ru/intlayer_with_vite+preact.md +157 -1
  179. package/docs/ru/intlayer_with_vite+react.md +157 -1
  180. package/docs/ru/intlayer_with_vite+solid.md +157 -1
  181. package/docs/ru/intlayer_with_vite+svelte.md +157 -1
  182. package/docs/ru/intlayer_with_vite+vue.md +157 -1
  183. package/docs/tr/compiler.md +85 -52
  184. package/docs/tr/configuration.md +83 -40
  185. package/docs/tr/intlayer_with_nextjs_16.md +174 -1
  186. package/docs/tr/intlayer_with_nextjs_compiler.md +174 -1
  187. package/docs/tr/intlayer_with_react_router_v7.md +224 -1
  188. package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +225 -1
  189. package/docs/tr/intlayer_with_svelte_kit.md +158 -2
  190. package/docs/tr/intlayer_with_tanstack.md +159 -1
  191. package/docs/tr/intlayer_with_vite+preact.md +157 -1
  192. package/docs/tr/intlayer_with_vite+react.md +157 -1
  193. package/docs/tr/intlayer_with_vite+solid.md +157 -1
  194. package/docs/tr/intlayer_with_vite+svelte.md +157 -1
  195. package/docs/tr/intlayer_with_vite+vue.md +157 -1
  196. package/docs/uk/compiler.md +96 -61
  197. package/docs/uk/configuration.md +83 -37
  198. package/docs/uk/intlayer_with_nextjs_16.md +174 -1
  199. package/docs/uk/intlayer_with_nextjs_compiler.md +174 -1
  200. package/docs/uk/intlayer_with_react_router_v7.md +224 -1
  201. package/docs/uk/intlayer_with_react_router_v7_fs_routes.md +225 -1
  202. package/docs/uk/intlayer_with_svelte_kit.md +157 -1
  203. package/docs/uk/intlayer_with_tanstack.md +159 -1
  204. package/docs/uk/intlayer_with_vite+preact.md +157 -1
  205. package/docs/uk/intlayer_with_vite+react.md +157 -1
  206. package/docs/uk/intlayer_with_vite+solid.md +157 -1
  207. package/docs/uk/intlayer_with_vite+svelte.md +157 -1
  208. package/docs/uk/intlayer_with_vite+vue.md +157 -1
  209. package/docs/vi/compiler.md +85 -50
  210. package/docs/vi/configuration.md +85 -39
  211. package/docs/vi/intlayer_with_nextjs_16.md +174 -1
  212. package/docs/vi/intlayer_with_nextjs_compiler.md +174 -1
  213. package/docs/vi/intlayer_with_react_router_v7.md +224 -1
  214. package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +225 -1
  215. package/docs/vi/intlayer_with_svelte_kit.md +158 -2
  216. package/docs/vi/intlayer_with_tanstack.md +159 -1
  217. package/docs/vi/intlayer_with_vite+preact.md +157 -1
  218. package/docs/vi/intlayer_with_vite+react.md +157 -1
  219. package/docs/vi/intlayer_with_vite+solid.md +157 -1
  220. package/docs/vi/intlayer_with_vite+svelte.md +157 -1
  221. package/docs/vi/intlayer_with_vite+vue.md +157 -1
  222. package/docs/zh/compiler.md +84 -49
  223. package/docs/zh/configuration.md +80 -37
  224. package/docs/zh/intlayer_with_adonisjs.md +1 -1
  225. package/docs/zh/intlayer_with_express.md +1 -1
  226. package/docs/zh/intlayer_with_fastify.md +1 -1
  227. package/docs/zh/intlayer_with_hono.md +1 -1
  228. package/docs/zh/intlayer_with_nestjs.md +1 -1
  229. package/docs/zh/intlayer_with_nextjs_16.md +174 -1
  230. package/docs/zh/intlayer_with_nextjs_compiler.md +174 -1
  231. package/docs/zh/intlayer_with_react_router_v7.md +227 -4
  232. package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +228 -4
  233. package/docs/zh/intlayer_with_svelte_kit.md +158 -2
  234. package/docs/zh/intlayer_with_tanstack.md +159 -1
  235. package/docs/zh/intlayer_with_vite+preact.md +159 -3
  236. package/docs/zh/intlayer_with_vite+react.md +157 -1
  237. package/docs/zh/intlayer_with_vite+solid.md +161 -5
  238. package/docs/zh/intlayer_with_vite+svelte.md +157 -1
  239. package/docs/zh/intlayer_with_vite+vue.md +158 -2
  240. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2024-08-13
3
- updatedAt: 2026-03-11
3
+ updatedAt: 2026-03-12
4
4
  title: Configuration
5
5
  description: Learn how to configure Intlayer for your application. Understand the various settings and options available to customize Intlayer to your needs.
6
6
  keywords:
@@ -15,7 +15,7 @@ slugs:
15
15
  - configuration
16
16
  history:
17
17
  - version: 8.3.0
18
- data: 2026-03-11
18
+ date: 2026-03-11
19
19
  changes: Move 'baseDir' from 'content' to 'system' config
20
20
  - version: 8.2.0
21
21
  date: 2026-03-09
@@ -119,7 +119,7 @@ Intlayer accepts JSON, JS, MJS, and TS configuration file formats:
119
119
 
120
120
  ## Example config file
121
121
 
122
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
122
+ ````typescript fileName="intlayer.config.ts" codeFormat="typescript"
123
123
  import { Locales, type IntlayerConfig } from "intlayer";
124
124
  import { nextjsRewrite } from "intlayer/routing";
125
125
  import { z } from "zod";
@@ -217,7 +217,7 @@ const config: IntlayerConfig = {
217
217
  * Options: 'cookie', 'localStorage', 'sessionStorage', 'header', or an array of these.
218
218
  * Default: ['cookie', 'header']
219
219
  */
220
- storage: "cookie",
220
+ storage: ["cookie", "header"],
221
221
 
222
222
  /**
223
223
  * Base path for the application URLs.
@@ -387,9 +387,9 @@ const config: IntlayerConfig = {
387
387
 
388
388
  /**
389
389
  * Output format for generated dictionary files.
390
- * Default: ['esm', 'cjs']
390
+ * Default: ['cjs', 'esm']
391
391
  */
392
- outputFormat: ["esm"],
392
+ outputFormat: ["cjs", "esm"],
393
393
 
394
394
  /**
395
395
  * Indicates if the build should check TypeScript types.
@@ -464,43 +464,70 @@ const config: IntlayerConfig = {
464
464
  compiler: {
465
465
  /**
466
466
  * Indicates if the compiler should be enabled.
467
- * Set to 'build-only' to skip the compiler during development and speed up start times.
467
+ *
468
+ * - false: Disable the compiler.
469
+ * - true: Enable the compiler.
470
+ * - "build-only": Skip the compiler during development and speed up start times.
471
+ *
472
+ * Default: false
468
473
  */
469
474
  enabled: true,
470
475
 
471
476
  /**
472
- * Pattern to traverse the code to optimize.
473
- */
474
- transformPattern: [
475
- "**/*.{js,ts,mjs,cjs,jsx,tsx,vue,svelte}",
476
- "!**/node_modules/**",
477
- ],
478
-
479
- /**
480
- * Pattern to exclude from the optimization.
477
+ * Defines the output files path. Replaces `outputDir`.
478
+ *
479
+ * - `./` paths are resolved relative to the component directory.
480
+ * - `/` paths are resolved relative to the project root (`baseDir`).
481
+ *
482
+ * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
483
+ *
484
+ * Example:
485
+ * ```ts
486
+ * {
487
+ * // Create Multilingual .content.ts files close to the component
488
+ * output: ({ fileName, extension }) => `./${fileName}${extension}`,
489
+ *
490
+ * // output: './{{fileName}}{{extension}}', // Equivalent using template string
491
+ * }
492
+ * ```
493
+ *
494
+ * ```ts
495
+ * {
496
+ * // Create centralize per-locale JSON at the root of the project
497
+ * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
498
+ *
499
+ * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
500
+ * }
501
+ * ```
502
+ *
503
+ * Variable list:
504
+ * - `fileName`: The name of the file.
505
+ * - `key`: The key of the content.
506
+ * - `locale`: The locale of the content.
507
+ * - `extension`: The extension of the file.
508
+ * - `componentFileName`: The name of the component file.
509
+ * - `componentExtension`: The extension of the component file.
510
+ * - `format`: The format of the dictionary.
511
+ * - `componentFormat`: The format of the component dictionary.
512
+ * - `componentDirPath`: The directory path of the component.
481
513
  */
482
- excludePattern: ["**/node_modules/**"],
514
+ output: ({ locale, key }) => `compiler/${locale}/${key}.json`,
483
515
 
484
516
  /**
485
- * Output directory for the optimized dictionaries.
517
+ * Indicates if the components should be saved after being transformed.
518
+ * That way, the compiler can be run only once to transform the app, and then it can be removed.
486
519
  */
487
- output: ({ locale, key }) => `compiler/${locale}/${key}.json`,
520
+ saveComponents: false,
488
521
 
489
522
  /**
490
- * Inset only content in generated file, without key.
523
+ * Inset only content into the generated file. Useful for per-locale i18next or ICU MessageFormat JSON outputs.
491
524
  */
492
525
  noMetadata: false,
493
526
 
494
527
  /**
495
528
  * Dictionary key prefix
496
529
  */
497
- dictionaryKeyPrefix: "", // Remove base prefix
498
-
499
- /**
500
- * Indicates if the components should be saved after being transformed.
501
- * That way, the compiler can be run only once to transform the app, and then it can be removed.
502
- */
503
- saveComponents: false,
530
+ dictionaryKeyPrefix: "", // Add an optional prefix for the extracted dictionary keys
504
531
  },
505
532
 
506
533
  /**
@@ -519,7 +546,7 @@ const config: IntlayerConfig = {
519
546
  };
520
547
 
521
548
  export default config;
522
- ```
549
+ ````
523
550
 
524
551
  ---
525
552
 
@@ -537,7 +564,7 @@ Defines settings related to internationalization, including available locales an
537
564
 
538
565
  - **locales**:
539
566
  - _Type_: `string[]`
540
- - _Default_: `['en']`
567
+ - _Default_: `[Locales.ENGLISH]`
541
568
  - _Description_: The list of supported locales in the application.
542
569
  - _Example_: `['en', 'fr', 'es']`
543
570
 
@@ -558,7 +585,7 @@ Defines settings related to internationalization, including available locales an
558
585
 
559
586
  - **defaultLocale**:
560
587
  - _Type_: `string`
561
- - _Default_: `'en'`
588
+ - _Default_: `Locales.ENGLISH`
562
589
  - _Description_: The default locale used as a fallback if the requested locale is not found.
563
590
  - _Example_: `'en'`
564
591
  - _Note_: This is used to determine the locale when none is specified in the URL, cookie, or header.
@@ -573,7 +600,7 @@ Defines settings related to the integrated editor, including server port and act
573
600
 
574
601
  - **applicationURL**:
575
602
  - _Type_: `string`
576
- - _Default_: `http://localhost:3000`
603
+ - _Default_: `''`
577
604
  - _Description_: The URL of the application. Used to restrict the origin of the editor for security reasons.
578
605
  - _Example_:
579
606
  - `'http://localhost:3000'`
@@ -637,7 +664,7 @@ Defines settings related to the integrated editor, including server port and act
637
664
 
638
665
  - **liveSync**:
639
666
  - _Type_: `boolean`
640
- - _Default_: `false`
667
+ - _Default_: `true`
641
668
  - _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.
642
669
  - _Example_: `true`
643
670
  - _Note_: For example, when a new dictionary is added or updated, the application will update the content to display in the page.
@@ -676,7 +703,7 @@ Settings that control routing behavior, including URL structure, locale storage,
676
703
 
677
704
  - **storage**:
678
705
  - _Type_: `false | 'cookie' | 'localStorage' | 'sessionStorage' | 'header' | CookiesAttributes | StorageAttributes | Array`
679
- - _Default_: `'localStorage'`
706
+ - _Default_: `['cookie', 'header']`
680
707
  - _Description_: Configuration for storing the locale in the client.
681
708
 
682
709
  - **cookie**:
@@ -779,7 +806,6 @@ const config: IntlayerConfig = {
779
806
  routing: {
780
807
  mode: "prefix-no-default",
781
808
  storage: "localStorage",
782
- headerName: "x-intlayer-locale",
783
809
  basePath: "",
784
810
  },
785
811
  };
@@ -812,7 +838,6 @@ const config: IntlayerConfig = {
812
838
  httpOnly: false,
813
839
  },
814
840
  ],
815
- headerName: "x-intlayer-locale",
816
841
  basePath: "",
817
842
  },
818
843
  };
@@ -833,7 +858,6 @@ const config: IntlayerConfig = {
833
858
  routing: {
834
859
  mode: "search-params",
835
860
  storage: "localStorage",
836
- headerName: "x-intlayer-locale",
837
861
  basePath: "",
838
862
  },
839
863
  };
@@ -857,7 +881,6 @@ const config: IntlayerConfig = {
857
881
  type: "sessionStorage",
858
882
  name: "app-locale",
859
883
  },
860
- headerName: "x-custom-locale",
861
884
  basePath: "/my-app",
862
885
  },
863
886
  };
@@ -872,7 +895,6 @@ export default config;
872
895
  import { nextjsRewrite } from "intlayer/routing";
873
896
 
874
897
  const config: IntlayerConfig = {
875
-
876
898
  internationalization: {
877
899
  locales: ["en", "fr"],
878
900
  defaultLocale: "en",
@@ -893,12 +915,11 @@ const config: IntlayerConfig = {
893
915
  en: "/blog/[category]/[id]",
894
916
  fr: "/journal/[category]/[id]",
895
917
  },
896
-
918
+ }),
919
+ },
897
920
  };
898
921
 
899
- export default config;,
900
- },
901
- });
922
+ export default config;
902
923
  ```
903
924
 
904
925
  ---
@@ -916,7 +937,7 @@ Settings related to content handling within the application, including directory
916
937
 
917
938
  - **fileExtensions**:
918
939
  - _Type_: `string[]`
919
- - _Default_: `['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']`
940
+ - _Default_: `['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.json5', '.content.jsonc', '.content.tsx', '.content.jsx']`
920
941
  - _Description_: File extensions to look for when building dictionaries.
921
942
  - _Example_: `['.data.ts', '.data.js', '.data.json']`
922
943
  - _Note_: Customizing file extensions can help avoid conflicts.
@@ -1213,8 +1234,8 @@ Build options apply to the `@intlayer/babel` and `@intlayer/swc` plugins.
1213
1234
  - _Note_: This can slow down the build.
1214
1235
 
1215
1236
  - **outputFormat**:
1216
- - _Type_: `'esm' | 'cjs'`
1217
- - _Default_: `'esm'`
1237
+ - _Type_: `('esm' | 'cjs')[]`
1238
+ - _Default_: `['cjs', 'esm']`
1218
1239
  - _Description_: Controls the output format of the dictionaries.
1219
1240
  - _Example_: `'cjs'`
1220
1241
  - _Note_: The output format of the dictionaries.
@@ -1245,7 +1266,7 @@ Settings that control the Intlayer compiler, which extracts dictionaries straigh
1245
1266
 
1246
1267
  - **dictionaryKeyPrefix**:
1247
1268
  - _Type_: `string`
1248
- - _Default_: `'comp-'`
1269
+ - _Default_: `''`
1249
1270
  - _Description_: Prefix for the extracted dictionary keys.
1250
1271
  - _Example_: `'my-key-'`
1251
1272
  - _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.
@@ -1269,23 +1290,25 @@ Settings that control the Intlayer compiler, which extracts dictionaries straigh
1269
1290
  - _Description_: Patterns that define which files should be excluded during optimization.
1270
1291
  - _Example_: `['**/node_modules/**', '!**/node_modules/react/**']`
1271
1292
 
1272
- - **outputDir**:
1273
- - _Type_: `string`
1274
- - _Default_: `'compiler'`
1275
- - _Description_: The directory where the extracted dictionaries will be stored, relative to your project base path.
1276
-
1277
1293
  - **output**:
1278
1294
  - _Type_: `FilePathPattern`
1279
- - _Default_: `({ key }) => 'compiler/${key}.content.json'`
1280
- - _Description_: Defines the output files path. Replaces `outputDir`. Handles dynamic variables like `{{locale}}`, `{{key}}`, `{{fileName}}`, `{{extension}}`, `{{format}}`, `{{dirPath}}`, `{{componentFileName}}`, `{{componentExtension}}`, `{{componentFormat}}`. Can be set as a string using `'my/{{var}}/path'` format, or as a function.
1281
- - _Note_: `./**/*` Path are resolved relatively to the component. `/**/*` path are resolved relatively to the Intlayer `baseDir`.
1282
- - _Note_: If locale is set in the path, it will generate per-locale dictionaries.
1283
- - _Example_: `output: ({ locale, key }) => 'compiler/${locale}/${key}.json'`
1295
+ - _Default_: `undefined`
1296
+ - _Description_: Defines the output files path. Replaces `outputDir`. Handles dynamic variables via template strings or a function. Supported variables: `{{fileName}}`, `{{key}}`, `{{locale}}`, `{{extension}}`, `{{componentFileName}}`, `{{componentExtension}}`, `{{format}}`, `{{componentFormat}}`, and `{{componentDirPath}}`.
1297
+ - _Note_: `./` paths are resolved relative to the component directory. `/` paths are resolved relative to the project root (`baseDir`).
1298
+ - _Note_: Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
1299
+ - _Example_:
1300
+ - **Multilingual files near component**:
1301
+ - String: `'./{{fileName}}{{extension}}'`
1302
+ - Function: `({ fileName, extension }) => \`./${fileName}${extension}``
1303
+
1304
+ - **Centralized per-locale JSON**:
1305
+ - String: `'/locales/{{locale}}/{{key}}.content.json'`
1306
+ - Function: `({ key, locale }) => \`/locales/${locale}/${key}.content.json``
1284
1307
 
1285
1308
  - **noMetadata**:
1286
1309
  - _Type_: `boolean`
1287
1310
  - _Default_: `false`
1288
- - _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).
1311
+ - _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.
1289
1312
  - _Note_: Useful if used with `loadJSON` plugin.
1290
1313
  - _Example_:
1291
1314
  If `true`:
@@ -1629,6 +1629,182 @@ bun add @intlayer/swc --dev
1629
1629
 
1630
1630
  > Note: If you set the option as `importMode: 'dynamic'` or `importMode: 'fetch'` (in the `dictionary` configuration), it will rely on Suspense, so you will have to wrap your `useIntlayer` calls in a `Suspense` boundary. That means, you will not be able to use the `useIntlayer` directly at the top level of your Page / Layout component.
1631
1631
 
1632
+ ### (Optional) Step 14: Extract the content of your components
1633
+
1634
+ If you have an existing codebase, transforming thousands of files can be time-consuming.
1635
+
1636
+ To ease this process, Intlayer propose a [compiler](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compiler.md) / [extractor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/extract.md) to transform your components and extract the content.
1637
+
1638
+ To set it up, you can add a `compiler` section in your `intlayer.config.ts` file:
1639
+
1640
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
1641
+ import { type IntlayerConfig } from "intlayer";
1642
+
1643
+ const config: IntlayerConfig = {
1644
+ // ... Rest of your config
1645
+ compiler: {
1646
+ /**
1647
+ * Indicates if the compiler should be enabled.
1648
+ */
1649
+ enabled: true,
1650
+
1651
+ /**
1652
+ * Defines the output files path
1653
+ */
1654
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
1655
+
1656
+ /**
1657
+ * Indicates if the components should be saved after being transformed.
1658
+ * That way, the compiler can be run only once to transform the app, and then it can be removed.
1659
+ */
1660
+ saveComponents: false,
1661
+
1662
+ /**
1663
+ * Dictionary key prefix
1664
+ */
1665
+ dictionaryKeyPrefix: "",
1666
+ },
1667
+ };
1668
+
1669
+ export default config;
1670
+ ```
1671
+
1672
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
1673
+ /** @type {import('intlayer').IntlayerConfig} */
1674
+ const config = {
1675
+ // ... Rest of your config
1676
+ compiler: {
1677
+ /**
1678
+ * Indicates if the compiler should be enabled.
1679
+ */
1680
+ enabled: true,
1681
+
1682
+ /**
1683
+ * Defines the output files path
1684
+ */
1685
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
1686
+
1687
+ /**
1688
+ * Indicates if the components should be saved after being transformed.
1689
+ * That way, the compiler can be run only once to transform the app, and then it can be removed.
1690
+ */
1691
+ saveComponents: false,
1692
+
1693
+ /**
1694
+ * Dictionary key prefix
1695
+ */
1696
+ dictionaryKeyPrefix: "",
1697
+ },
1698
+ };
1699
+
1700
+ export default config;
1701
+ ```
1702
+
1703
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
1704
+ /** @type {import('intlayer').IntlayerConfig} */
1705
+ const config = {
1706
+ // ... Rest of your config
1707
+ compiler: {
1708
+ /**
1709
+ * Indicates if the compiler should be enabled.
1710
+ */
1711
+ enabled: true,
1712
+
1713
+ /**
1714
+ * Defines the output files path
1715
+ */
1716
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
1717
+
1718
+ /**
1719
+ * Indicates if the components should be saved after being transformed.
1720
+ * That way, the compiler can be run only once to transform the app, and then it can be removed.
1721
+ */
1722
+ saveComponents: false,
1723
+
1724
+ /**
1725
+ * Dictionary key prefix
1726
+ */
1727
+ dictionaryKeyPrefix: "",
1728
+ },
1729
+ };
1730
+
1731
+ module.exports = config;
1732
+ ```
1733
+
1734
+ <Tabs>
1735
+ <Tab value='Extract command'>
1736
+
1737
+ Run the extractor to transform your components and extract the content
1738
+
1739
+ ```bash packageManager="npm"
1740
+ npx intlayer extract
1741
+ ```
1742
+
1743
+ ```bash packageManager="pnpm"
1744
+ pnpm intlayer extract
1745
+ ```
1746
+
1747
+ ```bash packageManager="yarn"
1748
+ yarn intlayer extract
1749
+ ```
1750
+
1751
+ ```bash packageManager="bun"
1752
+ bunx intlayer extract
1753
+ ```
1754
+
1755
+ </Tab>
1756
+ <Tab value='Babel compiler'>
1757
+
1758
+ ```bash packageManager="npm"
1759
+ npm install @intlayer/babel --save-dev
1760
+ ```
1761
+
1762
+ ```bash packageManager="pnpm"
1763
+ pnpm add @intlayer/babel --save-dev
1764
+ ```
1765
+
1766
+ ```bash packageManager="yarn"
1767
+ yarn add @intlayer/babel --save-dev
1768
+ ```
1769
+
1770
+ ```bash packageManager="bun"
1771
+ bun add @intlayer/babel --dev
1772
+ ```
1773
+
1774
+ ```js fileName="babel.config.js"
1775
+ const {
1776
+ intlayerExtractBabelPlugin,
1777
+ getExtractPluginOptions,
1778
+ } = require("@intlayer/babel");
1779
+
1780
+ module.exports = {
1781
+ presets: ["next/babel"],
1782
+ plugins: [
1783
+ // Extract content from components into dictionaries
1784
+ [intlayerExtractBabelPlugin, getExtractPluginOptions()],
1785
+ ],
1786
+ };
1787
+ ```
1788
+
1789
+ ```bash packageManager="npm"
1790
+ npm run build # Or npm run dev
1791
+ ```
1792
+
1793
+ ```bash packageManager="pnpm"
1794
+ pnpm run build # Or pnpm run dev
1795
+ ```
1796
+
1797
+ ```bash packageManager="yarn"
1798
+ yarn build # Or yarn dev
1799
+ ```
1800
+
1801
+ ```bash packageManager="bun"
1802
+ bun run build # Or bun run dev
1803
+ ```
1804
+
1805
+ </Tab>
1806
+ </Tabs>
1807
+
1632
1808
  ### Watch dictionaries changes on Turbopack
1633
1809
 
1634
1810
  When using Turbopack as your development server with the `next dev` command, dictionary changes will not be automatically detected by default.
@@ -431,7 +431,9 @@ export const LocaleSwitcher: FC = () => {
431
431
 
432
432
  When using `next-intlayer`, dictionaries are included in the bundle for every page by default. To optimize bundle size, Intlayer provides an optional SWC plugin that intelligently replace `useIntlayer` calls using macros. This ensures dictionaries are only included in bundles for pages that actually use them.
433
433
 
434
- To enable this optimization, install the `@intlayer/swc` package. Once installed, `next-intlayer` will automatically detect and use the plugin:
434
+ The `@intlayer/babel` plugin already integrate the bundling optimization (see `babel.config.js`). But the `@intlayer/swc` plugin is more performant. If you remove the `@intlayer/babel` plugin, you can use the `@intlayer/swc` plugin.
435
+
436
+ Install the `@intlayer/swc` package. Once installed, `next-intlayer` will automatically detect and use the plugin:
435
437
 
436
438
  ```bash packageManager="npm"
437
439
  npm install @intlayer/swc --save-dev
@@ -455,6 +457,182 @@ bun add @intlayer/swc --dev
455
457
 
456
458
  > Note: If you set the option as `importMode: 'dynamic'` or `importMode: 'fetch'` (in the `dictionary` configuration), it will rely on Suspense, so you will have to wrap your `useIntlayer` calls in a `Suspense` boundary. That means, you will not be able to use the `useIntlayer` directly at the top level of your Page / Layout component.
457
459
 
460
+ ### (Optional) Step 11: Extract the content of your components
461
+
462
+ If you have an existing codebase, transforming thousands of files can be time-consuming.
463
+
464
+ To ease this process, Intlayer propose a [compiler](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/compiler.md) / [extractor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/extract.md) to transform your components and extract the content.
465
+
466
+ To set it up, you can add a `compiler` section in your `intlayer.config.ts` file:
467
+
468
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
469
+ import { type IntlayerConfig } from "intlayer";
470
+
471
+ const config: IntlayerConfig = {
472
+ // ... Rest of your config
473
+ compiler: {
474
+ /**
475
+ * Indicates if the compiler should be enabled.
476
+ */
477
+ enabled: true,
478
+
479
+ /**
480
+ * Defines the output files path
481
+ */
482
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
483
+
484
+ /**
485
+ * Indicates if the components should be saved after being transformed.
486
+ * That way, the compiler can be run only once to transform the app, and then it can be removed.
487
+ */
488
+ saveComponents: false,
489
+
490
+ /**
491
+ * Dictionary key prefix
492
+ */
493
+ dictionaryKeyPrefix: "",
494
+ },
495
+ };
496
+
497
+ export default config;
498
+ ```
499
+
500
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
501
+ /** @type {import('intlayer').IntlayerConfig} */
502
+ const config = {
503
+ // ... Rest of your config
504
+ compiler: {
505
+ /**
506
+ * Indicates if the compiler should be enabled.
507
+ */
508
+ enabled: true,
509
+
510
+ /**
511
+ * Defines the output files path
512
+ */
513
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
514
+
515
+ /**
516
+ * Indicates if the components should be saved after being transformed.
517
+ * That way, the compiler can be run only once to transform the app, and then it can be removed.
518
+ */
519
+ saveComponents: false,
520
+
521
+ /**
522
+ * Dictionary key prefix
523
+ */
524
+ dictionaryKeyPrefix: "",
525
+ },
526
+ };
527
+
528
+ export default config;
529
+ ```
530
+
531
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
532
+ /** @type {import('intlayer').IntlayerConfig} */
533
+ const config = {
534
+ // ... Rest of your config
535
+ compiler: {
536
+ /**
537
+ * Indicates if the compiler should be enabled.
538
+ */
539
+ enabled: true,
540
+
541
+ /**
542
+ * Defines the output files path
543
+ */
544
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
545
+
546
+ /**
547
+ * Indicates if the components should be saved after being transformed.
548
+ * That way, the compiler can be run only once to transform the app, and then it can be removed.
549
+ */
550
+ saveComponents: false,
551
+
552
+ /**
553
+ * Dictionary key prefix
554
+ */
555
+ dictionaryKeyPrefix: "",
556
+ },
557
+ };
558
+
559
+ module.exports = config;
560
+ ```
561
+
562
+ <Tabs>
563
+ <Tab value='Extract command'>
564
+
565
+ Run the extractor to transform your components and extract the content
566
+
567
+ ```bash packageManager="npm"
568
+ npx intlayer extract
569
+ ```
570
+
571
+ ```bash packageManager="pnpm"
572
+ pnpm intlayer extract
573
+ ```
574
+
575
+ ```bash packageManager="yarn"
576
+ yarn intlayer extract
577
+ ```
578
+
579
+ ```bash packageManager="bun"
580
+ bunx intlayer extract
581
+ ```
582
+
583
+ </Tab>
584
+ <Tab value='Babel compiler'>
585
+
586
+ ```bash packageManager="npm"
587
+ npm install @intlayer/babel --save-dev
588
+ ```
589
+
590
+ ```bash packageManager="pnpm"
591
+ pnpm add @intlayer/babel --save-dev
592
+ ```
593
+
594
+ ```bash packageManager="yarn"
595
+ yarn add @intlayer/babel --save-dev
596
+ ```
597
+
598
+ ```bash packageManager="bun"
599
+ bun add @intlayer/babel --dev
600
+ ```
601
+
602
+ ```js fileName="babel.config.js"
603
+ const {
604
+ intlayerExtractBabelPlugin,
605
+ getExtractPluginOptions,
606
+ } = require("@intlayer/babel");
607
+
608
+ module.exports = {
609
+ presets: ["next/babel"],
610
+ plugins: [
611
+ // Extract content from components into dictionaries
612
+ [intlayerExtractBabelPlugin, getExtractPluginOptions()],
613
+ ],
614
+ };
615
+ ```
616
+
617
+ ```bash packageManager="npm"
618
+ npm run build # Or npm run dev
619
+ ```
620
+
621
+ ```bash packageManager="pnpm"
622
+ pnpm run build # Or pnpm run dev
623
+ ```
624
+
625
+ ```bash packageManager="yarn"
626
+ yarn build # Or yarn dev
627
+ ```
628
+
629
+ ```bash packageManager="bun"
630
+ bun run build # Or bun run dev
631
+ ```
632
+
633
+ </Tab>
634
+ </Tabs>
635
+
458
636
  ### Configure TypeScript
459
637
 
460
638
  Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.