@intlayer/docs 7.1.3 → 7.1.4

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.
package/README.md CHANGED
@@ -247,9 +247,6 @@ You can also follow us on :
247
247
  <a href="https://www.linkedin.com/company/intlayerorg" target="blank" rel='noopener noreferrer nofollow'><img align="center"
248
248
  src="https://img.shields.io/badge/linkedin-%231DA1F2.svg?style=for-the-badge&logo=linkedin&logoColor=white"
249
249
  alt="Intlayer LinkedIn" height="30"/></a>
250
- <a href="https://www.facebook.com/intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
251
- src="https://img.shields.io/badge/facebook-4267B2.svg?style=for-the-badge&logo=facebook&logoColor=white"
252
- alt="Intlayer Facebook" height="30"/></a>
253
250
  <a href="https://www.instagram.com/intlayer/" target="blank" rel='noopener noreferrer nofollow'><img align="center"
254
251
  src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
255
252
  alt="Intlayer Instagram" height="30"/></a>
@@ -101,14 +101,27 @@ export default config;
101
101
  أضف مكون intlayer الإضافي إلى تكوينك:
102
102
 
103
103
  ```typescript fileName="vite.config.ts"
104
- import { reactRouter } from "@react-router/dev/vite";
104
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
105
+ import viteReact from "@vitejs/plugin-react";
106
+ import { nitro } from "nitro/vite";
105
107
  import { defineConfig } from "vite";
106
- import { intlayer } from "vite-intlayer";
107
- import tsconfigPaths from "vite-tsconfig-paths";
108
+ import { intlayer, intlayerProxy } from "vite-intlayer";
109
+ import viteTsConfigPaths from "vite-tsconfig-paths";
108
110
 
109
- export default defineConfig({
110
- plugins: [reactRouter(), tsconfigPaths(), intlayer()],
111
+ const config = defineConfig({
112
+ plugins: [
113
+ nitro(),
114
+ viteTsConfigPaths({
115
+ projects: ["./tsconfig.json"],
116
+ }),
117
+ tanstackStart(),
118
+ viteReact(),
119
+ intlayer(), // To make intlayer work
120
+ intlayerProxy(), // To redirect the user to his own locale
121
+ ],
111
122
  });
123
+
124
+ export default config;
112
125
  ```
113
126
 
114
127
  > يُستخدم مكون Vite الإضافي `intlayer()` لدمج Intlayer مع Vite. يضمن بناء ملفات إعلان المحتوى ومراقبتها في وضع التطوير. كما يعرّف متغيرات بيئة Intlayer داخل تطبيق Vite. بالإضافة إلى ذلك، يوفر ألقابًا لتحسين الأداء.
@@ -134,7 +147,7 @@ function LayoutComponent() {
134
147
  const { locale } = Route.useParams();
135
148
 
136
149
  return (
137
- <IntlayerProvider locale={defaultLocale}>
150
+ <IntlayerProvider locale={locale ?? defaultLocale}>
138
151
  <Outlet />
139
152
  </IntlayerProvider>
140
153
  );
@@ -518,6 +531,32 @@ export default defineConfig({
518
531
 
519
532
  ---
520
533
 
534
+ ### الخطوة 13: تكييف Nitro (اختياري)
535
+
536
+ إذا كنت تستخدم Nitro لإخراج الإنتاج الخاص بك، فلن يقوم nitro بتضمين دليل `.intlayer` في دليل الإخراج. تحتاج إلى نسخه يدويًا.
537
+
538
+ مثال باستخدام سكريبت البناء:
539
+
540
+ ```json5 fileName="package.json"
541
+ {
542
+ "scripts": {
543
+ "dev": "vite dev --port 3000",
544
+ "build": "vite build && cpr .intlayer .output/.intlayer", // نسخ مجلد .intlayer
545
+ "serve": "vite preview",
546
+ },
547
+ }
548
+ ```
549
+
550
+ > يُستخدم cpr لتكييف الأمر لجعله يعمل على Windows.
551
+ > ستحتاج إلى تثبيت أداة `cpr` لاستخدام هذا الأمر.
552
+ >
553
+ > - `npm install --save-dev cpr`
554
+ > - `yarn add --dev cpr`
555
+ > - `pnpm add --save-dev cpr`
556
+ > - `bun add --save-dev cpr`
557
+
558
+ ---
559
+
521
560
  ### تكوين Git
522
561
 
523
562
  يوصى بتجاهل الملفات التي تم إنشاؤها بواسطة Intlayer. هذا يسمح لك بتجنب الالتزام بها في مستودع Git الخاص بك.
@@ -105,14 +105,27 @@ export default config;
105
105
  Fügen Sie das Intlayer-Plugin in Ihre Konfiguration ein:
106
106
 
107
107
  ```typescript fileName="vite.config.ts"
108
- import { reactRouter } from "@react-router/dev/vite";
108
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
109
+ import viteReact from "@vitejs/plugin-react";
110
+ import { nitro } from "nitro/vite";
109
111
  import { defineConfig } from "vite";
110
- import { intlayer } from "vite-intlayer";
111
- import tsconfigPaths from "vite-tsconfig-paths";
112
+ import { intlayer, intlayerProxy } from "vite-intlayer";
113
+ import viteTsConfigPaths from "vite-tsconfig-paths";
112
114
 
113
- export default defineConfig({
114
- plugins: [reactRouter(), tsconfigPaths(), intlayer()],
115
+ const config = defineConfig({
116
+ plugins: [
117
+ nitro(),
118
+ viteTsConfigPaths({
119
+ projects: ["./tsconfig.json"],
120
+ }),
121
+ tanstackStart(),
122
+ viteReact(),
123
+ intlayer(), // To make intlayer work
124
+ intlayerProxy(), // To redirect the user to his own locale
125
+ ],
115
126
  });
127
+
128
+ export default config;
116
129
  ```
117
130
 
118
131
  > Das `intlayer()` Vite-Plugin wird verwendet, um Intlayer mit Vite zu integrieren. Es sorgt für den Aufbau der Content-Deklarationsdateien und überwacht diese im Entwicklungsmodus. Es definiert Intlayer-Umgebungsvariablen innerhalb der Vite-Anwendung. Zusätzlich stellt es Aliase bereit, um die Leistung zu optimieren.
@@ -138,7 +151,7 @@ function LayoutComponent() {
138
151
  const { locale } = Route.useParams();
139
152
 
140
153
  return (
141
- <IntlayerProvider locale={defaultLocale}>
154
+ <IntlayerProvider locale={locale ?? defaultLocale}>
142
155
  <Outlet />
143
156
  </IntlayerProvider>
144
157
  );
@@ -522,6 +535,32 @@ Stellen Sie sicher, dass Ihre TypeScript-Konfiguration die automatisch generiert
522
535
 
523
536
  ---
524
537
 
538
+ ### Schritt 13: Nitro anpassen (Optional)
539
+
540
+ Wenn Sie Nitro für Ihre Produktionsausgabe verwenden, wird nitro das Verzeichnis `.intlayer` nicht in das Ausgabeverzeichnis einschließen. Sie müssen es manuell kopieren.
541
+
542
+ Beispiel mit Build-Skript:
543
+
544
+ ```json5 fileName="package.json"
545
+ {
546
+ "scripts": {
547
+ "dev": "vite dev --port 3000",
548
+ "build": "vite build && cpr .intlayer .output/.intlayer", // .intlayer-Ordner kopieren
549
+ "serve": "vite preview",
550
+ },
551
+ }
552
+ ```
553
+
554
+ > cpr wird verwendet, um den Befehl anzupassen, damit er unter Windows funktioniert.
555
+ > Sie müssen das `cpr`-Dienstprogramm installieren, um diesen Befehl zu verwenden.
556
+ >
557
+ > - `npm install --save-dev cpr`
558
+ > - `yarn add --dev cpr`
559
+ > - `pnpm add --save-dev cpr`
560
+ > - `bun add --save-dev cpr`
561
+
562
+ ---
563
+
525
564
  ### Git-Konfiguration
526
565
 
527
566
  Es wird empfohlen, die von Intlayer generierten Dateien zu ignorieren. So vermeiden Sie, diese versehentlich in Ihr Git-Repository zu committen.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2025-09-09
3
- updatedAt: 2025-09-09
3
+ updatedAt: 2025-11-18
4
4
  title: How to translate your Tanstack Start app – i18n guide 2025
5
5
  description: Learn how to add internationalization (i18n) to your Tanstack Start application using Intlayer. Follow this comprehensive guide to make your app multilingual with locale-aware routing.
6
6
  keywords:
@@ -18,6 +18,9 @@ slugs:
18
18
  - tanstack-start
19
19
  applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
20
20
  history:
21
+ - version: 7.2.3
22
+ date: 2025-11-18
23
+ changes: Add step 13: Adapt Nitro
21
24
  - version: 7.1.0
22
25
  date: 2025-11-17
23
26
  changes: Fix prefix default by adding getPrefix function useLocalizedNavigate, LocaleSwitcher and LocalizedLink.
@@ -117,14 +120,27 @@ export default config;
117
120
  Add the intlayer plugin into your configuration:
118
121
 
119
122
  ```typescript fileName="vite.config.ts"
120
- import { reactRouter } from "@react-router/dev/vite";
123
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
124
+ import viteReact from "@vitejs/plugin-react";
125
+ import { nitro } from "nitro/vite";
121
126
  import { defineConfig } from "vite";
122
- import { intlayer } from "vite-intlayer";
123
- import tsconfigPaths from "vite-tsconfig-paths";
127
+ import { intlayer, intlayerProxy } from "vite-intlayer";
128
+ import viteTsConfigPaths from "vite-tsconfig-paths";
124
129
 
125
- export default defineConfig({
126
- plugins: [reactRouter(), tsconfigPaths(), intlayer()],
130
+ const config = defineConfig({
131
+ plugins: [
132
+ nitro(),
133
+ viteTsConfigPaths({
134
+ projects: ["./tsconfig.json"],
135
+ }),
136
+ tanstackStart(),
137
+ viteReact(),
138
+ intlayer(), // To make intlayer work
139
+ intlayerProxy(), // To redirect the user to his own locale
140
+ ],
127
141
  });
142
+
143
+ export default config;
128
144
  ```
129
145
 
130
146
  > The `intlayer()` Vite plugin is used to integrate Intlayer with Vite. It ensures the building of content declaration files and monitors them in development mode. It defines Intlayer environment variables within the Vite application. Additionally, it provides aliases to optimize performance.
@@ -150,7 +166,7 @@ function LayoutComponent() {
150
166
  const { locale } = Route.useParams();
151
167
 
152
168
  return (
153
- <IntlayerProvider locale={defaultLocale}>
169
+ <IntlayerProvider locale={locale ?? defaultLocale}>
154
170
  <Outlet />
155
171
  </IntlayerProvider>
156
172
  );
@@ -536,6 +552,32 @@ Ensure your TypeScript configuration includes the autogenerated types:
536
552
 
537
553
  ---
538
554
 
555
+ ### Step 13: Adapt Nitro (Optional)
556
+
557
+ If you are using Nitro for your production output, nitro will not include the `.intlayer` directory in the output directory. You need to copy it manually.
558
+
559
+ Example using build script:
560
+
561
+ ```json5 fileName="package.json"
562
+ {
563
+ "scripts": {
564
+ "dev": "vite dev --port 3000",
565
+ "build": "vite build && cpr .intlayer .output/.intlayer", // Copy .intlayer folder
566
+ "serve": "vite preview",
567
+ },
568
+ }
569
+ ```
570
+
571
+ > cpr is used to adapt the command to make it work on Windows.
572
+ > You will have to install the `cpr` utility to use this command.
573
+ >
574
+ > - `npm install --save-dev cpr`
575
+ > - `yarn add --dev cpr`
576
+ > - `pnpm add --save-dev cpr`
577
+ > - `bun add --save-dev cpr`
578
+
579
+ ---
580
+
539
581
  ### Git Configuration
540
582
 
541
583
  It is recommended to ignore the files generated by Intlayer. This allows you to avoid committing them to your Git repository.
@@ -104,14 +104,27 @@ export default config;
104
104
  Add the intlayer plugin into your configuration:
105
105
 
106
106
  ```typescript fileName="vite.config.ts"
107
- import { reactRouter } from "@react-router/dev/vite";
107
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
108
+ import viteReact from "@vitejs/plugin-react";
109
+ import { nitro } from "nitro/vite";
108
110
  import { defineConfig } from "vite";
109
- import { intlayer } from "vite-intlayer";
110
- import tsconfigPaths from "vite-tsconfig-paths";
111
+ import { intlayer, intlayerProxy } from "vite-intlayer";
112
+ import viteTsConfigPaths from "vite-tsconfig-paths";
111
113
 
112
- export default defineConfig({
113
- plugins: [reactRouter(), tsconfigPaths(), intlayer()],
114
+ const config = defineConfig({
115
+ plugins: [
116
+ nitro(),
117
+ viteTsConfigPaths({
118
+ projects: ["./tsconfig.json"],
119
+ }),
120
+ tanstackStart(),
121
+ viteReact(),
122
+ intlayer(), // To make intlayer work
123
+ intlayerProxy(), // To redirect the user to his own locale
124
+ ],
114
125
  });
126
+
127
+ export default config;
115
128
  ```
116
129
 
117
130
  > The `intlayer()` Vite plugin is used to integrate Intlayer with Vite. It ensures the building of content declaration files and monitors them in development mode. It defines Intlayer environment variables within the Vite application. Additionally, it provides aliases to optimise performance.
@@ -137,7 +150,7 @@ function LayoutComponent() {
137
150
  const { locale } = Route.useParams();
138
151
 
139
152
  return (
140
- <IntlayerProvider locale={defaultLocale}>
153
+ <IntlayerProvider locale={locale ?? defaultLocale}>
141
154
  <Outlet />
142
155
  </IntlayerProvider>
143
156
  );
@@ -521,6 +534,32 @@ Ensure your TypeScript configuration includes the autogenerated types:
521
534
 
522
535
  ---
523
536
 
537
+ ### Step 13: Adapt Nitro (Optional)
538
+
539
+ If you are using Nitro for your production output, nitro will not include the `.intlayer` directory in the output directory. You need to copy it manually.
540
+
541
+ Example using build script:
542
+
543
+ ```json5 fileName="package.json"
544
+ {
545
+ "scripts": {
546
+ "dev": "vite dev --port 3000",
547
+ "build": "vite build && cpr -r .intlayer .output/.intlayer", // Copy .intlayer folder
548
+ "serve": "vite preview",
549
+ },
550
+ }
551
+ ```
552
+
553
+ > cpr is used to adapt the command to make it work on Windows.
554
+ > You will have to install the `cpr` utility to use this command.
555
+ >
556
+ > - `npm install --save-dev cpr`
557
+ > - `yarn add --dev cpr`
558
+ > - `pnpm add --save-dev cpr`
559
+ > - `bun add --save-dev cpr`
560
+
561
+ ---
562
+
524
563
  ### Git Configuration
525
564
 
526
565
  It is recommended to ignore the files generated by Intlayer. This prevents you from committing them to your Git repository.
@@ -103,14 +103,27 @@ export default config;
103
103
  Agrega el plugin intlayer en tu configuración:
104
104
 
105
105
  ```typescript fileName="vite.config.ts"
106
- import { reactRouter } from "@react-router/dev/vite";
106
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
107
+ import viteReact from "@vitejs/plugin-react";
108
+ import { nitro } from "nitro/vite";
107
109
  import { defineConfig } from "vite";
108
- import { intlayer } from "vite-intlayer";
109
- import tsconfigPaths from "vite-tsconfig-paths";
110
+ import { intlayer, intlayerProxy } from "vite-intlayer";
111
+ import viteTsConfigPaths from "vite-tsconfig-paths";
110
112
 
111
- export default defineConfig({
112
- plugins: [reactRouter(), tsconfigPaths(), intlayer()],
113
+ const config = defineConfig({
114
+ plugins: [
115
+ nitro(),
116
+ viteTsConfigPaths({
117
+ projects: ["./tsconfig.json"],
118
+ }),
119
+ tanstackStart(),
120
+ viteReact(),
121
+ intlayer(), // To make intlayer work
122
+ intlayerProxy(), // To redirect the user to his own locale
123
+ ],
113
124
  });
125
+
126
+ export default config;
114
127
  ```
115
128
 
116
129
  > El plugin `intlayer()` para Vite se utiliza para integrar Intlayer con Vite. Asegura la construcción de los archivos de declaración de contenido y los monitorea en modo desarrollo. Define variables de entorno de Intlayer dentro de la aplicación Vite. Además, proporciona alias para optimizar el rendimiento.
@@ -136,7 +149,7 @@ function LayoutComponent() {
136
149
  const { locale } = Route.useParams();
137
150
 
138
151
  return (
139
- <IntlayerProvider locale={defaultLocale}>
152
+ <IntlayerProvider locale={locale ?? defaultLocale}>
140
153
  <Outlet />
141
154
  </IntlayerProvider>
142
155
  );
@@ -513,6 +526,32 @@ Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerado
513
526
 
514
527
  ---
515
528
 
529
+ ### Paso 13: Adaptar Nitro (Opcional)
530
+
531
+ Si estás utilizando Nitro para tu salida de producción, nitro no incluirá el directorio `.intlayer` en el directorio de salida. Necesitas copiarlo manualmente.
532
+
533
+ Ejemplo usando script de build:
534
+
535
+ ```json5 fileName="package.json"
536
+ {
537
+ "scripts": {
538
+ "dev": "vite dev --port 3000",
539
+ "build": "vite build && cpr .intlayer .output/.intlayer", // Copiar carpeta .intlayer
540
+ "serve": "vite preview",
541
+ },
542
+ }
543
+ ```
544
+
545
+ > cpr se utiliza para adaptar el comando y hacer que funcione en Windows.
546
+ > Tendrás que instalar la utilidad `cpr` para usar este comando.
547
+ >
548
+ > - `npm install --save-dev cpr`
549
+ > - `yarn add --dev cpr`
550
+ > - `pnpm add --save-dev cpr`
551
+ > - `bun add --save-dev cpr`
552
+
553
+ ---
554
+
516
555
  ### Configuración de Git
517
556
 
518
557
  Se recomienda ignorar los archivos generados por Intlayer. Esto te permite evitar comprometerlos en tu repositorio Git.
@@ -103,14 +103,27 @@ export default config;
103
103
  Ajoutez le plugin intlayer dans votre configuration :
104
104
 
105
105
  ```typescript fileName="vite.config.ts"
106
- import { reactRouter } from "@react-router/dev/vite";
106
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
107
+ import viteReact from "@vitejs/plugin-react";
108
+ import { nitro } from "nitro/vite";
107
109
  import { defineConfig } from "vite";
108
- import { intlayer } from "vite-intlayer";
109
- import tsconfigPaths from "vite-tsconfig-paths";
110
+ import { intlayer, intlayerProxy } from "vite-intlayer";
111
+ import viteTsConfigPaths from "vite-tsconfig-paths";
110
112
 
111
- export default defineConfig({
112
- plugins: [reactRouter(), tsconfigPaths(), intlayer()],
113
+ const config = defineConfig({
114
+ plugins: [
115
+ nitro(),
116
+ viteTsConfigPaths({
117
+ projects: ["./tsconfig.json"],
118
+ }),
119
+ tanstackStart(),
120
+ viteReact(),
121
+ intlayer(), // To make intlayer work
122
+ intlayerProxy(), // To redirect the user to his own locale
123
+ ],
113
124
  });
125
+
126
+ export default config;
114
127
  ```
115
128
 
116
129
  > Le plugin Vite `intlayer()` est utilisé pour intégrer Intlayer avec Vite. Il assure la construction des fichiers de déclaration de contenu et les surveille en mode développement. Il définit les variables d'environnement Intlayer au sein de l'application Vite. De plus, il fournit des alias pour optimiser les performances.
@@ -136,7 +149,7 @@ function LayoutComponent() {
136
149
  const { locale } = Route.useParams();
137
150
 
138
151
  return (
139
- <IntlayerProvider locale={defaultLocale}>
152
+ <IntlayerProvider locale={locale ?? defaultLocale}>
140
153
  <Outlet />
141
154
  </IntlayerProvider>
142
155
  );
@@ -517,6 +530,32 @@ Assurez-vous que votre configuration TypeScript inclut les types générés auto
517
530
 
518
531
  ---
519
532
 
533
+ ### Étape 13 : Adapter Nitro (Optionnel)
534
+
535
+ Si vous utilisez Nitro pour votre sortie de production, nitro n'inclura pas le répertoire `.intlayer` dans le répertoire de sortie. Vous devez le copier manuellement.
536
+
537
+ Exemple utilisant le script de build :
538
+
539
+ ```json5 fileName="package.json"
540
+ {
541
+ "scripts": {
542
+ "dev": "vite dev --port 3000",
543
+ "build": "vite build && cpr .intlayer .output/.intlayer", // Copier le dossier .intlayer
544
+ "serve": "vite preview",
545
+ },
546
+ }
547
+ ```
548
+
549
+ > cpr est utilisé pour adapter la commande afin qu'elle fonctionne sur Windows.
550
+ > Vous devrez installer l'utilitaire `cpr` pour utiliser cette commande.
551
+ >
552
+ > - `npm install --save-dev cpr`
553
+ > - `yarn add --dev cpr`
554
+ > - `pnpm add --save-dev cpr`
555
+ > - `bun add --save-dev cpr`
556
+
557
+ ---
558
+
520
559
  ### Configuration Git
521
560
 
522
561
  Il est recommandé d'ignorer les fichiers générés par Intlayer. Cela vous permet d'éviter de les committer dans votre dépôt Git.
@@ -106,14 +106,27 @@ export default config;
106
106
  अपने कॉन्फ़िगरेशन में intlayer प्लगइन जोड़ें:
107
107
 
108
108
  ```typescript fileName="vite.config.ts"
109
- import { reactRouter } from "@react-router/dev/vite";
109
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
110
+ import viteReact from "@vitejs/plugin-react";
111
+ import { nitro } from "nitro/vite";
110
112
  import { defineConfig } from "vite";
111
- import { intlayer } from "vite-intlayer";
112
- import tsconfigPaths from "vite-tsconfig-paths";
113
+ import { intlayer, intlayerProxy } from "vite-intlayer";
114
+ import viteTsConfigPaths from "vite-tsconfig-paths";
113
115
 
114
- export default defineConfig({
115
- plugins: [reactRouter(), tsconfigPaths(), intlayer()],
116
+ const config = defineConfig({
117
+ plugins: [
118
+ nitro(),
119
+ viteTsConfigPaths({
120
+ projects: ["./tsconfig.json"],
121
+ }),
122
+ tanstackStart(),
123
+ viteReact(),
124
+ intlayer(), // To make intlayer work
125
+ intlayerProxy(), // To redirect the user to his own locale
126
+ ],
116
127
  });
128
+
129
+ export default config;
117
130
  ```
118
131
 
119
132
  > `intlayer()` Vite प्लगइन का उपयोग Intlayer को Vite के साथ एकीकृत करने के लिए किया जाता है। यह कंटेंट घोषणा फ़ाइलों के निर्माण को सुनिश्चित करता है और विकास मोड में उनकी निगरानी करता है। यह Vite एप्लिकेशन के भीतर Intlayer पर्यावरण चर को परिभाषित करता है। इसके अतिरिक्त, यह प्रदर्शन को अनुकूलित करने के लिए उपनाम प्रदान करता है।
@@ -139,7 +152,7 @@ function LayoutComponent() {
139
152
  const { locale } = Route.useParams();
140
153
 
141
154
  return (
142
- <IntlayerProvider locale={defaultLocale}>
155
+ <IntlayerProvider locale={locale ?? defaultLocale}>
143
156
  <Outlet />
144
157
  </IntlayerProvider>
145
158
  );
@@ -509,6 +522,32 @@ Intlayer टाइपस्क्रिप्ट के लाभ प्रा
509
522
 
510
523
  ---
511
524
 
525
+ ### चरण 13: Nitro को अनुकूलित करें (वैकल्पिक)
526
+
527
+ यदि आप अपने उत्पादन आउटपुट के लिए Nitro का उपयोग कर रहे हैं, तो nitro आउटपुट डायरेक्टरी में `.intlayer` डायरेक्टरी को शामिल नहीं करेगा। आपको इसे मैन्युअल रूप से कॉपी करना होगा।
528
+
529
+ बिल्ड स्क्रिप्ट का उपयोग करते हुए उदाहरण:
530
+
531
+ ```json5 fileName="package.json"
532
+ {
533
+ "scripts": {
534
+ "dev": "vite dev --port 3000",
535
+ "build": "vite build && cpr .intlayer .output/.intlayer", // .intlayer फ़ोल्डर कॉपी करें
536
+ "serve": "vite preview",
537
+ },
538
+ }
539
+ ```
540
+
541
+ > cpr का उपयोग कमांड को Windows पर काम करने के लिए अनुकूलित करने के लिए किया जाता है।
542
+ > इस कमांड का उपयोग करने के लिए आपको `cpr` उपयोगिता इंस्टॉल करनी होगी।
543
+ >
544
+ > - `npm install --save-dev cpr`
545
+ > - `yarn add --dev cpr`
546
+ > - `pnpm add --save-dev cpr`
547
+ > - `bun add --save-dev cpr`
548
+
549
+ ---
550
+
512
551
  ### गिट कॉन्फ़िगरेशन
513
552
 
514
553
  यह अनुशंसित है कि Intlayer द्वारा जनरेट की गई फाइलों को अनदेखा किया जाए। इससे आप उन्हें अपनी गिट रिपॉजिटरी में कमिट करने से बच सकते हैं।
@@ -114,14 +114,27 @@ export default config;
114
114
  Tambahkan plugin intlayer ke dalam konfigurasi Anda:
115
115
 
116
116
  ```typescript fileName="vite.config.ts"
117
- import { reactRouter } from "@react-router/dev/vite";
117
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
118
+ import viteReact from "@vitejs/plugin-react";
119
+ import { nitro } from "nitro/vite";
118
120
  import { defineConfig } from "vite";
119
- import { intlayer } from "vite-intlayer";
120
- import tsconfigPaths from "vite-tsconfig-paths";
121
+ import { intlayer, intlayerProxy } from "vite-intlayer";
122
+ import viteTsConfigPaths from "vite-tsconfig-paths";
121
123
 
122
- export default defineConfig({
123
- plugins: [reactRouter(), tsconfigPaths(), intlayer()],
124
+ const config = defineConfig({
125
+ plugins: [
126
+ nitro(),
127
+ viteTsConfigPaths({
128
+ projects: ["./tsconfig.json"],
129
+ }),
130
+ tanstackStart(),
131
+ viteReact(),
132
+ intlayer(), // To make intlayer work
133
+ intlayerProxy(), // To redirect the user to his own locale
134
+ ],
124
135
  });
136
+
137
+ export default config;
125
138
  ```
126
139
 
127
140
  > Plugin Vite `intlayer()` digunakan untuk mengintegrasikan Intlayer dengan Vite. Plugin ini memastikan pembuatan file deklarasi konten dan memantau file tersebut dalam mode pengembangan. Plugin ini juga mendefinisikan variabel lingkungan Intlayer di dalam aplikasi Vite. Selain itu, plugin ini menyediakan alias untuk mengoptimalkan performa.
@@ -147,7 +160,7 @@ function LayoutComponent() {
147
160
  const { locale } = Route.useParams();
148
161
 
149
162
  return (
150
- <IntlayerProvider locale={defaultLocale}>
163
+ <IntlayerProvider locale={locale ?? defaultLocale}>
151
164
  <Outlet />
152
165
  </IntlayerProvider>
153
166
  );
@@ -521,6 +534,32 @@ Pastikan konfigurasi TypeScript Anda menyertakan tipe yang dihasilkan secara oto
521
534
 
522
535
  ---
523
536
 
537
+ ### Langkah 13: Menyesuaikan Nitro (Opsional)
538
+
539
+ Jika Anda menggunakan Nitro untuk output produksi Anda, nitro tidak akan menyertakan direktori `.intlayer` dalam direktori output. Anda perlu menyalinnya secara manual.
540
+
541
+ Contoh menggunakan script build:
542
+
543
+ ```json5 fileName="package.json"
544
+ {
545
+ "scripts": {
546
+ "dev": "vite dev --port 3000",
547
+ "build": "vite build && cpr -r .intlayer .output/.intlayer", // Salin folder .intlayer
548
+ "serve": "vite preview",
549
+ },
550
+ }
551
+ ```
552
+
553
+ > cpr digunakan untuk mengadaptasi perintah agar berfungsi di Windows.
554
+ > Anda harus menginstal utilitas `cpr` untuk menggunakan perintah ini.
555
+ >
556
+ > - `npm install --save-dev cpr`
557
+ > - `yarn add --dev cpr`
558
+ > - `pnpm add --save-dev cpr`
559
+ > - `bun add --save-dev cpr`
560
+
561
+ ---
562
+
524
563
  ### Konfigurasi Git
525
564
 
526
565
  Disarankan untuk mengabaikan file yang dihasilkan oleh Intlayer. Ini memungkinkan Anda menghindari meng-commit file tersebut ke repositori Git Anda.