@intlayer/docs 7.3.0-canary.0 → 7.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 (53) hide show
  1. package/dist/cjs/generated/docs.entry.cjs +19 -0
  2. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  3. package/dist/esm/generated/docs.entry.mjs +19 -0
  4. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  5. package/dist/types/generated/docs.entry.d.ts +1 -0
  6. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  7. package/docs/ar/bundle_optimization.md +180 -0
  8. package/docs/ar/vs_code_extension.md +4 -0
  9. package/docs/de/bundle_optimization.md +190 -0
  10. package/docs/de/how_works_intlayer.md +1 -1
  11. package/docs/de/vs_code_extension.md +4 -0
  12. package/docs/en/bundle_optimization.md +180 -0
  13. package/docs/en/configuration.md +5 -2
  14. package/docs/en/how_works_intlayer.md +1 -1
  15. package/docs/en/vs_code_extension.md +7 -0
  16. package/docs/en-GB/bundle_optimization.md +180 -0
  17. package/docs/en-GB/how_works_intlayer.md +1 -1
  18. package/docs/en-GB/vs_code_extension.md +4 -0
  19. package/docs/es/bundle_optimization.md +190 -0
  20. package/docs/es/how_works_intlayer.md +1 -1
  21. package/docs/es/vs_code_extension.md +4 -0
  22. package/docs/fr/bundle_optimization.md +180 -0
  23. package/docs/fr/how_works_intlayer.md +1 -1
  24. package/docs/fr/vs_code_extension.md +4 -0
  25. package/docs/hi/bundle_optimization.md +180 -0
  26. package/docs/hi/vs_code_extension.md +4 -0
  27. package/docs/id/bundle_optimization.md +180 -0
  28. package/docs/id/how_works_intlayer.md +1 -1
  29. package/docs/id/vs_code_extension.md +4 -0
  30. package/docs/it/bundle_optimization.md +180 -0
  31. package/docs/it/how_works_intlayer.md +1 -1
  32. package/docs/it/vs_code_extension.md +4 -0
  33. package/docs/ja/bundle_optimization.md +180 -0
  34. package/docs/ja/vs_code_extension.md +4 -0
  35. package/docs/ko/bundle_optimization.md +180 -0
  36. package/docs/ko/vs_code_extension.md +4 -0
  37. package/docs/pl/bundle_optimization.md +180 -0
  38. package/docs/pl/how_works_intlayer.md +1 -1
  39. package/docs/pl/vs_code_extension.md +4 -0
  40. package/docs/pt/bundle_optimization.md +180 -0
  41. package/docs/pt/how_works_intlayer.md +1 -1
  42. package/docs/pt/vs_code_extension.md +4 -0
  43. package/docs/ru/bundle_optimization.md +180 -0
  44. package/docs/ru/vs_code_extension.md +4 -0
  45. package/docs/tr/bundle_optimization.md +180 -0
  46. package/docs/tr/how_works_intlayer.md +1 -1
  47. package/docs/tr/vs_code_extension.md +4 -0
  48. package/docs/vi/bundle_optimization.md +180 -0
  49. package/docs/vi/vs_code_extension.md +4 -0
  50. package/docs/zh/bundle_optimization.md +180 -0
  51. package/docs/zh/vs_code_extension.md +4 -0
  52. package/package.json +8 -8
  53. package/src/generated/docs.entry.ts +19 -0
@@ -141,7 +141,7 @@ Le package `vue-intlayer` est utilisé pour interpréter les dictionnaires Intla
141
141
 
142
142
  Le package `nuxt-intlayer` est un module Nuxt permettant de rendre les dictionnaires Intlayer utilisables dans les applications Nuxt. Il intègre des fonctionnalités essentielles pour faire fonctionner Intlayer dans un environnement Nuxt, telles que le middleware de traduction, le routage ou la configuration du fichier `nuxt.config.js`.
143
143
 
144
- ### svelte-intlayer (WIP)
144
+ ### svelte-intlayer
145
145
 
146
146
  Le package `svelte-intlayer` est utilisé pour interpréter les dictionnaires Intlayer et les rendre utilisables dans les applications Svelte.
147
147
 
@@ -42,6 +42,10 @@ Lien de l'extension : [https://marketplace.visualstudio.com/items?itemName=Intla
42
42
 
43
43
  ## Fonctionnalités
44
44
 
45
+ ![Extraire le contenu](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_extract_content.gif?raw=true)
46
+
47
+ - **Extraire le contenu** – Extrayez le contenu de vos composants React / Vue / Svelte
48
+
45
49
  ![Remplir les dictionnaires](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_fill_active_dictionary.gif?raw=true)
46
50
 
47
51
  - **Navigation instantanée** – Accédez rapidement au fichier de contenu correct en cliquant sur une clé `useIntlayer`.
@@ -0,0 +1,180 @@
1
+ ---
2
+ createdAt: 2025-11-25
3
+ updatedAt: 2025-11-25
4
+ title: i18n बंडल आकार और प्रदर्शन का अनुकूलन
5
+ description: अंतर्राष्ट्रीयकरण (i18n) सामग्री को अनुकूलित करके एप्लिकेशन बंडल आकार को कम करें। Intlayer के साथ शब्दकोशों के लिए ट्री शेकिंग और लेज़ी लोडिंग का लाभ उठाना सीखें।
6
+ keywords:
7
+ - बंडल अनुकूलन
8
+ - सामग्री स्वचालन
9
+ - गतिशील सामग्री
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
+ # i18n बंडल आकार और प्रदर्शन का अनुकूलन
25
+
26
+ JSON फ़ाइलों पर निर्भर पारंपरिक i18n समाधानों के साथ सबसे आम चुनौतियों में से एक सामग्री के आकार का प्रबंधन है। यदि डेवलपर्स सामग्री को मैन्युअल रूप से namespaces में विभाजित नहीं करते हैं, तो उपयोगकर्ता अक्सर केवल एक पृष्ठ देखने के लिए हर पृष्ठ और संभावित रूप से हर भाषा के अनुवाद डाउनलोड कर लेते हैं।
27
+
28
+ उदाहरण के लिए, 10 पृष्ठों वाले एक एप्लिकेशन के 10 भाषाओं में अनुवादित होने पर उपयोगकर्ता 100 पृष्ठों की सामग्री डाउनलोड कर सकता है, जबकि उसे केवल **एक** (वर्तमान पृष्ठ वर्तमान भाषा में) की आवश्यकता होती है। इससे बैंडविड्थ की बर्बादी होती है और लोड समय धीमा हो जाता है।
29
+
30
+ > इसे पता लगाने के लिए, आप `rollup-plugin-visualizer` (vite), `@next/bundle-analyzer` (next.js), या `webpack-bundle-analyzer` (React CRA / Angular / आदि) जैसे बंडल विश्लेषक का उपयोग कर सकते हैं।
31
+
32
+ **Intlayer इस समस्या को build-time optimization के माध्यम से हल करता है।** यह आपके कोड का विश्लेषण करता है ताकि पता लगाया जा सके कि कौन से डिक्शनरी वास्तव में प्रत्येक कंपोनेंट में उपयोग किए जाते हैं और केवल आवश्यक सामग्री को आपके बंडल में पुनः सम्मिलित करता है।
33
+
34
+ ## विषय सूची
35
+
36
+ <TOC />
37
+
38
+ ## यह कैसे काम करता है
39
+
40
+ Intlayer एक **प्रति-कंपोनेंट दृष्टिकोण** का उपयोग करता है। वैश्विक JSON फ़ाइलों के विपरीत, आपकी सामग्री आपके कंपोनेंट्स के साथ या उनके भीतर परिभाषित होती है। बिल्ड प्रक्रिया के दौरान, Intlayer:
41
+
42
+ 1. आपके कोड का **विश्लेषण** करता है ताकि `useIntlayer` कॉल्स को खोज सके।
43
+ 2. संबंधित डिक्शनरी सामग्री का **निर्माण** करता है।
44
+ 3. आपकी कॉन्फ़िगरेशन के आधार पर `useIntlayer` कॉल को अनुकूलित कोड से **प्रतिस्थापित** करता है।
45
+
46
+ यह सुनिश्चित करता है कि:
47
+
48
+ - यदि कोई कंपोनेंट आयातित नहीं है, तो उसकी सामग्री बंडल में शामिल नहीं की जाती (Dead Code Elimination)।
49
+ - यदि कोई कंपोनेंट lazy-loaded है, तो उसकी सामग्री भी lazy-loaded होती है।
50
+
51
+ ## प्लेटफ़ॉर्म द्वारा सेटअप
52
+
53
+ ### Next.js
54
+
55
+ Next.js को ट्रांसफ़ॉर्मेशन को संभालने के लिए `@intlayer/swc` प्लगइन की आवश्यकता होती है, क्योंकि Next.js बिल्ड के लिए SWC का उपयोग करता है।
56
+
57
+ > यह प्लगइन डिफ़ॉल्ट रूप से इंस्टॉल होता है क्योंकि SWC प्लगइन्स अभी भी Next.js के लिए प्रायोगिक हैं। भविष्य में इसमें बदलाव हो सकता है।
58
+
59
+ ### Vite
60
+
61
+ Vite `@intlayer/babel` प्लगइन का उपयोग करता है जो `vite-intlayer` की निर्भरता के रूप में शामिल है। अनुकूलन डिफ़ॉल्ट रूप से सक्षम है।
62
+
63
+ ### Webpack
64
+
65
+ Webpack पर Intlayer के साथ बंडल अनुकूलन सक्षम करने के लिए, आपको उपयुक्त Babel (`@intlayer/babel`) या SWC (`@intlayer/swc`) प्लगइन को इंस्टॉल और कॉन्फ़िगर करना होगा।
66
+
67
+ ### Expo / Lynx
68
+
69
+ इस प्लेटफ़ॉर्म के लिए बंडल अनुकूलन **अभी उपलब्ध नहीं है**। समर्थन भविष्य के रिलीज़ में जोड़ा जाएगा।
70
+
71
+ ## कॉन्फ़िगरेशन
72
+
73
+ आप अपने `intlayer.config.ts` में `build` प्रॉपर्टी के माध्यम से नियंत्रित कर सकते हैं कि Intlayer आपके बंडल को कैसे अनुकूलित करता है।
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", // या 'dynamic'
86
+ traversePattern: ["**/*.{js,ts,mjs,cjs,jsx,tsx}", "!**/node_modules/**"],
87
+ },
88
+ };
89
+
90
+ export default config;
91
+ ```
92
+
93
+ > अधिकांश मामलों में `optimize` के लिए डिफ़ॉल्ट विकल्प रखना अनुशंसित है।
94
+
95
+ > अधिक विवरण के लिए डॉक्यूमेंटेशन कॉन्फ़िगरेशन देखें: [Configuration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/configuration.md)
96
+
97
+ ### बिल्ड विकल्प
98
+
99
+ `build` कॉन्फ़िगरेशन ऑब्जेक्ट के तहत निम्नलिखित विकल्प उपलब्ध हैं:
100
+
101
+ | प्रॉपर्टी | प्रकार | डिफ़ॉल्ट | विवरण |
102
+ | :-------------------- | :------------------------------ | :------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | **`optimize`** | `boolean` | `undefined` | नियंत्रित करता है कि बिल्ड ऑप्टिमाइज़ेशन सक्षम है या नहीं। यदि `true` है, तो Intlayer डिक्शनरी कॉल्स को ऑप्टिमाइज़्ड इंजेक्ट्स से बदल देता है। यदि `false` है, तो ऑप्टिमाइज़ेशन अक्षम होता है। आदर्श रूप से उत्पादन में इसे `true` पर सेट किया जाना चाहिए। |
104
+ | **`importMode`** | `'static' , 'dynamic' , 'live'` | `'static'` | यह निर्धारित करता है कि डिक्शनरी कैसे लोड की जाती हैं (नीचे विवरण देखें)। |
105
+ | **`traversePattern`** | `string[]` | `['**/*.{js,ts,jsx,tsx}', ...]` | ग्लोब पैटर्न जो परिभाषित करते हैं कि Intlayer किन फाइलों को ऑप्टिमाइज़ेशन के लिए स्कैन करेगा। इसका उपयोग अप्रासंगिक फाइलों को बाहर करने और बिल्ड को तेज़ करने के लिए करें। |
106
+ | **`outputFormat`** | `'esm', 'cjs'` | `'esm', 'cjs'` | निर्मित डिक्शनरी के आउटपुट फॉर्मेट को नियंत्रित करता है। |
107
+
108
+ ## इम्पोर्ट मोड्स
109
+
110
+ `importMode` सेटिंग यह निर्धारित करती है कि डिक्शनरी सामग्री आपके कंपोनेंट में कैसे इंजेक्ट की जाती है।
111
+
112
+ ### 1. स्टैटिक मोड (`default`)
113
+
114
+ स्थैतिक मोड में, Intlayer `useIntlayer` को `useDictionary` से बदल देता है और डिक्शनरी को सीधे JavaScript बंडल में इंजेक्ट करता है।
115
+
116
+ - **फायदे:** त्वरित रेंडरिंग (सिंक्रोनस), हाइड्रेशन के दौरान कोई अतिरिक्त नेटवर्क अनुरोध नहीं।
117
+ - **नुकसान:** बंडल में उस विशिष्ट कंपोनेंट के लिए **सभी** उपलब्ध भाषाओं के अनुवाद शामिल होते हैं।
118
+ - **सबसे अच्छा:** सिंगल पेज एप्लिकेशन (SPA) के लिए।
119
+
120
+ **परिवर्तित कोड उदाहरण:**
121
+
122
+ ```tsx
123
+ // आपका कोड
124
+ const content = useIntlayer("my-key");
125
+
126
+ // ऑप्टिमाइज़्ड कोड (स्थैतिक)
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. डायनेमिक मोड
140
+
141
+ डायनामिक मोड में, Intlayer `useIntlayer` को `useDictionaryAsync` से बदल देता है। यह `import()` (Suspense-जैसे तंत्र) का उपयोग करता है ताकि वर्तमान लोकल के लिए JSON को लेज़ी-लोड किया जा सके।
142
+
143
+ - **फायदे:** **लोकल-स्तर पर ट्री शेकिंग।** अंग्रेज़ी संस्करण देखने वाला उपयोगकर्ता केवल अंग्रेज़ी डिक्शनरी डाउनलोड करेगा। फ्रेंच डिक्शनरी कभी लोड नहीं होती।
144
+ - **नुकसान:** हाइड्रेशन के दौरान प्रत्येक कंपोनेंट के लिए एक नेटवर्क अनुरोध (एसेट फेच) ट्रिगर होता है।
145
+ - **सबसे अच्छा:** बड़े टेक्स्ट ब्लॉक्स, लेख, या कई भाषाओं का समर्थन करने वाले एप्लिकेशन जहां बंडल का आकार महत्वपूर्ण हो।
146
+
147
+ **परिवर्तित कोड उदाहरण:**
148
+
149
+ ```tsx
150
+ // आपका कोड
151
+ const content = useIntlayer("my-key");
152
+
153
+ // अनुकूलित कोड (डायनामिक)
154
+ const content = useDictionaryAsync({
155
+ en: () =>
156
+ import(".intlayer/dynamic_dictionary/en.json").then((mod) => mod.default),
157
+ fr: () =>
158
+ import(".intlayer/dynamic_dictionary/fr.json").then((mod) => mod.default),
159
+ });
160
+ ```
161
+
162
+ > जब `importMode: 'dynamic'` का उपयोग किया जाता है, यदि आपके पास एक पेज पर 100 कंपोनेंट्स हैं जो `useIntlayer` का उपयोग करते हैं, तो ब्राउज़र 100 अलग-अलग फेच करने का प्रयास करेगा। इस "वाटरफॉल" अनुरोधों से बचने के लिए, सामग्री को कम `.content` फाइलों में समूहित करें (जैसे, पेज सेक्शन के लिए एक डिक्शनरी) बजाय कि प्रत्येक एटम कंपोनेंट के लिए एक।
163
+
164
+ > वर्तमान में, `importMode: 'dynamic'` Vue और Svelte के लिए पूरी तरह से समर्थित नहीं है। इन फ्रेमवर्क्स के लिए आगे के अपडेट तक `importMode: 'static'` का उपयोग करने की सलाह दी जाती है।
165
+
166
+ ### 3. लाइव मोड
167
+
168
+ डायनामिक मोड के समान व्यवहार करता है लेकिन पहले Intlayer लाइव सिंक API से शब्दकोश प्राप्त करने का प्रयास करता है। यदि API कॉल विफल हो जाती है या सामग्री लाइव अपडेट के लिए चिह्नित नहीं है, तो यह डायनामिक इम्पोर्ट पर वापस चला जाता है।
169
+
170
+ > अधिक जानकारी के लिए CMS दस्तावेज़ देखें: [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_CMS.md)
171
+
172
+ ## सारांश: स्टैटिक बनाम डायनामिक
173
+
174
+ | फीचर | स्टैटिक मोड | डायनामिक मोड |
175
+ | :------------------------ | :------------------------------------------------- | :------------------------------------- |
176
+ | **JS बंडल आकार** | बड़ा (कंपोनेंट के लिए सभी भाषाओं को शामिल करता है) | सबसे छोटा (केवल कोड, कोई सामग्री नहीं) |
177
+ | **प्रारंभिक लोड** | त्वरित (सामग्री बंडल में है) | थोड़ा विलंब (JSON प्राप्त करता है) |
178
+ | **नेटवर्क अनुरोध** | 0 अतिरिक्त अनुरोध | प्रति शब्दकोश 1 अनुरोध |
179
+ | **ट्री शेकिंग** | कंपोनेंट-स्तर | कंपोनेंट-स्तर + लोकल-स्तर |
180
+ | **सर्वोत्तम उपयोग मामला** | UI कंपोनेंट्स, छोटे ऐप्स | बहुत सारे टेक्स्ट वाले पेज, कई भाषाएँ |
@@ -42,6 +42,10 @@ history:
42
42
 
43
43
  ## विशेषताएँ
44
44
 
45
+ ![सामग्री निकालें](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_extract_content.gif?raw=true)
46
+
47
+ - **सामग्री निकालें** – अपने React / Vue / Svelte घटकों से सामग्री निकालें
48
+
45
49
  ![शब्दकोश भरें](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_fill_active_dictionary.gif?raw=true)
46
50
 
47
51
  - **तत्काल नेविगेशन** – `useIntlayer` कुंजी पर क्लिक करने पर सही सामग्री फ़ाइल पर तेजी से जाएं।
@@ -0,0 +1,180 @@
1
+ ---
2
+ createdAt: 2025-11-25
3
+ updatedAt: 2025-11-25
4
+ title: Mengoptimalkan Ukuran & Performa Bundle i18n
5
+ description: Mengurangi ukuran bundle aplikasi dengan mengoptimalkan konten internasionalisasi (i18n). Pelajari cara memanfaatkan tree shaking dan lazy loading untuk kamus dengan Intlayer.
6
+ keywords:
7
+ - Optimasi Bundle
8
+ - Otomasi Konten
9
+ - Konten Dinamis
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: Inisialisasi riwayat
22
+ ---
23
+
24
+ # Mengoptimalkan Ukuran & Performa Bundle i18n
25
+
26
+ Salah satu tantangan paling umum dengan solusi i18n tradisional yang mengandalkan file JSON adalah mengelola ukuran konten. Jika pengembang tidak secara manual memisahkan konten ke dalam namespace, pengguna sering kali harus mengunduh terjemahan untuk setiap halaman dan berpotensi setiap bahasa hanya untuk melihat satu halaman saja.
27
+
28
+ Misalnya, sebuah aplikasi dengan 10 halaman yang diterjemahkan ke dalam 10 bahasa mungkin mengakibatkan pengguna mengunduh konten dari 100 halaman, meskipun mereka hanya membutuhkan **satu** (halaman saat ini dalam bahasa saat ini). Hal ini menyebabkan pemborosan bandwidth dan waktu muat yang lebih lambat.
29
+
30
+ > Untuk mendeteksinya, Anda dapat menggunakan bundle analyzer seperti `rollup-plugin-visualizer` (vite), `@next/bundle-analyzer` (next.js), atau `webpack-bundle-analyzer` (React CRA / Angular / dll).
31
+
32
+ **Intlayer menyelesaikan masalah ini melalui optimasi saat build.** Intlayer menganalisis kode Anda untuk mendeteksi kamus mana yang benar-benar digunakan per komponen dan hanya menyuntikkan kembali konten yang diperlukan ke dalam bundle Anda.
33
+
34
+ ## Daftar Isi
35
+
36
+ <TOC />
37
+
38
+ ## Cara Kerjanya
39
+
40
+ Intlayer menggunakan **pendekatan per-komponen**. Berbeda dengan file JSON global, konten Anda didefinisikan berdampingan atau di dalam komponen Anda. Selama proses build, Intlayer:
41
+
42
+ 1. **Menganalisis** kode Anda untuk menemukan panggilan `useIntlayer`.
43
+ 2. **Membangun** konten kamus yang sesuai.
44
+ 3. **Mengganti** panggilan `useIntlayer` dengan kode yang dioptimalkan berdasarkan konfigurasi Anda.
45
+
46
+ Ini memastikan bahwa:
47
+
48
+ - Jika sebuah komponen tidak diimpor, kontennya tidak disertakan dalam bundle (Eliminasi Kode Mati).
49
+ - Jika sebuah komponen dimuat secara lazy, kontennya juga dimuat secara lazy.
50
+
51
+ ## Setup berdasarkan Platform
52
+
53
+ ### Next.js
54
+
55
+ Next.js memerlukan plugin `@intlayer/swc` untuk menangani transformasi, karena Next.js menggunakan SWC untuk proses build.
56
+
57
+ > Plugin ini terpasang secara default karena plugin SWC masih bersifat eksperimental untuk Next.js. Hal ini mungkin akan berubah di masa depan.
58
+
59
+ ### Vite
60
+
61
+ Vite menggunakan plugin `@intlayer/babel` yang sudah termasuk sebagai dependensi dari `vite-intlayer`. Optimasi ini diaktifkan secara default.
62
+
63
+ ### Webpack
64
+
65
+ Untuk mengaktifkan optimasi bundle dengan Intlayer pada Webpack, Anda perlu menginstal dan mengonfigurasi plugin Babel (`@intlayer/babel`) atau SWC (`@intlayer/swc`) yang sesuai.
66
+
67
+ ### Expo / Lynx
68
+
69
+ Optimasi bundle **belum tersedia** untuk platform ini. Dukungan akan ditambahkan pada rilis mendatang.
70
+
71
+ ## Konfigurasi
72
+
73
+ Anda dapat mengontrol bagaimana Intlayer mengoptimalkan bundle Anda melalui properti `build` di dalam `intlayer.config.ts` Anda.
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", // atau 'dynamic'
86
+ traversePattern: ["**/*.{js,ts,mjs,cjs,jsx,tsx}", "!**/node_modules/**"],
87
+ },
88
+ };
89
+
90
+ export default config;
91
+ ```
92
+
93
+ > Menjaga opsi default untuk `optimize` direkomendasikan dalam sebagian besar kasus.
94
+
95
+ > Lihat dokumentasi konfigurasi untuk detail lebih lanjut: [Configuration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md)
96
+
97
+ ### Opsi Build
98
+
99
+ Opsi berikut tersedia di bawah objek konfigurasi `build`:
100
+
101
+ | Properti | Tipe | Default | Deskripsi |
102
+ | :-------------------- | :------------------------------ | :------------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | **`optimize`** | `boolean` | `undefined` | Mengontrol apakah optimasi build diaktifkan. Jika `true`, Intlayer menggantikan pemanggilan kamus dengan injeksi yang dioptimalkan. Jika `false`, optimasi dinonaktifkan. Idealnya diatur ke `true` pada produksi. |
104
+ | **`importMode`** | `'static' , 'dynamic' , 'live'` | `'static'` | Menentukan bagaimana kamus dimuat (lihat detail di bawah). |
105
+ | **`traversePattern`** | `string[]` | `['**/*.{js,ts,jsx,tsx}', ...]` | Pola glob yang menentukan file mana yang harus dipindai oleh Intlayer untuk optimasi. Gunakan ini untuk mengecualikan file yang tidak terkait dan mempercepat proses build. |
106
+ | **`outputFormat`** | `'esm', 'cjs'` | `'esm', 'cjs'` | Mengontrol format output dari kamus yang dibangun. |
107
+
108
+ ## Mode Impor
109
+
110
+ Pengaturan `importMode` menentukan bagaimana konten kamus disuntikkan ke dalam komponen Anda.
111
+
112
+ ### 1. Mode Statis (`default`)
113
+
114
+ Dalam mode statis, Intlayer menggantikan `useIntlayer` dengan `useDictionary` dan menyuntikkan kamus langsung ke dalam bundle JavaScript.
115
+
116
+ - **Kelebihan:** Rendering instan (sinkron), tanpa permintaan jaringan tambahan selama hidrasi.
117
+ - **Kekurangan:** Bundle menyertakan terjemahan untuk **semua** bahasa yang tersedia untuk komponen tersebut.
118
+ - **Cocok untuk:** Single Page Applications (SPA).
119
+
120
+ **Contoh Kode yang Dioptimalkan:**
121
+
122
+ ```tsx
123
+ // Kode Anda
124
+ const content = useIntlayer("my-key");
125
+
126
+ // Kode yang Dioptimalkan (Statis)
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. Mode Dinamis
140
+
141
+ Dalam mode dinamis, Intlayer menggantikan `useIntlayer` dengan `useDictionaryAsync`. Ini menggunakan `import()` (mekanisme mirip Suspense) untuk memuat malas secara spesifik JSON untuk locale saat ini.
142
+
143
+ - **Kelebihan:** **Tree shaking tingkat locale.** Pengguna yang melihat versi bahasa Inggris akan _hanya_ mengunduh kamus bahasa Inggris. Kamus bahasa Prancis tidak pernah dimuat.
144
+ - **Kekurangan:** Memicu permintaan jaringan (pengambilan aset) per komponen selama hidrasi.
145
+ - **Terbaik untuk:** Blok teks besar, artikel, atau aplikasi yang mendukung banyak bahasa di mana ukuran bundle sangat penting.
146
+
147
+ **Contoh Kode yang Dioptimalkan:**
148
+
149
+ ```tsx
150
+ // Kode Anda
151
+ const content = useIntlayer("my-key");
152
+
153
+ // Kode yang Dioptimalkan (Dinamis)
154
+ const content = useDictionaryAsync({
155
+ en: () =>
156
+ import(".intlayer/dynamic_dictionary/en.json").then((mod) => mod.default),
157
+ fr: () =>
158
+ import(".intlayer/dynamic_dictionary/fr.json").then((mod) => mod.default),
159
+ });
160
+ ```
161
+
162
+ > Saat menggunakan `importMode: 'dynamic'`, jika Anda memiliki 100 komponen yang menggunakan `useIntlayer` pada satu halaman, browser akan mencoba melakukan 100 pengambilan terpisah. Untuk menghindari "air terjun" permintaan ini, kelompokkan konten ke dalam lebih sedikit file `.content` (misalnya, satu kamus per bagian halaman) daripada satu per komponen atom.
163
+
164
+ > Saat ini, `importMode: 'dynamic'` belum sepenuhnya didukung untuk Vue dan Svelte. Disarankan menggunakan `importMode: 'static'` untuk framework ini sampai pembaruan lebih lanjut.
165
+
166
+ ### 3. Mode Live
167
+
168
+ Berperilaku mirip dengan mode Dynamic tetapi mencoba mengambil kamus dari Intlayer Live Sync API terlebih dahulu. Jika panggilan API gagal atau konten tidak ditandai untuk pembaruan langsung, maka akan kembali ke impor dinamis.
169
+
170
+ > Lihat dokumentasi CMS untuk detail lebih lanjut: [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_CMS.md)
171
+
172
+ ## Ringkasan: Static vs Dynamic
173
+
174
+ | Fitur | Mode Static | Mode Dynamic |
175
+ | :------------------- | :------------------------------------------------- | :---------------------------------------- |
176
+ | **Ukuran Bundle JS** | Lebih besar (termasuk semua bahasa untuk komponen) | Paling kecil (hanya kode, tanpa konten) |
177
+ | **Initial Load** | Instan (Konten ada dalam bundle) | Sedikit penundaan (Mengambil JSON) |
178
+ | **Network Requests** | 0 permintaan tambahan | 1 permintaan per kamus |
179
+ | **Tree Shaking** | Tingkat komponen | Tingkat komponen + tingkat lokal |
180
+ | **Best Use Case** | Komponen UI, Aplikasi kecil | Halaman dengan banyak teks, Banyak Bahasa |
@@ -146,7 +146,7 @@ Paket `vue-intlayer` digunakan untuk menginterpretasikan kamus Intlayer dan memb
146
146
 
147
147
  Paket `nuxt-intlayer` adalah modul Nuxt untuk membuat kamus Intlayer dapat digunakan dalam aplikasi Nuxt. Paket ini mengintegrasikan fitur-fitur penting agar Intlayer dapat bekerja di lingkungan Nuxt, seperti middleware terjemahan, routing, atau konfigurasi file `nuxt.config.js`.
148
148
 
149
- ### svelte-intlayer (WIP)
149
+ ### svelte-intlayer
150
150
 
151
151
  Paket `svelte-intlayer` digunakan untuk menginterpretasikan kamus Intlayer dan membuatnya dapat digunakan dalam aplikasi Svelte.
152
152
 
@@ -42,6 +42,10 @@ Tautan ekstensi: [https://marketplace.visualstudio.com/items?itemName=Intlayer.i
42
42
 
43
43
  ## Fitur
44
44
 
45
+ ![Ekstrak konten](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_extract_content.gif?raw=true)
46
+
47
+ - **Ekstrak Konten** – Ekstrak konten dari komponen React / Vue / Svelte Anda
48
+
45
49
  ![Isi kamus](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_fill_active_dictionary.gif?raw=true)
46
50
 
47
51
  - **Navigasi Instan** – Melompat dengan cepat ke file konten yang benar saat mengklik kunci `useIntlayer`.
@@ -0,0 +1,180 @@
1
+ ---
2
+ createdAt: 2025-11-25
3
+ updatedAt: 2025-11-25
4
+ title: Ottimizzazione della Dimensione e delle Prestazioni del Bundle i18n
5
+ description: Riduci la dimensione del bundle dell'applicazione ottimizzando i contenuti di internazionalizzazione (i18n). Scopri come sfruttare il tree shaking e il lazy loading per i dizionari con Intlayer.
6
+ keywords:
7
+ - Ottimizzazione del Bundle
8
+ - Automazione dei Contenuti
9
+ - Contenuti Dinamici
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: Inizializzazione della cronologia
22
+ ---
23
+
24
+ # Ottimizzazione della Dimensione e delle Prestazioni del Bundle i18n
25
+
26
+ Una delle sfide più comuni con le soluzioni i18n tradizionali basate su file JSON è la gestione della dimensione dei contenuti. Se gli sviluppatori non separano manualmente i contenuti in namespace, gli utenti spesso finiscono per scaricare le traduzioni di ogni pagina e potenzialmente di ogni lingua solo per visualizzare una singola pagina.
27
+
28
+ Ad esempio, un'applicazione con 10 pagine tradotte in 10 lingue potrebbe far sì che un utente scarichi il contenuto di 100 pagine, anche se ha bisogno solo di **una** (la pagina corrente nella lingua corrente). Questo comporta uno spreco di banda e tempi di caricamento più lenti.
29
+
30
+ > Per rilevarlo, puoi utilizzare un bundle analyzer come `rollup-plugin-visualizer` (vite), `@next/bundle-analyzer` (next.js) o `webpack-bundle-analyzer` (React CRA / Angular / ecc).
31
+
32
+ **Intlayer risolve questo problema attraverso l'ottimizzazione in fase di build.** Analizza il tuo codice per rilevare quali dizionari sono effettivamente utilizzati per ogni componente e reinserisce solo il contenuto necessario nel tuo bundle.
33
+
34
+ ## Indice
35
+
36
+ <TOC />
37
+
38
+ ## Come Funziona
39
+
40
+ Intlayer utilizza un **approccio per componente**. A differenza dei file JSON globali, il tuo contenuto è definito accanto o all'interno dei tuoi componenti. Durante il processo di build, Intlayer:
41
+
42
+ 1. **Analizza** il tuo codice per trovare le chiamate a `useIntlayer`.
43
+ 2. **Costruisce** il contenuto del dizionario corrispondente.
44
+ 3. **Sostituisce** la chiamata a `useIntlayer` con codice ottimizzato basato sulla tua configurazione.
45
+
46
+ Questo garantisce che:
47
+
48
+ - Se un componente non è importato, il suo contenuto non viene incluso nel bundle (Eliminazione del codice morto).
49
+ - Se un componente è caricato in modo lazy, anche il suo contenuto viene caricato in modo lazy.
50
+
51
+ ## Configurazione per Piattaforma
52
+
53
+ ### Next.js
54
+
55
+ Next.js richiede il plugin `@intlayer/swc` per gestire la trasformazione, poiché Next.js utilizza SWC per le build.
56
+
57
+ > Questo plugin è installato di default perché i plugin SWC sono ancora sperimentali per Next.js. Potrebbe cambiare in futuro.
58
+
59
+ ### Vite
60
+
61
+ Vite utilizza il plugin `@intlayer/babel` che è incluso come dipendenza di `vite-intlayer`. L'ottimizzazione è abilitata di default.
62
+
63
+ ### Webpack
64
+
65
+ Per abilitare l'ottimizzazione del bundle con Intlayer su Webpack, è necessario installare e configurare il plugin Babel (`@intlayer/babel`) o SWC (`@intlayer/swc`) appropriato.
66
+
67
+ ### Expo / Lynx
68
+
69
+ L'ottimizzazione del bundle **non è ancora disponibile** per questa piattaforma. Il supporto sarà aggiunto in una futura release.
70
+
71
+ ## Configurazione
72
+
73
+ Puoi controllare come Intlayer ottimizza il tuo bundle tramite la proprietà `build` nel tuo file `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", // oppure 'dynamic'
86
+ traversePattern: ["**/*.{js,ts,mjs,cjs,jsx,tsx}", "!**/node_modules/**"],
87
+ },
88
+ };
89
+
90
+ export default config;
91
+ ```
92
+
93
+ > È consigliato mantenere l'opzione di default per `optimize` nella maggior parte dei casi.
94
+
95
+ > Consulta la documentazione per maggiori dettagli: [Configurazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/configuration.md)
96
+
97
+ ### Opzioni di Build
98
+
99
+ Le seguenti opzioni sono disponibili sotto l'oggetto di configurazione `build`:
100
+
101
+ | Proprietà | Tipo | Predefinito | Descrizione |
102
+ | :-------------------- | :------------------------------ | :------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | **`optimize`** | `boolean` | `undefined` | Controlla se l'ottimizzazione della build è abilitata. Se `true`, Intlayer sostituisce le chiamate al dizionario con inject ottimizzati. Se `false`, l'ottimizzazione è disabilitata. Idealmente impostato a `true` in produzione. |
104
+ | **`importMode`** | `'static' , 'dynamic' , 'live'` | `'static'` | Determina come vengono caricati i dizionari (vedi dettagli sotto). |
105
+ | **`traversePattern`** | `string[]` | `['**/*.{js,ts,jsx,tsx}', ...]` | Pattern glob che definiscono quali file Intlayer deve scansionare per l'ottimizzazione. Usalo per escludere file non correlati e velocizzare le build. |
106
+ | **`outputFormat`** | `'esm', 'cjs'` | `'esm', 'cjs'` | Controlla il formato di output dei dizionari costruiti. |
107
+
108
+ ## Modalità di Importazione
109
+
110
+ L'impostazione `importMode` determina come il contenuto del dizionario viene iniettato nel tuo componente.
111
+
112
+ ### 1. Modalità Statica (`default`)
113
+
114
+ In modalità statica, Intlayer sostituisce `useIntlayer` con `useDictionary` e inietta il dizionario direttamente nel bundle JavaScript.
115
+
116
+ - **Vantaggi:** Rendering istantaneo (sincrono), nessuna richiesta di rete aggiuntiva durante l'hydration.
117
+ - **Svantaggi:** Il bundle include le traduzioni per **tutte** le lingue disponibili per quel componente specifico.
118
+ - **Ideale per:** Single Page Applications (SPA).
119
+
120
+ **Esempio di codice trasformato:**
121
+
122
+ ```tsx
123
+ // Il tuo codice
124
+ const content = useIntlayer("my-key");
125
+
126
+ // Codice ottimizzato (Statico)
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. Modalità Dinamica
140
+
141
+ In modalità dinamica, Intlayer sostituisce `useIntlayer` con `useDictionaryAsync`. Questo utilizza `import()` (meccanismo simile a Suspense) per caricare pigramente specificamente il JSON per la locale corrente.
142
+
143
+ - **Vantaggi:** **Tree shaking a livello di locale.** Un utente che visualizza la versione inglese scaricherà _solo_ il dizionario inglese. Il dizionario francese non viene mai caricato.
144
+ - **Svantaggi:** Genera una richiesta di rete (fetch dell'asset) per ogni componente durante l'hydration.
145
+ - **Ideale per:** Blocchi di testo grandi, articoli o applicazioni che supportano molte lingue dove la dimensione del bundle è critica.
146
+
147
+ **Esempio di codice trasformato:**
148
+
149
+ ```tsx
150
+ // Il tuo codice
151
+ const content = useIntlayer("my-key");
152
+
153
+ // Codice ottimizzato (Dinamico)
154
+ const content = useDictionaryAsync({
155
+ en: () =>
156
+ import(".intlayer/dynamic_dictionary/en.json").then((mod) => mod.default),
157
+ fr: () =>
158
+ import(".intlayer/dynamic_dictionary/fr.json").then((mod) => mod.default),
159
+ });
160
+ ```
161
+
162
+ > Quando si utilizza `importMode: 'dynamic'`, se si hanno 100 componenti che usano `useIntlayer` in una singola pagina, il browser tenterà 100 richieste separate. Per evitare questa "cascata" di richieste, raggruppare il contenuto in meno file `.content` (ad esempio, un dizionario per sezione della pagina) invece di uno per ogni componente atomico.
163
+
164
+ > Attualmente, `importMode: 'dynamic'` non è completamente supportato per Vue e Svelte. Si consiglia di utilizzare `importMode: 'static'` per questi framework fino a futuri aggiornamenti.
165
+
166
+ ### 3. Modalità Live
167
+
168
+ Si comporta in modo simile alla modalità Dynamic ma tenta prima di recuperare i dizionari dall'API Intlayer Live Sync. Se la chiamata API fallisce o il contenuto non è contrassegnato per aggiornamenti live, si ricade sull'importazione dinamica.
169
+
170
+ > Consulta la documentazione CMS per maggiori dettagli: [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_CMS.md)
171
+
172
+ ## Riepilogo: Static vs Dynamic
173
+
174
+ | Caratteristica | Modalità Static | Modalità Dynamic |
175
+ | :----------------------- | :----------------------------------------------------- | :-------------------------------------------- |
176
+ | **Dimensione Bundle JS** | Più grande (include tutte le lingue per il componente) | Più piccolo (solo codice, nessun contenuto) |
177
+ | **Caricamento Iniziale** | Istantaneo (Il contenuto è nel bundle) | Leggero ritardo (Recupera JSON) |
178
+ | **Richieste di Rete** | 0 richieste aggiuntive | 1 richiesta per dizionario |
179
+ | **Tree Shaking** | A livello di componente | A livello di componente + a livello di lingua |
180
+ | **Caso d'Uso Migliore** | Componenti UI, Piccole App | Pagine con molto testo, Molte lingue |
@@ -141,7 +141,7 @@ Il pacchetto `vue-intlayer` è utilizzato per interpretare i dizionari di Intlay
141
141
 
142
142
  Il pacchetto `nuxt-intlayer` è un modulo Nuxt per rendere utilizzabili i dizionari Intlayer nelle applicazioni Nuxt. Integra funzionalità essenziali per far funzionare Intlayer in un ambiente Nuxt, come il middleware per la traduzione, il routing e la configurazione del file `nuxt.config.js`.
143
143
 
144
- ### svelte-intlayer (WIP)
144
+ ### svelte-intlayer
145
145
 
146
146
  Il pacchetto `svelte-intlayer` è utilizzato per interpretare i dizionari di Intlayer e renderli utilizzabili nelle applicazioni Svelte.
147
147
 
@@ -42,6 +42,10 @@ Link all'estensione: [https://marketplace.visualstudio.com/items?itemName=Intlay
42
42
 
43
43
  ## Funzionalità
44
44
 
45
+ ![Estrai contenuto](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_extract_content.gif?raw=true)
46
+
47
+ - **Estrai Contenuto** – Estrai contenuto dai tuoi componenti React / Vue / Svelte
48
+
45
49
  ![Riempi dizionari](https://github.com/aymericzip/intlayer-vs-code-extension/blob/master/assets/vscode_extention_fill_active_dictionary.gif?raw=true)
46
50
 
47
51
  - **Navigazione Istantanea** – Passa rapidamente al file di contenuto corretto cliccando su una chiave `useIntlayer`.