Skip to content

Commit 92525a0

Browse files
committed
feat(docs): add optional step for optimizing bundle size with SWC plugin in multiple language guides
1 parent f6d0936 commit 92525a0

39 files changed

+707
-7
lines changed

docs/ar/intlayer_with_nextjs_14.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,24 @@ Link.displayName = 'Link';
11911191
11921192
من خلال دمج هذا المكون `Link` في جميع أنحاء تطبيقك، تحافظ على تجربة مستخدم متماسكة وواعية باللغة مع الاستفادة أيضًا من تحسين محركات البحث وسهولة الاستخدام.
11931193
1194+
### (اختياري) الخطوة 12: تحسين حجم الحزمة
1195+
1196+
`next-intlayer` का उपयोग करते समय, डिफ़ॉल्ट रूप से प्रत्येक पृष्ठ के लिए शब्दकोश बंडल में शामिल होते हैं। बंडल आकार को अनुकूलित करने के लिए, Intlayer एक वैकल्पिक SWC प्लगइन प्रदान करता है जो मैक्रोज़ का उपयोग करके `useIntlayer` कॉल को बुद्धिमानी से बदलता है। यह सुनिश्चित करता है कि शब्दकोश केवल उन पृष्ठों के बंडल में शामिल हों जो वास्तव में उनका उपयोग करते हैं।
1197+
1198+
इस अनुकूलन को सक्षम करने के लिए, `@intlayer/swc` पैकेज इंस्टॉल करें। एक बार इंस्टॉल हो जाने पर, `next-intlayer` स्वचालित रूप से प्लगइन का पता लगाएगा और उसका उपयोग करेगा:
1199+
1200+
```bash packageManager="npm"
1201+
npm install @intlayer/swc --save-dev
1202+
```
1203+
1204+
```bash packageManager="pnpm"
1205+
pnpm add @intlayer/swc --save-dev
1206+
```
1207+
1208+
```bash packageManager="yarn"
1209+
yarn add @intlayer/swc --save-dev
1210+
```
1211+
11941212
### تكوين TypeScript
11951213
11961214
يستخدم Intlayer توسيع الوحدات للحصول على فوائد TypeScript وجعل قاعدة الكود الخاصة بك أقوى.

docs/ar/intlayer_with_nextjs_15.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,24 @@ const Link = ({ href, children, ...props }) => {
12391239
12401240
من خلال دمج مكون `Link` هذا عبر تطبيقك، تحافظ على تجربة مستخدم متماسكة وواعية باللغة مع الاستفادة أيضًا من تحسين SEO وسهولة الاستخدام.
12411241
1242+
### (اختياري) الخطوة 12: تحسين حجم الحزمة
1243+
1244+
`next-intlayer` का उपयोग करते समय, डिफ़ॉल्ट रूप से प्रत्येक पृष्ठ के लिए शब्दकोश बंडल में शामिल होते हैं। बंडल आकार को अनुकूलित करने के लिए, Intlayer एक वैकल्पिक SWC प्लगइन प्रदान करता है जो मैक्रोज़ का उपयोग करके `useIntlayer` कॉल को बुद्धिमानी से बदलता है। यह सुनिश्चित करता है कि शब्दकोश केवल उन पृष्ठों के बंडल में शामिल हों जो वास्तव में उनका उपयोग करते हैं।
1245+
1246+
इस अनुकूलन को सक्षम करने के लिए, `@intlayer/swc` पैकेज इंस्टॉल करें। एक बार इंस्टॉल हो जाने पर, `next-intlayer` स्वचालित रूप से प्लगइन का पता लगाएगा और उसका उपयोग करेगा:
1247+
1248+
```bash packageManager="npm"
1249+
npm install @intlayer/swc --save-dev
1250+
```
1251+
1252+
```bash packageManager="pnpm"
1253+
pnpm add @intlayer/swc --save-dev
1254+
```
1255+
1256+
```bash packageManager="yarn"
1257+
yarn add @intlayer/swc --save-dev
1258+
```
1259+
12421260
### تكوين TypeScript
12431261
12441262
يستخدم Intlayer توسيع الوحدة للحصول على فوائد TypeScript وجعل قاعدة التعليمات البرمجية الخاصة بك أقوى.

docs/ar/intlayer_with_nextjs_page_router.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,24 @@ Link.displayName = 'Link';
10201020
10211021
من خلال دمج هذا المكون `Link` في جميع أنحاء تطبيقك، تحافظ على تجربة مستخدم متماسكة وواعية باللغة مع الاستفادة أيضًا من تحسين محركات البحث وقابلية الاستخدام المحسنة.
10221022
1023+
### (اختياري) الخطوة 11: تحسين حجم الحزمة
1024+
1025+
`next-intlayer` का उपयोग करते समय, डिफ़ॉल्ट रूप से प्रत्येक पृष्ठ के लिए शब्दकोश बंडल में शामिल होते हैं। बंडल आकार को अनुकूलित करने के लिए, Intlayer एक वैकल्पिक SWC प्लगइन प्रदान करता है जो मैक्रोज़ का उपयोग करके `useIntlayer` कॉल को बुद्धिमानी से बदलता है। यह सुनिश्चित करता है कि शब्दकोश केवल उन पृष्ठों के बंडल में शामिल हों जो वास्तव में उनका उपयोग करते हैं।
1026+
1027+
इस अनुकूलन को सक्षम करने के लिए, `@intlayer/swc` पैकेज इंस्टॉल करें। एक बार इंस्टॉल हो जाने पर, `next-intlayer` स्वचालित रूप से प्लगइन का पता लगाएगा और उसका उपयोग करेगा:
1028+
1029+
```bash packageManager="npm"
1030+
npm install @intlayer/swc --save-dev
1031+
```
1032+
1033+
```bash packageManager="pnpm"
1034+
pnpm add @intlayer/swc --save-dev
1035+
```
1036+
1037+
```bash packageManager="yarn"
1038+
yarn add @intlayer/swc --save-dev
1039+
```
1040+
10231041
### تكوين TypeScript
10241042
10251043
يستخدم Intlayer توسيع الوحدات للحصول على فوائد TypeScript وجعل قاعدة التعليمات البرمجية الخاصة بك أقوى.

docs/de/intlayer_with_nextjs_14.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,24 @@ Link.displayName = 'Link';
11861186
11871187
Durch die Integration dieser `Link`-Komponente in Ihrer gesamten Anwendung erhalten Sie eine kohärente und sprachbewusste Benutzererfahrung und profitieren gleichzeitig von verbesserter SEO und Benutzerfreundlichkeit.
11881188
1189+
### (Optional) Schritt 12: Optimieren Sie Ihre Bundle-Größe
1190+
1191+
Bei der Verwendung von `next-intlayer` werden Wörterbücher standardmäßig in das Bundle für jede Seite aufgenommen. Um die Bundle-Größe zu optimieren, bietet Intlayer ein optionales SWC-Plugin, das `useIntlayer`-Aufrufe intelligent durch Makros ersetzt. Dies stellt sicher, dass Wörterbücher nur in Bundles für Seiten enthalten sind, die sie tatsächlich verwenden.
1192+
1193+
Um diese Optimierung zu aktivieren, installieren Sie das `@intlayer/swc`-Paket. Nach der Installation erkennt und verwendet `next-intlayer` das Plugin automatisch:
1194+
1195+
```bash packageManager="npm"
1196+
npm install @intlayer/swc --save-dev
1197+
```
1198+
1199+
```bash packageManager="pnpm"
1200+
pnpm add @intlayer/swc --save-dev
1201+
```
1202+
1203+
```bash packageManager="yarn"
1204+
yarn add @intlayer/swc --save-dev
1205+
```
1206+
11891207
### TypeScript konfigurieren
11901208
11911209
Intlayer verwendet Modulerweiterung, um die Vorteile von TypeScript zu nutzen und Ihren Code robuster zu machen.

docs/de/intlayer_with_nextjs_15.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,24 @@ const Link = ({ href, children, ...props }) => {
12351235
12361236
Durch die Integration dieser `Link`-Komponente in Ihrer gesamten Anwendung gewährleisten Sie eine kohärente und sprachbewusste Benutzererfahrung und profitieren gleichzeitig von verbesserter SEO und Benutzerfreundlichkeit.
12371237
1238+
### (Optional) Schritt 12: Optimieren Sie Ihre Bundle-Größe
1239+
1240+
Bei der Verwendung von `next-intlayer` werden Wörterbücher standardmäßig in das Bundle für jede Seite aufgenommen. Um die Bundle-Größe zu optimieren, bietet Intlayer ein optionales SWC-Plugin, das `useIntlayer`-Aufrufe intelligent durch Makros ersetzt. Dies stellt sicher, dass Wörterbücher nur in Bundles für Seiten enthalten sind, die sie tatsächlich verwenden.
1241+
1242+
Um diese Optimierung zu aktivieren, installieren Sie das `@intlayer/swc`-Paket. Nach der Installation erkennt und verwendet `next-intlayer` das Plugin automatisch:
1243+
1244+
```bash packageManager="npm"
1245+
npm install @intlayer/swc --save-dev
1246+
```
1247+
1248+
```bash packageManager="pnpm"
1249+
pnpm add @intlayer/swc --save-dev
1250+
```
1251+
1252+
```bash packageManager="yarn"
1253+
yarn add @intlayer/swc --save-dev
1254+
```
1255+
12381256
### TypeScript konfigurieren
12391257
12401258
Intlayer verwendet Modulerweiterungen, um die Vorteile von TypeScript zu nutzen und Ihre Codebasis robuster zu machen.

docs/de/intlayer_with_nextjs_page_router.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,24 @@ Link.displayName = 'Link';
10091009
10101010
Durch die Integration dieser `Link`-Komponente in Ihrer gesamten Anwendung erhalten Sie eine kohärente und sprachbewusste Benutzererfahrung und profitieren gleichzeitig von einer verbesserten SEO und Benutzerfreundlichkeit.
10111011
1012+
### (Optional) Schritt 11: Optimieren Sie Ihre Bundle-Größe
1013+
1014+
Bei der Verwendung von `next-intlayer` werden Wörterbücher standardmäßig in das Bundle für jede Seite aufgenommen. Um die Bundle-Größe zu optimieren, bietet Intlayer ein optionales SWC-Plugin, das `useIntlayer`-Aufrufe intelligent durch Makros ersetzt. Dies stellt sicher, dass Wörterbücher nur in Bundles für Seiten enthalten sind, die sie tatsächlich verwenden.
1015+
1016+
Um diese Optimierung zu aktivieren, installieren Sie das `@intlayer/swc`-Paket. Nach der Installation erkennt und verwendet `next-intlayer` das Plugin automatisch:
1017+
1018+
```bash packageManager="npm"
1019+
npm install @intlayer/swc --save-dev
1020+
```
1021+
1022+
```bash packageManager="pnpm"
1023+
pnpm add @intlayer/swc --save-dev
1024+
```
1025+
1026+
```bash packageManager="yarn"
1027+
yarn add @intlayer/swc --save-dev
1028+
```
1029+
10121030
### TypeScript konfigurieren
10131031
10141032
Intlayer verwendet Modulerweiterungen, um die Vorteile von TypeScript zu nutzen und Ihre Codebasis robuster zu machen.

docs/en-GB/intlayer_with_nextjs_14.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,24 @@ Link.displayName = 'Link';
11951195
11961196
By integrating this `Link` component across your application, you maintain a coherent and language-aware user experience while also benefitting from improved SEO and usability.
11971197
1198+
### (Optional) Step 12: Optmize your bundle size
1199+
1200+
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.
1201+
1202+
To enable this optimization, install the `@intlayer/swc` package. Once installed, `next-intlayer` will automatically detect and use the plugin:
1203+
1204+
```bash packageManager="npm"
1205+
npm install @intlayer/swc --save-dev
1206+
```
1207+
1208+
```bash packageManager="pnpm"
1209+
pnpm add @intlayer/swc --save-dev
1210+
```
1211+
1212+
```bash packageManager="yarn"
1213+
yarn add @intlayer/swc --save-dev
1214+
```
1215+
11981216
### Configure TypeScript
11991217
12001218
Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.

docs/en-GB/intlayer_with_nextjs_15.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,24 @@ const Link = ({ href, children, ...props }) => {
12361236
12371237
By integrating this `Link` component across your application, you maintain a coherent and language-aware user experience while also benefitting from improved SEO and usability.
12381238
1239+
### (Optional) Step 12: Optmize your bundle size
1240+
1241+
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.
1242+
1243+
To enable this optimization, install the `@intlayer/swc` package. Once installed, `next-intlayer` will automatically detect and use the plugin:
1244+
1245+
```bash packageManager="npm"
1246+
npm install @intlayer/swc --save-dev
1247+
```
1248+
1249+
```bash packageManager="pnpm"
1250+
pnpm add @intlayer/swc --save-dev
1251+
```
1252+
1253+
```bash packageManager="yarn"
1254+
yarn add @intlayer/swc --save-dev
1255+
```
1256+
12391257
### Configure TypeScript
12401258
12411259
Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.

docs/en-GB/intlayer_with_nextjs_page_router.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,24 @@ Link.displayName = 'Link';
10081008
10091009
By integrating this `Link` component across your application, you maintain a coherent and language-aware user experience while also benefiting from improved SEO and usability.
10101010
1011+
### (Optional) Step 11: Optmize your bundle size
1012+
1013+
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.
1014+
1015+
To enable this optimization, install the `@intlayer/swc` package. Once installed, `next-intlayer` will automatically detect and use the plugin:
1016+
1017+
```bash packageManager="npm"
1018+
npm install @intlayer/swc --save-dev
1019+
```
1020+
1021+
```bash packageManager="pnpm"
1022+
pnpm add @intlayer/swc --save-dev
1023+
```
1024+
1025+
```bash packageManager="yarn"
1026+
yarn add @intlayer/swc --save-dev
1027+
```
1028+
10111029
### Configure TypeScript
10121030
10131031
Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.

docs/en/intlayer_with_nextjs_14.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,24 @@ Link.displayName = 'Link';
11861186
11871187
By integrating this `Link` component across your application, you maintain a coherent and language-aware user experience while also benefitting from improved SEO and usability.
11881188
1189+
### (Optional) Step 12: Optmize your bundle size
1190+
1191+
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.
1192+
1193+
To enable this optimization, install the `@intlayer/swc` package. Once installed, `next-intlayer` will automatically detect and use the plugin:
1194+
1195+
```bash packageManager="npm"
1196+
npm install @intlayer/swc --save-dev
1197+
```
1198+
1199+
```bash packageManager="pnpm"
1200+
pnpm add @intlayer/swc --save-dev
1201+
```
1202+
1203+
```bash packageManager="yarn"
1204+
yarn add @intlayer/swc --save-dev
1205+
```
1206+
11891207
### Configure TypeScript
11901208
11911209
Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.

docs/en/intlayer_with_nextjs_15.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,24 @@ const Link = ({ href, children, ...props }) => {
12351235
12361236
By integrating this `Link` component across your application, you maintain a coherent and language-aware user experience while also benefitting from improved SEO and usability.
12371237
1238+
### (Optional) Step 12: Optmize your bundle size
1239+
1240+
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.
1241+
1242+
To enable this optimization, install the `@intlayer/swc` package. Once installed, `next-intlayer` will automatically detect and use the plugin:
1243+
1244+
```bash packageManager="npm"
1245+
npm install @intlayer/swc --save-dev
1246+
```
1247+
1248+
```bash packageManager="pnpm"
1249+
pnpm add @intlayer/swc --save-dev
1250+
```
1251+
1252+
```bash packageManager="yarn"
1253+
yarn add @intlayer/swc --save-dev
1254+
```
1255+
12381256
### Configure TypeScript
12391257
12401258
Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.

docs/en/intlayer_with_nextjs_page_router.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,24 @@ Link.displayName = 'Link';
10051005
10061006
By integrating this `Link` component across your application, you maintain a coherent and language-aware user experience while also benefitting from improved SEO and usability.
10071007
1008+
### (Optional) Step 11: Optmize your bundle size
1009+
1010+
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.
1011+
1012+
To enable this optimization, install the `@intlayer/swc` package. Once installed, `next-intlayer` will automatically detect and use the plugin:
1013+
1014+
```bash packageManager="npm"
1015+
npm install @intlayer/swc --save-dev
1016+
```
1017+
1018+
```bash packageManager="pnpm"
1019+
pnpm add @intlayer/swc --save-dev
1020+
```
1021+
1022+
```bash packageManager="yarn"
1023+
yarn add @intlayer/swc --save-dev
1024+
```
1025+
10081026
### Configure TypeScript
10091027
10101028
Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.

docs/es/intlayer_with_nextjs_14.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ const Page = ({ params: { locale } }) => {
464464
- **`IntlayerClientProvider`** se utiliza para proporcionar el idioma a los componentes del lado del cliente. Puede colocarse en cualquier componente padre, incluido el layout. Sin embargo, se recomienda colocarlo en un layout porque Next.js comparte el código del layout entre páginas, haciéndolo más eficiente. Al usar `IntlayerClientProvider` en el layout, evitas reinicializarlo para cada página, mejorando el rendimiento y manteniendo un contexto de localización consistente en toda tu aplicación.
465465
- **`IntlayerServerProvider`** se utiliza para proporcionar el idioma a los hijos del servidor. No puede configurarse en el layout.
466466

467-
> El layout y la página no pueden compartir un contexto de servidor común porque el sistema de contexto del servidor se basa en un almacén de datos por solicitud (a través del mecanismo de [Reacts cache](https://react.dev/reference/react/cache)), causando que cada "contexto" se recree para diferentes segmentos de la aplicación. Colocar el proveedor en un layout compartido rompería este aislamiento, impidiendo la correcta propagación de los valores del contexto del servidor a tus componentes del servidor.
467+
> El layout y la página no pueden compartir un contexto de servidor común porque el sistema de contexto del servidor se basa en un almacén de datos por solicitud (a través del mecanismo de [React's cache](https://react.dev/reference/react/cache)), causando que cada "contexto" se recree para diferentes segmentos de la aplicación. Colocar el proveedor en un layout compartido rompería este aislamiento, impidiendo la correcta propagación de los valores del contexto del servidor a tus componentes del servidor.
468468
469469
```tsx {4,7} fileName="src/components/ClientComponentExample.tsx" codeFormat="typescript"
470470
"use client";
@@ -1186,6 +1186,24 @@ Link.displayName = 'Link';
11861186
11871187
Al integrar este componente `Link` en toda tu aplicación, mantienes una experiencia de usuario coherente y consciente del idioma, mientras también te beneficias de un mejor SEO y usabilidad.
11881188
1189+
### (Opcional) Paso 12: Optimiza el tamaño de tu bundle
1190+
1191+
Cuando usas `next-intlayer`, los diccionarios se incluyen en el bundle de cada página por defecto. Para optimizar el tamaño de tu bundle, Intlayer ofrece un plugin SWC opcional que reemplaza de forma inteligente las llamadas a `useIntlayer` usando macros. Esto asegura que los diccionarios solo se incluyan en los bundles de las páginas que realmente los utilizan.
1192+
1193+
Para habilitar esta optimización, instala el paquete `@intlayer/swc`. Una vez instalado, `next-intlayer` lo detectará y lo usará automáticamente:
1194+
1195+
```bash packageManager="npm"
1196+
npm install @intlayer/swc --save-dev
1197+
```
1198+
1199+
```bash packageManager="pnpm"
1200+
pnpm add @intlayer/swc --save-dev
1201+
```
1202+
1203+
```bash packageManager="yarn"
1204+
yarn add @intlayer/swc --save-dev
1205+
```
1206+
11891207
### Configurar TypeScript
11901208
11911209
Intlayer utiliza la ampliación de módulos para obtener los beneficios de TypeScript y fortalecer tu base de código.

0 commit comments

Comments
 (0)