@intlayer/docs 7.3.0 → 7.3.2-canary.0

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/README.md +0 -2
  2. package/blog/ar/compiler_vs_declarative_i18n.md +1 -2
  3. package/blog/ar/list_i18n_technologies/frameworks/flutter.md +0 -22
  4. package/blog/de/compiler_vs_declarative_i18n.md +1 -2
  5. package/blog/de/list_i18n_technologies/frameworks/flutter.md +0 -22
  6. package/blog/en/compiler_vs_declarative_i18n.md +1 -2
  7. package/blog/en/list_i18n_technologies/frameworks/flutter.md +0 -22
  8. package/blog/en/list_i18n_technologies/frameworks/svelte.md +19 -3
  9. package/blog/en/list_i18n_technologies/frameworks/vue.md +16 -2
  10. package/blog/en-GB/compiler_vs_declarative_i18n.md +1 -2
  11. package/blog/en-GB/list_i18n_technologies/frameworks/flutter.md +0 -22
  12. package/blog/es/compiler_vs_declarative_i18n.md +1 -2
  13. package/blog/es/list_i18n_technologies/frameworks/flutter.md +0 -22
  14. package/blog/fr/compiler_vs_declarative_i18n.md +1 -2
  15. package/blog/fr/list_i18n_technologies/frameworks/flutter.md +0 -22
  16. package/blog/hi/compiler_vs_declarative_i18n.md +1 -2
  17. package/blog/hi/list_i18n_technologies/frameworks/flutter.md +0 -22
  18. package/blog/id/compiler_vs_declarative_i18n.md +1 -2
  19. package/blog/id/list_i18n_technologies/frameworks/flutter.md +0 -22
  20. package/blog/it/compiler_vs_declarative_i18n.md +1 -2
  21. package/blog/it/list_i18n_technologies/frameworks/flutter.md +0 -22
  22. package/blog/ja/compiler_vs_declarative_i18n.md +1 -2
  23. package/blog/ja/list_i18n_technologies/frameworks/flutter.md +0 -22
  24. package/blog/ko/compiler_vs_declarative_i18n.md +1 -2
  25. package/blog/ko/list_i18n_technologies/frameworks/flutter.md +0 -22
  26. package/blog/pl/compiler_vs_declarative_i18n.md +1 -2
  27. package/blog/pl/list_i18n_technologies/frameworks/flutter.md +0 -22
  28. package/blog/pt/compiler_vs_declarative_i18n.md +1 -2
  29. package/blog/pt/list_i18n_technologies/frameworks/flutter.md +0 -22
  30. package/blog/ru/compiler_vs_declarative_i18n.md +1 -2
  31. package/blog/ru/list_i18n_technologies/frameworks/flutter.md +0 -22
  32. package/blog/tr/compiler_vs_declarative_i18n.md +1 -2
  33. package/blog/tr/list_i18n_technologies/frameworks/flutter.md +0 -22
  34. package/blog/vi/compiler_vs_declarative_i18n.md +1 -2
  35. package/blog/vi/list_i18n_technologies/frameworks/flutter.md +0 -22
  36. package/blog/zh/compiler_vs_declarative_i18n.md +1 -2
  37. package/blog/zh/list_i18n_technologies/frameworks/flutter.md +0 -22
  38. package/dist/cjs/generated/docs.entry.cjs +38 -0
  39. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  40. package/dist/esm/generated/docs.entry.mjs +38 -0
  41. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  42. package/dist/types/generated/docs.entry.d.ts +2 -0
  43. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  44. package/docs/ar/bundle_optimization.md +184 -0
  45. package/docs/ar/compiler.md +133 -0
  46. package/docs/ar/vs_code_extension.md +4 -0
  47. package/docs/de/bundle_optimization.md +194 -0
  48. package/docs/de/compiler.md +133 -0
  49. package/docs/de/how_works_intlayer.md +1 -1
  50. package/docs/de/vs_code_extension.md +4 -0
  51. package/docs/en/bundle_optimization.md +184 -0
  52. package/docs/en/compiler.md +133 -0
  53. package/docs/en/configuration.md +5 -2
  54. package/docs/en/how_works_intlayer.md +1 -1
  55. package/docs/en/vs_code_extension.md +7 -0
  56. package/docs/en-GB/bundle_optimization.md +184 -0
  57. package/docs/en-GB/compiler.md +133 -0
  58. package/docs/en-GB/how_works_intlayer.md +1 -1
  59. package/docs/en-GB/vs_code_extension.md +4 -0
  60. package/docs/es/bundle_optimization.md +194 -0
  61. package/docs/es/compiler.md +133 -0
  62. package/docs/es/how_works_intlayer.md +1 -1
  63. package/docs/es/vs_code_extension.md +4 -0
  64. package/docs/fr/bundle_optimization.md +184 -0
  65. package/docs/fr/compiler.md +133 -0
  66. package/docs/fr/how_works_intlayer.md +1 -1
  67. package/docs/fr/vs_code_extension.md +4 -0
  68. package/docs/hi/bundle_optimization.md +184 -0
  69. package/docs/hi/compiler.md +133 -0
  70. package/docs/hi/vs_code_extension.md +4 -0
  71. package/docs/id/bundle_optimization.md +184 -0
  72. package/docs/id/compiler.md +133 -0
  73. package/docs/id/how_works_intlayer.md +1 -1
  74. package/docs/id/vs_code_extension.md +4 -0
  75. package/docs/it/bundle_optimization.md +184 -0
  76. package/docs/it/compiler.md +133 -0
  77. package/docs/it/how_works_intlayer.md +1 -1
  78. package/docs/it/vs_code_extension.md +4 -0
  79. package/docs/ja/bundle_optimization.md +184 -0
  80. package/docs/ja/compiler.md +133 -0
  81. package/docs/ja/vs_code_extension.md +4 -0
  82. package/docs/ko/bundle_optimization.md +184 -0
  83. package/docs/ko/compiler.md +133 -0
  84. package/docs/ko/vs_code_extension.md +4 -0
  85. package/docs/pl/bundle_optimization.md +184 -0
  86. package/docs/pl/compiler.md +133 -0
  87. package/docs/pl/how_works_intlayer.md +1 -1
  88. package/docs/pl/vs_code_extension.md +4 -0
  89. package/docs/pt/bundle_optimization.md +184 -0
  90. package/docs/pt/compiler.md +133 -0
  91. package/docs/pt/how_works_intlayer.md +1 -1
  92. package/docs/pt/vs_code_extension.md +4 -0
  93. package/docs/ru/bundle_optimization.md +184 -0
  94. package/docs/ru/compiler.md +133 -0
  95. package/docs/ru/vs_code_extension.md +4 -0
  96. package/docs/tr/bundle_optimization.md +184 -0
  97. package/docs/tr/compiler.md +133 -0
  98. package/docs/tr/how_works_intlayer.md +1 -1
  99. package/docs/tr/vs_code_extension.md +4 -0
  100. package/docs/vi/bundle_optimization.md +184 -0
  101. package/docs/vi/compiler.md +133 -0
  102. package/docs/vi/vs_code_extension.md +4 -0
  103. package/docs/zh/bundle_optimization.md +184 -0
  104. package/docs/zh/compiler.md +133 -0
  105. package/docs/zh/vs_code_extension.md +4 -0
  106. package/package.json +8 -7
  107. package/src/generated/docs.entry.ts +38 -0
@@ -0,0 +1,133 @@
1
+ ---
2
+ createdAt: 2025-09-09
3
+ updatedAt: 2025-09-09
4
+ title: Intlayer Compiler | Automatisierte Inhaltsextraktion für i18n
5
+ description: Automatisieren Sie Ihren Internationalisierungsprozess mit dem Intlayer Compiler. Extrahieren Sie Inhalte direkt aus Ihren Komponenten für schnellere und effizientere i18n in Vite, Next.js und mehr.
6
+ keywords:
7
+ - Intlayer
8
+ - Compiler
9
+ - Internationalisierung
10
+ - i18n
11
+ - Automatisierung
12
+ - Extraktion
13
+ - Geschwindigkeit
14
+ - Vite
15
+ - Next.js
16
+ - React
17
+ - Vue
18
+ - Svelte
19
+ slugs:
20
+ - doc
21
+ - compiler
22
+ history:
23
+ - version: 7.3.1
24
+ date: 2025-11-27
25
+ changes: Release Compiler
26
+ ---
27
+
28
+ # Intlayer Compiler | Automatisierte Inhaltsextraktion für i18n
29
+
30
+ ## Was ist der Intlayer Compiler?
31
+
32
+ Der **Intlayer Compiler** ist ein leistungsstarkes Werkzeug, das entwickelt wurde, um den Prozess der Internationalisierung (i18n) in Ihren Anwendungen zu automatisieren. Er durchsucht Ihren Quellcode (JSX, TSX, Vue, Svelte) nach Inhaltsdeklarationen, extrahiert diese und generiert automatisch die notwendigen Wörterbuchdateien. Dadurch können Sie Ihre Inhalte direkt bei den Komponenten belassen, während Intlayer die Verwaltung und Synchronisierung Ihrer Wörterbücher übernimmt.
33
+
34
+ ## Warum den Intlayer Compiler verwenden?
35
+
36
+ - **Automatisierung**: Beseitigt das manuelle Kopieren und Einfügen von Inhalten in Wörterbücher.
37
+ - **Geschwindigkeit**: Optimierte Inhaltsextraktion, die sicherstellt, dass Ihr Build-Prozess schnell bleibt.
38
+ - **Entwicklererfahrung**: Behalten Sie Inhaltsdeklarationen genau dort, wo sie verwendet werden, und verbessern Sie so die Wartbarkeit.
39
+ - **Live-Updates**: Unterstützt Hot Module Replacement (HMR) für sofortiges Feedback während der Entwicklung.
40
+
41
+ Siehe den Blogbeitrag [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/de/compiler_vs_declarative_i18n.md) für einen tieferen Vergleich.
42
+
43
+ ## Warum den Intlayer Compiler nicht verwenden?
44
+
45
+ Während der Compiler eine ausgezeichnete "funktioniert einfach so"-Erfahrung bietet, führt er auch einige Kompromisse ein, die Sie beachten sollten:
46
+
47
+ - **Heuristische Mehrdeutigkeit**: Der Compiler muss erraten, was benutzerorientierter Inhalt im Gegensatz zur Anwendungslogik ist (z. B. `className="active"`, Statuscodes, Produkt-IDs). In komplexen Codebasen kann dies zu falschen Positiven oder übersehenen Zeichenketten führen, die manuelle Anmerkungen und Ausnahmen erfordern.
48
+ - **Nur statische Extraktion**: Die compilerbasierte Extraktion basiert auf statischer Analyse. Zeichenketten, die nur zur Laufzeit existieren (API-Fehlercodes, CMS-Felder usw.), können vom Compiler allein nicht entdeckt oder übersetzt werden, daher benötigen Sie immer noch eine ergänzende Laufzeit-i18n-Strategie.
49
+
50
+ Für einen tieferen architektonischen Vergleich siehe den Blogbeitrag [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/de/compiler_vs_declarative_i18n.md).
51
+
52
+ Als Alternative, um Ihren i18n-Prozess zu automatisieren und gleichzeitig die volle Kontrolle über Ihren Inhalt zu behalten, bietet Intlayer auch einen Auto-Extraktionsbefehl `intlayer transform` (siehe [CLI-Dokumentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/cli/transform.md)) oder den Befehl `Intlayer: extract content to Dictionary` aus der Intlayer VS Code-Erweiterung (siehe [VS Code-Erweiterungsdokumentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/vs_code_extension.md)).
53
+
54
+ ## Verwendung
55
+
56
+ ### Vite
57
+
58
+ Für Vite-basierte Anwendungen (React, Vue, Svelte usw.) ist der einfachste Weg, den Compiler zu verwenden, das `vite-intlayer` Plugin.
59
+
60
+ #### Installation
61
+
62
+ ```bash
63
+ npm install vite-intlayer
64
+ ```
65
+
66
+ #### Konfiguration
67
+
68
+ Aktualisieren Sie Ihre `vite.config.ts`, um das `intlayerCompiler` Plugin einzubinden:
69
+
70
+ ```ts fileName="vite.config.ts"
71
+ import { defineConfig } from "vite";
72
+ import { intlayer, intlayerCompiler } from "vite-intlayer";
73
+
74
+ export default defineConfig({
75
+ plugins: [
76
+ intlayer(),
77
+ intlayerCompiler(), // Fügt das Compiler-Plugin hinzu
78
+ ],
79
+ });
80
+ ```
81
+
82
+ #### Framework-Unterstützung
83
+
84
+ Das Vite-Plugin erkennt und verarbeitet automatisch verschiedene Dateitypen:
85
+
86
+ - **React / JSX / TSX**: Wird nativ unterstützt.
87
+ - **Vue**: Erfordert `@intlayer/vue-compiler`.
88
+ - **Svelte**: Erfordert `@intlayer/svelte-compiler`.
89
+
90
+ Stellen Sie sicher, dass Sie das passende Compiler-Paket für Ihr Framework installieren:
91
+
92
+ ```bash
93
+ # Für Vue
94
+ npm install @intlayer/vue-compiler
95
+
96
+ # Für Svelte
97
+ npm install @intlayer/svelte-compiler
98
+ ```
99
+
100
+ ### Next.js (Babel)
101
+
102
+ Für Next.js oder andere Webpack-basierte Anwendungen, die Babel verwenden, können Sie den Compiler mit dem `@intlayer/babel` Plugin konfigurieren.
103
+
104
+ #### Installation
105
+
106
+ ```bash
107
+ npm install @intlayer/babel
108
+ ```
109
+
110
+ #### Konfiguration
111
+
112
+ Aktualisieren Sie Ihre `babel.config.js` (oder `babel.config.json`), um das Extraktions-Plugin einzubinden. Wir stellen einen Helfer `getExtractPluginOptions` bereit, der Ihre Intlayer-Konfiguration automatisch lädt.
113
+
114
+ ```js fileName="babel.config.js"
115
+ const {
116
+ intlayerExtractBabelPlugin,
117
+ intlayerOptimizeBabelPlugin,
118
+ getExtractPluginOptions,
119
+ getOptimizePluginOptions,
120
+ } = require("@intlayer/babel");
121
+
122
+ module.exports = {
123
+ presets: ["next/babel"],
124
+ plugins: [
125
+ // Extract content from components into dictionaries
126
+ [intlayerExtractBabelPlugin, getExtractPluginOptions()],
127
+ // Optimize imports by replacing useIntlayer with direct dictionary imports
128
+ [intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],
129
+ ],
130
+ };
131
+ ```
132
+
133
+ Diese Konfiguration stellt sicher, dass Inhalte, die in Ihren Komponenten deklariert sind, automatisch extrahiert und während Ihres Build-Prozesses zur Generierung von Wörterbüchern verwendet werden.
@@ -139,7 +139,7 @@ Das `vue-intlayer`-Paket wird verwendet, um Intlayer-Wörterbücher zu interpret
139
139
 
140
140
  Das `nuxt-intlayer`-Paket ist ein Nuxt-Modul, um Intlayer-Wörterbücher in Nuxt-Anwendungen nutzbar zu machen. Es integriert wesentliche Funktionen, damit Intlayer in einer Nuxt-Umgebung funktioniert, wie z. B. Übersetzungs-Middleware, Routing oder die Konfiguration der `nuxt.config.js`-Datei.
141
141
 
142
- ### svelte-intlayer (WIP)
142
+ ### svelte-intlayer
143
143
 
144
144
  Das `svelte-intlayer`-Paket wird verwendet, um Intlayer-Wörterbücher zu interpretieren und in Svelte-Anwendungen nutzbar zu machen.
145
145
 
@@ -42,6 +42,10 @@ Erweiterungslink: [https://marketplace.visualstudio.com/items?itemName=Intlayer.
42
42
 
43
43
  ## Funktionen
44
44
 
45
+ ![Inhalt extrahieren](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_extract_content.gif?raw=true)
46
+
47
+ - **Inhalt extrahieren** – Extrahieren Sie Inhalte aus Ihren React / Vue / Svelte Komponenten
48
+
45
49
  ![Wörterbücher füllen](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_fill_active_dictionary.gif?raw=true)
46
50
 
47
51
  - **Sofortige Navigation** – Schneller Sprung zur richtigen Inhaltsdatei beim Klicken auf einen `useIntlayer`-Schlüssel.
@@ -0,0 +1,184 @@
1
+ ---
2
+ createdAt: 2025-11-25
3
+ updatedAt: 2025-11-25
4
+ title: Optimizing i18n Bundle Size & Performance
5
+ description: Reduce application bundle size by optimizing internationalization (i18n) content. Learn how to leverage tree shaking and lazy loading for dictionaries with Intlayer.
6
+ keywords:
7
+ - Bundle Optimization
8
+ - Content Automation
9
+ - Dynamic Content
10
+ - Intlayer
11
+ - Next.js
12
+ - JavaScript
13
+ - React
14
+ slugs:
15
+ - doc
16
+ - concept
17
+ - bundle-optimization
18
+ history:
19
+ - version: 6.0.0
20
+ date: 2025-11-25
21
+ changes: Init history
22
+ ---
23
+
24
+ # Optimizing i18n Bundle Size & Performance
25
+
26
+ One of the most common challenges with traditional i18n solutions relying on JSON files is managing content size. If developers do not manually separate content into namespaces, users often end up downloading translations for every page and potentially every language just to view a single page.
27
+
28
+ For example, an application with 10 pages translated into 10 languages might result in a user downloading the content of 100 pages, even though they only need **one** (the current page in the current language). This leads to wasted bandwidth and slower load times.
29
+
30
+ > To detect it, you can use bundle analyzer like `rollup-plugin-visualizer` (vite), `@next/bundle-analyzer` (next.js), or `webpack-bundle-analyzer` (React CRA / Angular / etc).
31
+
32
+ **Intlayer solves this problem through build-time optimization.** It analyzes your code to detect which dictionaries are actually used per component and reinjects only the necessary content into your bundle.
33
+
34
+ ## Table of Contents
35
+
36
+ <TOC />
37
+
38
+ ## How It Works
39
+
40
+ Intlayer uses a **per-component approach**. Unlike global JSON files, your content is defined alongside or within your components. During the build process, Intlayer:
41
+
42
+ 1. **Analyzes** your code to find `useIntlayer` calls.
43
+ 2. **Builds** the corresponding dictionary content.
44
+ 3. **Replaces** the `useIntlayer` call with optimized code based on your configuration.
45
+
46
+ This ensures that:
47
+
48
+ - If a component is not imported, its content is not included in the bundle (Dead Code Elimination).
49
+ - If a component is lazy-loaded, its content is also lazy-loaded.
50
+
51
+ ## Setup by Platform
52
+
53
+ ### Next.js
54
+
55
+ Next.js requires the `@intlayer/swc` plugin to handle the transformation, as Next.js uses SWC for builds.
56
+
57
+ > This plugin is installed by default because SWC plugins are still experimental for Next.js. It may change in the future.
58
+
59
+ ### Vite
60
+
61
+ Vite uses `@intlayer/babel` plugin which is included as dependency of `vite-intlayer`. The optimization is enabled by default.
62
+
63
+ ### Webpack
64
+
65
+ To enable bundle optimization with Intlayer on Webpack, you need to install and configure the appropriate Babel (`@intlayer/babel`) or SWC (`@intlayer/swc`) plugin.
66
+
67
+ ### Expo / Lynx
68
+
69
+ Bundle optimization is **not available yet** for this platform. Support will be added in a future release.
70
+
71
+ ## Configuration
72
+
73
+ You can control how Intlayer optimizes your bundle via the `build` property in your `intlayer.config.ts`.
74
+
75
+ ```typescript fileName="intlayer.config.ts"
76
+ import { Locales, type IntlayerConfig } from "intlayer";
77
+
78
+ const config: IntlayerConfig = {
79
+ internationalization: {
80
+ locales: [Locales.ENGLISH, Locales.FRENCH],
81
+ defaultLocale: Locales.ENGLISH,
82
+ },
83
+ build: {
84
+ optimize: true,
85
+ importMode: "static", // or 'dynamic'
86
+ traversePattern: ["**/*.{js,ts,mjs,cjs,jsx,tsx}", "!**/node_modules/**"],
87
+ },
88
+ };
89
+
90
+ export default config;
91
+ ```
92
+
93
+ > Keeping the default option for `optimize` is recommended in the most majority of cases.
94
+
95
+ > See doc configuration for more details: [Configuration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md)
96
+
97
+ ### Build Options
98
+
99
+ The following options are available under the `build` configuration object:
100
+
101
+ | Property | Type | Default | Description |
102
+ | :-------------------- | :------------------------------ | :------------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | **`optimize`** | `boolean` | `undefined` | Controls whether build optimization is enabled. If `true`, Intlayer replaces dictionary calls with optimized injects. If `false`, optimization is disabled. Ideally set to `true` in production. |
104
+ | **`importMode`** | `'static' , 'dynamic' , 'live'` | `'static'` | Determines how dictionaries are loaded (see details below). |
105
+ | **`traversePattern`** | `string[]` | `['**/*.{js,ts,jsx,tsx}', ...]` | Glob patterns defining which files Intlayer should scan for optimization. Use this to exclude unrelated files and speed up builds. |
106
+ | **`outputFormat`** | `'esm', 'cjs'` | `'esm', 'cjs'` | Controls the output format of the built dictionaries. |
107
+
108
+ ## Import Modes
109
+
110
+ The `importMode` setting dictates how the dictionary content is injected into your component.
111
+
112
+ ### 1. Static Mode (`default`)
113
+
114
+ In static mode, Intlayer replaces `useIntlayer` with `useDictionary` and injects the dictionary directly into the JavaScript bundle.
115
+
116
+ - **Pros:** Instant rendering (synchronous), zero extra network requests during hydration.
117
+ - **Cons:** The bundle includes translations for **all** available languages for that specific component.
118
+ - **Best for:** Single Page Applications (SPA).
119
+
120
+ **Transformed Code Example:**
121
+
122
+ ```tsx
123
+ // Your code
124
+ const content = useIntlayer("my-key");
125
+
126
+ // Optimized code (Static)
127
+ const content = useDictionary({
128
+ key: "my-key",
129
+ content: {
130
+ nodeType: "translation",
131
+ translation: {
132
+ en: "My title",
133
+ fr: "Mon titre",
134
+ },
135
+ },
136
+ });
137
+ ```
138
+
139
+ ### 2. Dynamic Mode
140
+
141
+ In dynamic mode, Intlayer replaces `useIntlayer` with `useDictionaryAsync`. This uses `import()` (Suspense-like mechanism) to lazy-load specifically the JSON for the current locale.
142
+
143
+ - **Pros:** **Locale-level tree shaking.** A user viewing the English version will _only_ download the English dictionary. The French dictionary is never loaded.
144
+ - **Cons:** Triggers a network request (asset fetch) per component during hydration.
145
+ - **Best for:** Large text blocks, articles, or applications supporting many languages where bundle size is critical.
146
+
147
+ **Transformed Code Example:**
148
+
149
+ ```tsx
150
+ // Your code
151
+ const content = useIntlayer("my-key");
152
+
153
+ // Optimized code (Dynamic)
154
+ const content = useDictionaryAsync({
155
+ en: () =>
156
+ import(".intlayer/dynamic_dictionary/my-key/en.json").then(
157
+ (mod) => mod.default
158
+ ),
159
+ fr: () =>
160
+ import(".intlayer/dynamic_dictionary/my-key/fr.json").then(
161
+ (mod) => mod.default
162
+ ),
163
+ });
164
+ ```
165
+
166
+ > When using `importMode: 'dynamic'`, if you have 100 components using `useIntlayer` on a single page, the browser will attempt 100 separate fetches. To avoid this "waterfall" of requests, group content into fewer `.content` files (e.g., one dictionary per page section) rather than one per atom component.
167
+
168
+ > Currently, `importMode: 'dynamic'` is not fully supported for Vue and Svelte. It is recommended to use `importMode: 'static'` for these frameworks until further updates.
169
+
170
+ ### 3. Live Mode
171
+
172
+ Behaves similarly to Dynamic mode but attempts to fetch dictionaries from the Intlayer Live Sync API first. If the API call fails or the content is not marked for live updates, it falls back to the dynamic import.
173
+
174
+ > See CMS documentation for more details: [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md)
175
+
176
+ ## Summary: Static vs Dynamic
177
+
178
+ | Feature | Static Mode | Dynamic Mode |
179
+ | :------------------- | :-------------------------------------------- | :----------------------------------- |
180
+ | **JS Bundle Size** | Larger (includes all langs for the component) | Smallest (only code, no content) |
181
+ | **Initial Load** | Instant (Content is in bundle) | Slight delay (Fetches JSON) |
182
+ | **Network Requests** | 0 extra requests | 1 request per dictionary |
183
+ | **Tree Shaking** | Component-level | Component-level + Locale-level |
184
+ | **Best Use Case** | UI Components, Small Apps | Pages with much text, Many Languages |
@@ -0,0 +1,133 @@
1
+ ---
2
+ createdAt: 2025-09-09
3
+ updatedAt: 2025-09-09
4
+ title: Intlayer Compiler | Automated Content Extraction for i18n
5
+ description: Automate your internationalization process with the Intlayer Compiler. Extract content directly from your components for faster, more efficient i18n in Vite, Next.js, and more.
6
+ keywords:
7
+ - Intlayer
8
+ - Compiler
9
+ - Internationalization
10
+ - i18n
11
+ - Automation
12
+ - Extraction
13
+ - Speed
14
+ - Vite
15
+ - Next.js
16
+ - React
17
+ - Vue
18
+ - Svelte
19
+ slugs:
20
+ - doc
21
+ - compiler
22
+ history:
23
+ - version: 7.3.1
24
+ date: 2025-11-27
25
+ changes: Release Compiler
26
+ ---
27
+
28
+ # Intlayer Compiler | Automated Content Extraction for i18n
29
+
30
+ ## What is the Intlayer Compiler?
31
+
32
+ The **Intlayer Compiler** is a powerful tool designed to automate the process of internationalization (i18n) in your applications. It scans your source code (JSX, TSX, Vue, Svelte) for content declarations, extracts them, and automatically generates the necessary dictionary files. This allows you to keep your content co-located with your components while Intlayer handles the management and synchronization of your dictionaries.
33
+
34
+ ## Why Use the Intlayer Compiler?
35
+
36
+ - **Automation**: Eliminates manual copy-pasting of content into dictionaries.
37
+ - **Speed**: Optimized content extraction ensuring your build process remains fast.
38
+ - **Developer Experience**: Keep content declarations right where they are used, improving maintainability.
39
+ - **Live Updates**: Supports Hot Module Replacement (HMR) for instant feedback during development.
40
+
41
+ See the [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/compiler_vs_declarative_i18n.md) blog post for a deeper comparison.
42
+
43
+ ## Why not use the Intlayer Compiler?
44
+
45
+ While the compiler offers an excellent "just works" experience, it also introduces some trade-offs you should be aware of:
46
+
47
+ - **Heuristic ambiguity**: The compiler must guess what is user-facing content vs. application logic (e.g., `className="active"`, status codes, product IDs). In complex codebases, this can lead to false positives or missed strings that require manual annotations and exceptions.
48
+ - **Static-only extraction**: Compiler-based extraction relies on static analysis. Strings that only exist at runtime (API error codes, CMS fields, etc.) cannot be discovered or translated by the compiler alone, so you still need a complementary runtime i18n strategy.
49
+
50
+ For a deeper architectural comparison, see the blog post [Compiler vs. Declarative i18n](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/compiler_vs_declarative_i18n.md).
51
+
52
+ As an alternative, to automate your i18n process while keeping full control of your content, Intlayer also provides an auto-extraction command `intlayer transform` (see [CLI documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/transform.md)), or the `Intlayer: extract content to Dictionary` command from the Intlayer VS Code extension (see [VS Code extension documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/vs_code_extension.md)).
53
+
54
+ ## Usage
55
+
56
+ ### Vite
57
+
58
+ For Vite-based applications (React, Vue, Svelte, etc.), the easiest way to use the compiler is through the `vite-intlayer` plugin.
59
+
60
+ #### Installation
61
+
62
+ ```bash
63
+ npm install vite-intlayer
64
+ ```
65
+
66
+ #### Configuration
67
+
68
+ Update your `vite.config.ts` to include the `intlayerCompiler` plugin:
69
+
70
+ ```ts fileName="vite.config.ts"
71
+ import { defineConfig } from "vite";
72
+ import { intlayer, intlayerCompiler } from "vite-intlayer";
73
+
74
+ export default defineConfig({
75
+ plugins: [
76
+ intlayer(),
77
+ intlayerCompiler(), // Adds the compiler plugin
78
+ ],
79
+ });
80
+ ```
81
+
82
+ #### Framework Support
83
+
84
+ The Vite plugin automatically detects and handles different file types:
85
+
86
+ - **React / JSX / TSX**: Handled natively.
87
+ - **Vue**: Requires `@intlayer/vue-compiler`.
88
+ - **Svelte**: Requires `@intlayer/svelte-compiler`.
89
+
90
+ Make sure to install the appropriate compiler package for your framework:
91
+
92
+ ```bash
93
+ # For Vue
94
+ npm install @intlayer/vue-compiler
95
+
96
+ # For Svelte
97
+ npm install @intlayer/svelte-compiler
98
+ ```
99
+
100
+ ### Next.js (Babel)
101
+
102
+ For Next.js or other Webpack-based applications using Babel, you can configure the compiler using the `@intlayer/babel` plugin.
103
+
104
+ #### Installation
105
+
106
+ ```bash
107
+ npm install @intlayer/babel
108
+ ```
109
+
110
+ #### Configuration
111
+
112
+ Update your `babel.config.js` (or `babel.config.json`) to include the extraction plugin. We provide a helper `getExtractPluginOptions` to load your Intlayer configuration automatically.
113
+
114
+ ```js fileName="babel.config.js"
115
+ const {
116
+ intlayerExtractBabelPlugin,
117
+ intlayerOptimizeBabelPlugin,
118
+ getExtractPluginOptions,
119
+ getOptimizePluginOptions,
120
+ } = require("@intlayer/babel");
121
+
122
+ module.exports = {
123
+ presets: ["next/babel"],
124
+ plugins: [
125
+ // Extract content from components into dictionaries
126
+ [intlayerExtractBabelPlugin, getExtractPluginOptions()],
127
+ // Optimize imports by replacing useIntlayer with direct dictionary imports
128
+ [intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],
129
+ ],
130
+ };
131
+ ```
132
+
133
+ This configuration ensures that content declared in your components is automatically extracted and used to generate dictionaries during your build process.
@@ -654,6 +654,8 @@ Intlayer supports multiple AI providers for enhanced flexibility and choice. Cur
654
654
  - _Default_: None
655
655
  - _Description_: Provides additional context about your application to the AI model, helping it generate more accurate and contextually appropriate translations. This can include information about your app's domain, target audience, tone, or specific terminology.
656
656
 
657
+ > If you provide additional parameters, Intlayer will pass them to the AI model as context. It can be used to customize the reasoning effort, text verbosity, etc
658
+
657
659
  ### Build Configuration
658
660
 
659
661
  Settings that control how Intlayer optimizes and builds your application's internationalization.
@@ -668,9 +670,10 @@ Build options apply to the `@intlayer/babel` and `@intlayer/swc` plugins.
668
670
 
669
671
  - **optimize**:
670
672
  - _Type_: `boolean`
671
- - _Default_: `process.env.NODE_ENV === 'production'`
673
+ - _Default_: `undefined`
672
674
  - _Description_: Controls whether the build should be optimized.
673
- - _Example_: `true`
675
+ - _Example_: `process.env.NODE_ENV === 'production'`
676
+ - _Note_: By default, the build optimization is not fixed. If not set, Intlayer will trigger the build optimization on the build of your application (vite / nextjs / etc). Setting it to `true` will force the build optimization, including during dev mode. Setting it to `false` will disable the build optimization.
674
677
  - _Note_: When enabled, Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used. All imports will stay as static import to avoid async processing when loading the dictionaries.
675
678
  - _Note_: Intlayer will replace all calls of `useIntlayer` with the defined mode by the `importMode` option and `getIntlayer` with `getDictionary`.
676
679
  - _Note_: This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
@@ -146,7 +146,7 @@ The `vue-intlayer` package is used to interpret Intlayer dictionaries and make t
146
146
 
147
147
  The `nuxt-intlayer` package is as Nuxt module to make Intlayer dictionaries usable in Nuxt applications. It integrates essential features to make Intlayer work in a Nuxt environment, such as translation middleware, routing, or the `nuxt.config.js` file configuration.
148
148
 
149
- ### svelte-intlayer (WIP)
149
+ ### svelte-intlayer
150
150
 
151
151
  The `svelte-intlayer` package is used to interpret Intlayer dictionaries and make them usable in Svelte applications.
152
152
 
@@ -16,6 +16,9 @@ slugs:
16
16
  - doc
17
17
  - vs-code-extension
18
18
  history:
19
+ - version: 7.3.0
20
+ date: 2025-11-25
21
+ changes: Add extract content command
19
22
  - version: 6.1.5
20
23
  date: 2025-09-30
21
24
  changes: Add demo gif
@@ -42,6 +45,10 @@ Extension link: [https://marketplace.visualstudio.com/items?itemName=Intlayer.in
42
45
 
43
46
  ## Features
44
47
 
48
+ ![Extract content](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_extract_content.gif?raw=true)
49
+
50
+ - **Extract Content** – Extract content from your React / Vue / Svelte components
51
+
45
52
  ![Fill dictionaries](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_fill_active_dictionary.gif?raw=true)
46
53
 
47
54
  - **Instant Navigation** – Quickly jump to the correct content file when clicking on a `useIntlayer` key.