@intlayer/docs 6.1.6-canary.0 → 6.1.6
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/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +71 -80
- package/dist/cjs/generated/docs.entry.cjs +16 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +16 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_angular.md +2 -2
- package/docs/ar/intlayer_with_astro.md +246 -0
- package/docs/ar/intlayer_with_create_react_app.md +3 -2
- package/docs/ar/intlayer_with_express.md +2 -2
- package/docs/ar/intlayer_with_nestjs.md +2 -2
- package/docs/ar/intlayer_with_nextjs_14.md +2 -2
- package/docs/ar/intlayer_with_nextjs_15.md +2 -2
- package/docs/ar/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ar/intlayer_with_nuxt.md +2 -2
- package/docs/ar/intlayer_with_react_native+expo.md +11 -20
- package/docs/ar/intlayer_with_react_router_v7.md +195 -241
- package/docs/ar/intlayer_with_tanstack.md +198 -272
- package/docs/ar/intlayer_with_vite+preact.md +9 -9
- package/docs/ar/intlayer_with_vite+react.md +7 -7
- package/docs/ar/intlayer_with_vite+vue.md +9 -9
- package/docs/de/intlayer_with_angular.md +2 -2
- package/docs/de/intlayer_with_astro.md +246 -0
- package/docs/de/intlayer_with_create_react_app.md +2 -2
- package/docs/de/intlayer_with_express.md +2 -2
- package/docs/de/intlayer_with_nestjs.md +2 -2
- package/docs/de/intlayer_with_nextjs_14.md +2 -2
- package/docs/de/intlayer_with_nextjs_15.md +2 -2
- package/docs/de/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/de/intlayer_with_nuxt.md +2 -2
- package/docs/de/intlayer_with_react_native+expo.md +11 -20
- package/docs/de/intlayer_with_react_router_v7.md +193 -242
- package/docs/de/intlayer_with_tanstack.md +194 -266
- package/docs/de/intlayer_with_vite+preact.md +9 -9
- package/docs/de/intlayer_with_vite+react.md +9 -9
- package/docs/de/intlayer_with_vite+vue.md +11 -11
- package/docs/de/packages/vite-intlayer/index.md +3 -3
- package/docs/en/how_works_intlayer.md +1 -1
- package/docs/en/index.md +1 -1
- package/docs/en/intlayer_cli.md +1 -1
- package/docs/en/intlayer_with_angular.md +4 -4
- package/docs/en/intlayer_with_astro.md +246 -0
- package/docs/en/intlayer_with_create_react_app.md +4 -4
- package/docs/en/intlayer_with_express.md +3 -3
- package/docs/en/intlayer_with_lynx+react.md +1 -1
- package/docs/en/intlayer_with_nestjs.md +2 -2
- package/docs/en/intlayer_with_nextjs_14.md +13 -4
- package/docs/en/intlayer_with_nextjs_15.md +13 -4
- package/docs/en/intlayer_with_nextjs_page_router.md +5 -5
- package/docs/en/intlayer_with_nuxt.md +4 -4
- package/docs/en/intlayer_with_react_native+expo.md +46 -24
- package/docs/en/intlayer_with_react_router_v7.md +164 -211
- package/docs/en/intlayer_with_tanstack.md +166 -241
- package/docs/en/intlayer_with_vite+preact.md +12 -12
- package/docs/en/intlayer_with_vite+react.md +12 -12
- package/docs/en/intlayer_with_vite+solid.md +2 -2
- package/docs/en/intlayer_with_vite+svelte.md +2 -2
- package/docs/en/intlayer_with_vite+vue.md +12 -12
- package/docs/en/introduction.md +1 -1
- package/docs/en/packages/next-intlayer/useDictionary.md +1 -1
- package/docs/en/packages/next-intlayer/useIntlayer.md +1 -1
- package/docs/en/packages/react-intlayer/useDictionary.md +1 -1
- package/docs/en/packages/react-intlayer/useI18n.md +1 -1
- package/docs/en/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/en/releases/v6.md +1 -0
- package/docs/en/roadmap.md +1 -1
- package/docs/en-GB/intlayer_with_angular.md +3 -3
- package/docs/en-GB/intlayer_with_astro.md +246 -0
- package/docs/en-GB/intlayer_with_create_react_app.md +5 -4
- package/docs/en-GB/intlayer_with_express.md +2 -2
- package/docs/en-GB/intlayer_with_nestjs.md +2 -2
- package/docs/en-GB/intlayer_with_nextjs_14.md +4 -4
- package/docs/en-GB/intlayer_with_nextjs_15.md +2 -2
- package/docs/en-GB/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/en-GB/intlayer_with_nuxt.md +2 -2
- package/docs/en-GB/intlayer_with_react_native+expo.md +11 -20
- package/docs/en-GB/intlayer_with_react_router_v7.md +171 -220
- package/docs/en-GB/intlayer_with_tanstack.md +174 -248
- package/docs/en-GB/intlayer_with_vite+preact.md +9 -9
- package/docs/en-GB/intlayer_with_vite+react.md +9 -9
- package/docs/en-GB/intlayer_with_vite+vue.md +11 -11
- package/docs/en-GB/packages/next-intlayer/useIntlayer.md +1 -1
- package/docs/en-GB/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/es/intlayer_with_angular.md +2 -2
- package/docs/es/intlayer_with_astro.md +246 -0
- package/docs/es/intlayer_with_create_react_app.md +3 -2
- package/docs/es/intlayer_with_express.md +2 -2
- package/docs/es/intlayer_with_nextjs_14.md +2 -2
- package/docs/es/intlayer_with_nextjs_15.md +2 -2
- package/docs/es/intlayer_with_react_native+expo.md +11 -20
- package/docs/es/intlayer_with_react_router_v7.md +188 -232
- package/docs/es/intlayer_with_tanstack.md +203 -273
- package/docs/es/intlayer_with_vite+preact.md +7 -7
- package/docs/es/intlayer_with_vite+react.md +7 -7
- package/docs/es/intlayer_with_vite+vue.md +9 -9
- package/docs/fr/intlayer_with_angular.md +2 -2
- package/docs/fr/intlayer_with_astro.md +246 -0
- package/docs/fr/intlayer_with_create_react_app.md +3 -2
- package/docs/fr/intlayer_with_express.md +2 -2
- package/docs/fr/intlayer_with_nestjs.md +2 -2
- package/docs/fr/intlayer_with_nextjs_14.md +2 -2
- package/docs/fr/intlayer_with_react_native+expo.md +11 -20
- package/docs/fr/intlayer_with_react_router_v7.md +188 -248
- package/docs/fr/intlayer_with_tanstack.md +192 -265
- package/docs/fr/intlayer_with_vite+preact.md +7 -7
- package/docs/fr/intlayer_with_vite+react.md +7 -7
- package/docs/fr/intlayer_with_vite+vue.md +9 -9
- package/docs/hi/intlayer_cli.md +1 -4
- package/docs/hi/intlayer_with_angular.md +2 -2
- package/docs/hi/intlayer_with_astro.md +246 -0
- package/docs/hi/intlayer_with_create_react_app.md +2 -2
- package/docs/hi/intlayer_with_express.md +2 -2
- package/docs/hi/intlayer_with_nestjs.md +2 -2
- package/docs/hi/intlayer_with_nextjs_14.md +2 -2
- package/docs/hi/intlayer_with_nextjs_15.md +2 -2
- package/docs/hi/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/hi/intlayer_with_nuxt.md +2 -2
- package/docs/hi/intlayer_with_react_native+expo.md +11 -20
- package/docs/hi/intlayer_with_react_router_v7.md +199 -243
- package/docs/hi/intlayer_with_tanstack.md +210 -285
- package/docs/hi/intlayer_with_vite+preact.md +9 -9
- package/docs/hi/intlayer_with_vite+react.md +9 -9
- package/docs/hi/intlayer_with_vite+solid.md +1 -1
- package/docs/hi/intlayer_with_vite+vue.md +11 -11
- package/docs/it/intlayer_with_angular.md +2 -2
- package/docs/it/intlayer_with_astro.md +246 -0
- package/docs/it/intlayer_with_create_react_app.md +3 -2
- package/docs/it/intlayer_with_express.md +2 -2
- package/docs/it/intlayer_with_nestjs.md +2 -2
- package/docs/it/intlayer_with_nextjs_14.md +2 -2
- package/docs/it/intlayer_with_nextjs_15.md +2 -2
- package/docs/it/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/it/intlayer_with_nuxt.md +2 -2
- package/docs/it/intlayer_with_react_native+expo.md +11 -21
- package/docs/it/intlayer_with_react_router_v7.md +195 -242
- package/docs/it/intlayer_with_tanstack.md +203 -267
- package/docs/it/intlayer_with_vite+preact.md +9 -9
- package/docs/it/intlayer_with_vite+react.md +13 -11
- package/docs/it/intlayer_with_vite+vue.md +11 -11
- package/docs/ja/intlayer_with_angular.md +2 -2
- package/docs/ja/intlayer_with_astro.md +246 -0
- package/docs/ja/intlayer_with_create_react_app.md +3 -2
- package/docs/ja/intlayer_with_express.md +2 -2
- package/docs/ja/intlayer_with_nestjs.md +2 -2
- package/docs/ja/intlayer_with_nextjs_14.md +2 -2
- package/docs/ja/intlayer_with_nextjs_15.md +2 -2
- package/docs/ja/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ja/intlayer_with_nuxt.md +2 -2
- package/docs/ja/intlayer_with_react_native+expo.md +18 -29
- package/docs/ja/intlayer_with_react_router_v7.md +204 -250
- package/docs/ja/intlayer_with_tanstack.md +218 -286
- package/docs/ja/intlayer_with_vite+preact.md +9 -9
- package/docs/ja/intlayer_with_vite+react.md +11 -11
- package/docs/ja/intlayer_with_vite+vue.md +11 -11
- package/docs/ko/intlayer_with_angular.md +2 -2
- package/docs/ko/intlayer_with_astro.md +246 -0
- package/docs/ko/intlayer_with_create_react_app.md +3 -2
- package/docs/ko/intlayer_with_express.md +2 -2
- package/docs/ko/intlayer_with_nestjs.md +2 -2
- package/docs/ko/intlayer_with_nextjs_14.md +2 -2
- package/docs/ko/intlayer_with_nextjs_15.md +2 -2
- package/docs/ko/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ko/intlayer_with_nuxt.md +2 -2
- package/docs/ko/intlayer_with_react_native+expo.md +19 -28
- package/docs/ko/intlayer_with_react_router_v7.md +190 -244
- package/docs/ko/intlayer_with_tanstack.md +200 -270
- package/docs/ko/intlayer_with_vite+preact.md +9 -9
- package/docs/ko/intlayer_with_vite+react.md +9 -9
- package/docs/ko/intlayer_with_vite+vue.md +11 -11
- package/docs/pt/intlayer_with_angular.md +2 -2
- package/docs/pt/intlayer_with_astro.md +246 -0
- package/docs/pt/intlayer_with_create_react_app.md +3 -2
- package/docs/pt/intlayer_with_express.md +2 -2
- package/docs/pt/intlayer_with_nestjs.md +2 -2
- package/docs/pt/intlayer_with_nextjs_14.md +2 -2
- package/docs/pt/intlayer_with_nextjs_15.md +2 -2
- package/docs/pt/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/pt/intlayer_with_nuxt.md +2 -2
- package/docs/pt/intlayer_with_react_native+expo.md +11 -20
- package/docs/pt/intlayer_with_react_router_v7.md +7 -13
- package/docs/pt/intlayer_with_tanstack.md +183 -258
- package/docs/pt/intlayer_with_vite+preact.md +9 -9
- package/docs/pt/intlayer_with_vite+react.md +9 -9
- package/docs/pt/intlayer_with_vite+vue.md +9 -9
- package/docs/ru/intlayer_with_angular.md +2 -2
- package/docs/ru/intlayer_with_astro.md +246 -0
- package/docs/ru/intlayer_with_create_react_app.md +3 -2
- package/docs/ru/intlayer_with_express.md +2 -2
- package/docs/ru/intlayer_with_nestjs.md +2 -2
- package/docs/ru/intlayer_with_nextjs_14.md +2 -2
- package/docs/ru/intlayer_with_nextjs_15.md +2 -2
- package/docs/ru/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ru/intlayer_with_nuxt.md +2 -2
- package/docs/ru/intlayer_with_react_native+expo.md +11 -20
- package/docs/ru/intlayer_with_react_router_v7.md +192 -238
- package/docs/ru/intlayer_with_tanstack.md +197 -269
- package/docs/ru/intlayer_with_vite+preact.md +9 -9
- package/docs/ru/intlayer_with_vite+react.md +9 -9
- package/docs/ru/intlayer_with_vite+vue.md +11 -11
- package/docs/tr/how_works_intlayer.md +1 -1
- package/docs/tr/index.md +1 -1
- package/docs/tr/intlayer_cli.md +1 -1
- package/docs/tr/intlayer_with_angular.md +4 -4
- package/docs/tr/intlayer_with_astro.md +246 -0
- package/docs/tr/intlayer_with_create_react_app.md +4 -4
- package/docs/tr/intlayer_with_express.md +3 -3
- package/docs/tr/intlayer_with_lynx+react.md +1 -1
- package/docs/tr/intlayer_with_nestjs.md +2 -2
- package/docs/tr/intlayer_with_nextjs_14.md +2 -2
- package/docs/tr/intlayer_with_nextjs_15.md +4 -4
- package/docs/tr/intlayer_with_nextjs_page_router.md +5 -5
- package/docs/tr/intlayer_with_nuxt.md +4 -4
- package/docs/tr/intlayer_with_react_native+expo.md +12 -21
- package/docs/tr/intlayer_with_react_router_v7.md +222 -267
- package/docs/tr/intlayer_with_tanstack.md +400 -303
- package/docs/tr/intlayer_with_vite+preact.md +12 -12
- package/docs/tr/intlayer_with_vite+react.md +12 -12
- package/docs/tr/intlayer_with_vite+solid.md +2 -2
- package/docs/tr/intlayer_with_vite+svelte.md +2 -2
- package/docs/tr/intlayer_with_vite+vue.md +12 -12
- package/docs/tr/introduction.md +1 -1
- package/docs/tr/packages/react-intlayer/useDictionary.md +1 -1
- package/docs/tr/packages/react-intlayer/useI18n.md +1 -1
- package/docs/tr/roadmap.md +1 -1
- package/docs/zh/intlayer_with_angular.md +2 -2
- package/docs/zh/intlayer_with_astro.md +246 -0
- package/docs/zh/intlayer_with_create_react_app.md +3 -2
- package/docs/zh/intlayer_with_express.md +2 -2
- package/docs/zh/intlayer_with_nestjs.md +2 -2
- package/docs/zh/intlayer_with_nextjs_14.md +2 -2
- package/docs/zh/intlayer_with_nextjs_15.md +2 -2
- package/docs/zh/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/zh/intlayer_with_nuxt.md +2 -2
- package/docs/zh/intlayer_with_react_native+expo.md +19 -28
- package/docs/zh/intlayer_with_react_router_v7.md +200 -248
- package/docs/zh/intlayer_with_tanstack.md +208 -283
- package/docs/zh/intlayer_with_vite+preact.md +9 -9
- package/docs/zh/intlayer_with_vite+react.md +9 -9
- package/docs/zh/intlayer_with_vite+vue.md +9 -9
- package/package.json +11 -11
- package/src/generated/docs.entry.ts +16 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-09-04
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-10-03
|
|
4
4
|
title: Iniziare con Intlayer in React Router v7
|
|
5
5
|
description: Scopri come aggiungere l'internazionalizzazione (i18n) alla tua applicazione React Router v7 utilizzando Intlayer. Segui questa guida completa per rendere la tua app multilingue con il routing consapevole della localizzazione.
|
|
6
6
|
keywords:
|
|
@@ -17,11 +17,10 @@ slugs:
|
|
|
17
17
|
- environment
|
|
18
18
|
- vite-and-react
|
|
19
19
|
- react-router-v7
|
|
20
|
-
applicationTemplate: https://github.com/
|
|
21
|
-
author: AydinTheFirst
|
|
20
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-react-router-v7-template
|
|
22
21
|
---
|
|
23
22
|
|
|
24
|
-
# Iniziare con l'internazionalizzazione (i18n)
|
|
23
|
+
# Iniziare con l'internazionalizzazione (i18n) con Intlayer e React Router v7
|
|
25
24
|
|
|
26
25
|
Questa guida dimostra come integrare **Intlayer** per un'internazionalizzazione senza soluzione di continuità nei progetti React Router v7 con routing consapevole della localizzazione, supporto TypeScript e pratiche di sviluppo moderne.
|
|
27
26
|
|
|
@@ -32,7 +31,7 @@ Questa guida dimostra come integrare **Intlayer** per un'internazionalizzazione
|
|
|
32
31
|
Con Intlayer, puoi:
|
|
33
32
|
|
|
34
33
|
- **Gestire facilmente le traduzioni** utilizzando dizionari dichiarativi a livello di componente.
|
|
35
|
-
- **Localizzare dinamicamente
|
|
34
|
+
- **Localizzare dinamicamente i metadata**, le rotte e i contenuti.
|
|
36
35
|
- **Garantire il supporto TypeScript** con tipi generati automaticamente, migliorando l'autocompletamento e il rilevamento degli errori.
|
|
37
36
|
- **Beneficiare di funzionalità avanzate**, come il rilevamento e il cambio dinamico della localizzazione.
|
|
38
37
|
- **Abilitare il routing consapevole della localizzazione** con il sistema di routing basato su configurazione di React Router v7.
|
|
@@ -43,7 +42,7 @@ Con Intlayer, puoi:
|
|
|
43
42
|
|
|
44
43
|
### Passo 1: Installare le dipendenze
|
|
45
44
|
|
|
46
|
-
Installa i pacchetti necessari
|
|
45
|
+
Installa i pacchetti necessari usando il tuo gestore di pacchetti preferito:
|
|
47
46
|
|
|
48
47
|
```bash packageManager="npm"
|
|
49
48
|
npm install intlayer react-intlayer
|
|
@@ -57,19 +56,17 @@ pnpm add vite-intlayer --save-dev
|
|
|
57
56
|
|
|
58
57
|
- **intlayer**
|
|
59
58
|
|
|
60
|
-
- **intlayer
|
|
61
|
-
|
|
62
|
-
Il pacchetto principale che fornisce strumenti di internazionalizzazione per la gestione della configurazione, la traduzione, la [dichiarazione dei contenuti](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md), la traspilazione e i [comandi CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_cli.md).
|
|
59
|
+
- **Il pacchetto core** che fornisce strumenti di internazionalizzazione per la gestione della configurazione, la traduzione, la [dichiarazione dei contenuti](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md), la traspilazione e i [comandi CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_cli.md).
|
|
63
60
|
|
|
64
|
-
- **react-intlayer**
|
|
61
|
+
- **react-intlayer**
|
|
65
62
|
Il pacchetto che integra Intlayer con l'applicazione React. Fornisce provider di contesto e hook per l'internazionalizzazione in React.
|
|
66
63
|
|
|
67
|
-
- **vite-intlayer**
|
|
68
|
-
Include il plugin Vite per integrare Intlayer con il [bundler Vite](https://vite.dev/guide/why.html#why-bundle-for-production), oltre a middleware per rilevare la
|
|
64
|
+
- **vite-intlayer**
|
|
65
|
+
Include il plugin Vite per integrare Intlayer con il [bundler Vite](https://vite.dev/guide/why.html#why-bundle-for-production), oltre a middleware per rilevare la locale preferita dall'utente, gestire i cookie e gestire il reindirizzamento degli URL.
|
|
69
66
|
|
|
70
67
|
### Passo 2: Configurazione del tuo progetto
|
|
71
68
|
|
|
72
|
-
Crea un file di configurazione per
|
|
69
|
+
Crea un file di configurazione per impostare le lingue della tua applicazione:
|
|
73
70
|
|
|
74
71
|
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
75
72
|
import { type IntlayerConfig, Locales } from "intlayer";
|
|
@@ -77,10 +74,7 @@ import { type IntlayerConfig, Locales } from "intlayer";
|
|
|
77
74
|
const config: IntlayerConfig = {
|
|
78
75
|
internationalization: {
|
|
79
76
|
defaultLocale: Locales.ENGLISH,
|
|
80
|
-
locales: [Locales.ENGLISH, Locales.
|
|
81
|
-
},
|
|
82
|
-
middleware: {
|
|
83
|
-
prefixDefault: true, // Prefissa sempre la lingua predefinita negli URL
|
|
77
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
84
78
|
},
|
|
85
79
|
};
|
|
86
80
|
|
|
@@ -91,13 +85,11 @@ export default config;
|
|
|
91
85
|
import { Locales } from "intlayer";
|
|
92
86
|
|
|
93
87
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
88
|
+
// Configurazione per l'internazionalizzazione
|
|
94
89
|
const config = {
|
|
95
90
|
internationalization: {
|
|
96
91
|
defaultLocale: Locales.ENGLISH,
|
|
97
|
-
locales: [Locales.ENGLISH, Locales.
|
|
98
|
-
},
|
|
99
|
-
middleware: {
|
|
100
|
-
prefixDefault: true,
|
|
92
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
101
93
|
},
|
|
102
94
|
};
|
|
103
95
|
|
|
@@ -112,82 +104,75 @@ const { Locales } = require("intlayer");
|
|
|
112
104
|
const config = {
|
|
113
105
|
internationalization: {
|
|
114
106
|
defaultLocale: Locales.ENGLISH, // Lingua predefinita
|
|
115
|
-
locales: [Locales.ENGLISH, Locales.
|
|
116
|
-
},
|
|
117
|
-
middleware: {
|
|
118
|
-
prefixDefault: true, // Prefissa sempre la lingua predefinita negli URL
|
|
107
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], // Lingue supportate
|
|
119
108
|
},
|
|
120
109
|
};
|
|
121
110
|
|
|
122
111
|
module.exports = config;
|
|
123
112
|
```
|
|
124
113
|
|
|
125
|
-
> Attraverso questo file di configurazione, puoi impostare URL localizzati, reindirizzamenti middleware, nomi dei cookie, la posizione e l'estensione delle
|
|
126
|
-
|
|
127
|
-
### Passo 3: Configurare le Rotte di React Router v7
|
|
128
|
-
|
|
129
|
-
Configura la tua configurazione di routing con rotte consapevoli della localizzazione:
|
|
130
|
-
|
|
131
|
-
```typescript fileName="app/routes.ts" codeFormat="typescript"
|
|
132
|
-
import { layout, route, type RouteConfig } from "@react-router/dev/routes";
|
|
133
|
-
|
|
134
|
-
export default [
|
|
135
|
-
layout("routes/layout.tsx", [
|
|
136
|
-
route("/", "routes/page.tsx"), // Pagina radice - reindirizza alla localizzazione
|
|
137
|
-
route("/:lang", "routes/[lang]/page.tsx"), // Pagina iniziale localizzata
|
|
138
|
-
route("/:lang/about", "routes/[lang]/about/page.tsx"), // Pagina "about" localizzata
|
|
139
|
-
]),
|
|
140
|
-
] satisfies RouteConfig;
|
|
141
|
-
```
|
|
114
|
+
> Attraverso questo file di configurazione, puoi impostare URL localizzati, reindirizzamenti middleware, nomi dei cookie, la posizione e l'estensione delle dichiarazioni di contenuto, disabilitare i log di Intlayer nella console e altro ancora. Per un elenco completo dei parametri disponibili, consulta la [documentazione di configurazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/configuration.md).
|
|
142
115
|
|
|
143
|
-
### Passo
|
|
116
|
+
### Passo 3: Integra Intlayer nella tua configurazione Vite
|
|
144
117
|
|
|
145
118
|
Aggiungi il plugin intlayer nella tua configurazione:
|
|
146
119
|
|
|
147
|
-
```typescript fileName="vite.config.ts"
|
|
120
|
+
```typescript fileName="vite.config.ts"
|
|
148
121
|
import { reactRouter } from "@react-router/dev/vite";
|
|
149
122
|
import { defineConfig } from "vite";
|
|
150
|
-
import {
|
|
123
|
+
import { intlayer } from "vite-intlayer";
|
|
151
124
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
152
125
|
|
|
153
126
|
export default defineConfig({
|
|
154
|
-
plugins: [
|
|
155
|
-
reactRouter(),
|
|
156
|
-
tsconfigPaths(),
|
|
157
|
-
intlayer(),
|
|
158
|
-
intlayerMiddlewarePlugin(),
|
|
159
|
-
],
|
|
127
|
+
plugins: [reactRouter(), tsconfigPaths(), intlayer()],
|
|
160
128
|
});
|
|
161
129
|
```
|
|
162
130
|
|
|
163
|
-
> Il plugin Vite `intlayer()` viene utilizzato per integrare Intlayer con Vite. Garantisce la creazione dei file di dichiarazione
|
|
131
|
+
> Il plugin Vite `intlayer()` viene utilizzato per integrare Intlayer con Vite. Garantisce la creazione dei file di dichiarazione dei contenuti e li monitora in modalità sviluppo. Definisce le variabili d'ambiente di Intlayer all'interno dell'applicazione Vite. Inoltre, fornisce alias per ottimizzare le prestazioni.
|
|
132
|
+
|
|
133
|
+
### Passo 4: Configurare le rotte di React Router v7
|
|
164
134
|
|
|
165
|
-
|
|
135
|
+
Configura la tua configurazione di routing con rotte consapevoli della localizzazione:
|
|
136
|
+
|
|
137
|
+
```typescript fileName="app/routes.ts"
|
|
138
|
+
import { layout, route, type RouteConfig } from "@react-router/dev/routes";
|
|
139
|
+
|
|
140
|
+
export default [
|
|
141
|
+
layout("routes/layout.tsx", [
|
|
142
|
+
route("/:lang?", "routes/page.tsx"), // Pagina iniziale localizzata
|
|
143
|
+
route("/:lang?/about", "routes/about/page.tsx"), // Pagina "about" localizzata
|
|
144
|
+
]),
|
|
145
|
+
] satisfies RouteConfig;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Passo 5: Crea i Componenti di Layout
|
|
166
149
|
|
|
167
150
|
Configura il layout principale e i layout specifici per la localizzazione:
|
|
168
151
|
|
|
169
152
|
#### Layout Principale
|
|
170
153
|
|
|
171
|
-
```tsx fileName="app/routes/layout.tsx"
|
|
172
|
-
tsx fileName="app/routes/layout.tsx" codeFormat="typescript"
|
|
173
|
-
// app/routes/layout.tsx
|
|
174
|
-
import { Outlet } from "react-router";
|
|
154
|
+
```tsx fileName="app/routes/layout.tsx"
|
|
175
155
|
import { IntlayerProvider } from "react-intlayer";
|
|
156
|
+
import { Outlet } from "react-router";
|
|
157
|
+
|
|
158
|
+
import type { Route } from "./+types/layout";
|
|
159
|
+
|
|
160
|
+
export default function RootLayout({ params }: Route.ComponentProps) {
|
|
161
|
+
const { locale } = params;
|
|
176
162
|
|
|
177
|
-
export default function RootLayout() {
|
|
178
163
|
return (
|
|
179
|
-
<IntlayerProvider>
|
|
164
|
+
<IntlayerProvider locale={locale}>
|
|
180
165
|
<Outlet />
|
|
181
166
|
</IntlayerProvider>
|
|
182
167
|
);
|
|
183
168
|
}
|
|
184
169
|
```
|
|
185
170
|
|
|
186
|
-
### Passo 6:
|
|
171
|
+
### Passo 6: Dichiarare il Tuo Contenuto
|
|
187
172
|
|
|
188
173
|
Crea e gestisci le tue dichiarazioni di contenuto per memorizzare le traduzioni:
|
|
189
174
|
|
|
190
|
-
```tsx fileName="app/routes/[lang]/page.content.ts"
|
|
175
|
+
```tsx fileName="app/routes/[lang]/page.content.ts"
|
|
191
176
|
import { t, type Dictionary } from "intlayer";
|
|
192
177
|
|
|
193
178
|
const pageContent = {
|
|
@@ -195,19 +180,23 @@ const pageContent = {
|
|
|
195
180
|
content: {
|
|
196
181
|
title: t({
|
|
197
182
|
en: "Welcome to React Router v7 + Intlayer",
|
|
198
|
-
|
|
183
|
+
es: "Bienvenido a React Router v7 + Intlayer",
|
|
184
|
+
fr: "Bienvenue sur React Router v7 + Intlayer",
|
|
199
185
|
}),
|
|
200
186
|
description: t({
|
|
201
187
|
en: "Build multilingual applications with ease using React Router v7 and Intlayer.",
|
|
202
|
-
|
|
188
|
+
es: "Cree aplicaciones multilingües fácilmente usando React Router v7 y Intlayer.",
|
|
189
|
+
fr: "Créez des applications multilingues facilement avec React Router v7 et Intlayer.",
|
|
203
190
|
}),
|
|
204
191
|
aboutLink: t({
|
|
205
|
-
en: "
|
|
206
|
-
|
|
192
|
+
en: "Learn About Us",
|
|
193
|
+
es: "Aprender Sobre Nosotros",
|
|
194
|
+
fr: "En savoir plus sur nous",
|
|
207
195
|
}),
|
|
208
196
|
homeLink: t({
|
|
209
197
|
en: "Home",
|
|
210
|
-
|
|
198
|
+
es: "Inicio",
|
|
199
|
+
fr: "Accueil",
|
|
211
200
|
}),
|
|
212
201
|
},
|
|
213
202
|
} satisfies Dictionary;
|
|
@@ -215,104 +204,92 @@ const pageContent = {
|
|
|
215
204
|
export default pageContent;
|
|
216
205
|
```
|
|
217
206
|
|
|
218
|
-
> Le tue dichiarazioni di contenuto possono essere definite ovunque nella tua applicazione non appena
|
|
207
|
+
> Le tue dichiarazioni di contenuto possono essere definite ovunque nella tua applicazione non appena vengono incluse nella directory `contentDir` (per default, `./app`). E devono corrispondere all'estensione del file di dichiarazione del contenuto (per default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
219
208
|
|
|
220
209
|
> Per maggiori dettagli, consulta la [documentazione sulla dichiarazione del contenuto](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md).
|
|
221
210
|
|
|
222
211
|
### Passo 7: Crea Componenti Consapevoli della Locale
|
|
223
212
|
|
|
224
|
-
Crea un componente `LocalizedLink` per una navigazione consapevole della
|
|
213
|
+
Crea un componente `LocalizedLink` per una navigazione consapevole della locale:
|
|
225
214
|
|
|
226
|
-
```tsx fileName="app/components/localized-link.tsx"
|
|
227
|
-
|
|
228
|
-
import { getLocalizedUrl } from "intlayer";
|
|
229
|
-
import { useLocale } from "react-intlayer";
|
|
230
|
-
import React from "react";
|
|
231
|
-
import { Link, useLocation } from "react-router";
|
|
215
|
+
```tsx fileName="app/components/localized-link.tsx"
|
|
216
|
+
import type { FC } from "react";
|
|
232
217
|
|
|
233
|
-
type
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const { locale } = useLocale();
|
|
237
|
-
const location = useLocation();
|
|
218
|
+
import { getLocalizedUrl, type LocalesValues } from "intlayer";
|
|
219
|
+
import { useLocale } from "react-intlayer";
|
|
220
|
+
import { Link, type LinkProps, type To } from "react-router";
|
|
238
221
|
|
|
239
|
-
|
|
240
|
-
/^([a-z][a-z0-9+.-]*:)?\/\//i.test(path) || path.startsWith("mailto:");
|
|
222
|
+
const isExternalLink = (to: string) => /^(https?:)?\/\//.test(to);
|
|
241
223
|
|
|
224
|
+
// Funzione per localizzare l'URL in base alla lingua
|
|
225
|
+
export const locacalizeTo = (to: To, locale: LocalesValues): To => {
|
|
242
226
|
if (typeof to === "string") {
|
|
243
|
-
if (
|
|
244
|
-
return
|
|
227
|
+
if (isExternalLink(to)) {
|
|
228
|
+
return to;
|
|
245
229
|
}
|
|
246
|
-
|
|
230
|
+
|
|
231
|
+
return getLocalizedUrl(to, locale);
|
|
247
232
|
}
|
|
248
233
|
|
|
249
|
-
if (to
|
|
250
|
-
|
|
251
|
-
if (pathname && pathname.startsWith("/") && !isExternal(pathname)) {
|
|
252
|
-
return (
|
|
253
|
-
<Link
|
|
254
|
-
to={{ ...to, pathname: getLocalizedUrl(pathname, locale) }}
|
|
255
|
-
{...props}
|
|
256
|
-
/>
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
return <Link to={to} {...props} />;
|
|
234
|
+
if (isExternalLink(to.pathname ?? "")) {
|
|
235
|
+
return to;
|
|
260
236
|
}
|
|
261
237
|
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
```
|
|
238
|
+
return {
|
|
239
|
+
...to,
|
|
240
|
+
pathname: getLocalizedUrl(to.pathname ?? "", locale),
|
|
241
|
+
};
|
|
242
|
+
};
|
|
270
243
|
|
|
271
|
-
|
|
244
|
+
// Componente per link localizzati
|
|
245
|
+
export const LocalizedLink: FC<LinkProps> = (props) => {
|
|
246
|
+
const { locale } = useLocale();
|
|
272
247
|
|
|
273
|
-
|
|
248
|
+
return <Link {...props} to={locacalizeTo(props.to, locale)} />;
|
|
249
|
+
};
|
|
250
|
+
```
|
|
274
251
|
|
|
275
|
-
|
|
252
|
+
Nel caso in cui desideri navigare verso le rotte localizzate, puoi utilizzare l'hook `useLocalizedNavigate`:
|
|
276
253
|
|
|
277
|
-
```tsx fileName="app/
|
|
278
|
-
|
|
279
|
-
import {
|
|
280
|
-
import { Navigate } from "react-router";
|
|
254
|
+
```tsx fileName="app/hooks/useLocalizedNavigate.ts"
|
|
255
|
+
import { useLocale } from "intlayer";
|
|
256
|
+
import { type NavigateOptions, type To, useNavigate } from "react-router";
|
|
281
257
|
|
|
282
|
-
|
|
258
|
+
import { locacalizeTo } from "~/components/localized-link";
|
|
259
|
+
|
|
260
|
+
export const useLocalizedNavigate = () => {
|
|
261
|
+
const navigate = useNavigate();
|
|
283
262
|
const { locale } = useLocale();
|
|
284
263
|
|
|
285
|
-
|
|
286
|
-
|
|
264
|
+
const localizedNavigate = (to: To, options?: NavigateOptions) => {
|
|
265
|
+
const localedTo = locacalizeTo(to, locale);
|
|
266
|
+
|
|
267
|
+
navigate(localedTo, options);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
return localizedNavigate;
|
|
271
|
+
};
|
|
287
272
|
```
|
|
288
273
|
|
|
274
|
+
### Passo 8: Utilizza Intlayer nelle tue Pagine
|
|
275
|
+
|
|
276
|
+
Accedi ai tuoi dizionari di contenuti in tutta l'applicazione:
|
|
277
|
+
|
|
289
278
|
#### Pagina Home Localizzata
|
|
290
279
|
|
|
291
|
-
```tsx fileName="app/routes/[lang]/page.tsx"
|
|
280
|
+
```tsx fileName="app/routes/[lang]/page.tsx"
|
|
292
281
|
import { useIntlayer } from "react-intlayer";
|
|
293
|
-
import LocalizedLink from "~/components/localized-link";
|
|
282
|
+
import { LocalizedLink } from "~/components/localized-link";
|
|
294
283
|
|
|
295
284
|
export default function Page() {
|
|
296
|
-
const
|
|
285
|
+
const { title, description, aboutLink } = useIntlayer("page");
|
|
297
286
|
|
|
298
287
|
return (
|
|
299
|
-
<div
|
|
300
|
-
<h1>{
|
|
301
|
-
<p>{
|
|
302
|
-
<nav
|
|
303
|
-
<LocalizedLink
|
|
304
|
-
to="/about"
|
|
305
|
-
style={{
|
|
306
|
-
display: "inline-block",
|
|
307
|
-
padding: "0.5rem 1rem",
|
|
308
|
-
backgroundColor: "#007bff",
|
|
309
|
-
color: "white",
|
|
310
|
-
textDecoration: "none",
|
|
311
|
-
borderRadius: "4px",
|
|
312
|
-
}}
|
|
313
|
-
>
|
|
314
|
-
{content.aboutLink}
|
|
315
|
-
</LocalizedLink>
|
|
288
|
+
<div>
|
|
289
|
+
<h1>{title}</h1>
|
|
290
|
+
<p>{description}</p>
|
|
291
|
+
<nav>
|
|
292
|
+
<LocalizedLink to="/about">{aboutLink}</LocalizedLink>
|
|
316
293
|
</nav>
|
|
317
294
|
</div>
|
|
318
295
|
);
|
|
@@ -321,57 +298,71 @@ export default function Page() {
|
|
|
321
298
|
|
|
322
299
|
> Per saperne di più sull'hook `useIntlayer`, consulta la [documentazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/react-intlayer/useIntlayer.md).
|
|
323
300
|
|
|
324
|
-
### Passo 9: Crea un
|
|
301
|
+
### Passo 9: Crea un Componente per il Selettore di Lingua
|
|
325
302
|
|
|
326
303
|
Crea un componente per permettere agli utenti di cambiare lingua:
|
|
327
304
|
|
|
328
|
-
```tsx fileName="app/components/locale-switcher.tsx"
|
|
329
|
-
import {
|
|
330
|
-
import { useLocale } from "react-intlayer";
|
|
331
|
-
import { useLocation, useNavigate } from "react-router";
|
|
305
|
+
```tsx fileName="app/components/locale-switcher.tsx"
|
|
306
|
+
import type { FC } from "react";
|
|
332
307
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
308
|
+
import {
|
|
309
|
+
getHTMLTextDir,
|
|
310
|
+
getLocaleName,
|
|
311
|
+
getLocalizedUrl,
|
|
312
|
+
getPathWithoutLocale,
|
|
313
|
+
} from "intlayer";
|
|
314
|
+
import { setLocaleCookie, useIntlayer, useLocale } from "react-intlayer";
|
|
315
|
+
import { Link, useLocation } from "react-router";
|
|
337
316
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
};
|
|
317
|
+
export const LocaleSwitcher: FC = () => {
|
|
318
|
+
const { localeSwitcherLabel } = useIntlayer("locale-switcher");
|
|
319
|
+
const { pathname } = useLocation();
|
|
320
|
+
|
|
321
|
+
const { availableLocales, locale } = useLocale();
|
|
322
|
+
|
|
323
|
+
const pathWithoutLocale = getPathWithoutLocale(pathname);
|
|
346
324
|
|
|
347
325
|
return (
|
|
348
|
-
<
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
326
|
+
<ol>
|
|
327
|
+
{availableLocales.map((localeItem) => (
|
|
328
|
+
<li key={localeItem}>
|
|
329
|
+
<Link
|
|
330
|
+
aria-current={localeItem === locale ? "page" : undefined}
|
|
331
|
+
aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeItem)}`}
|
|
332
|
+
onClick={() => setLocaleCookie(localeItem)}
|
|
333
|
+
to={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
334
|
+
>
|
|
335
|
+
<span>
|
|
336
|
+
{/* Locale - es. FR */}
|
|
337
|
+
{localeItem}
|
|
338
|
+
</span>
|
|
339
|
+
<span>
|
|
340
|
+
{/* Lingua nella propria Locale - es. Français */}
|
|
341
|
+
{getLocaleName(localeItem, locale)}
|
|
342
|
+
</span>
|
|
343
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
344
|
+
{/* Lingua nella Locale corrente - es. Francés con la locale corrente impostata su Locales.SPANISH */}
|
|
345
|
+
{getLocaleName(localeItem)}
|
|
346
|
+
</span>
|
|
347
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
348
|
+
{/* Lingua in inglese - es. French */}
|
|
349
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
350
|
+
</span>
|
|
351
|
+
</Link>
|
|
352
|
+
</li>
|
|
353
|
+
))}
|
|
354
|
+
</ol>
|
|
363
355
|
);
|
|
364
|
-
}
|
|
356
|
+
};
|
|
365
357
|
```
|
|
366
358
|
|
|
367
359
|
> Per saperne di più sull'hook `useLocale`, consulta la [documentazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/react-intlayer/useLocale.md).
|
|
368
360
|
|
|
369
|
-
### Passo 10: Aggiungere la
|
|
361
|
+
### Passo 10: Aggiungere la gestione degli attributi HTML (Opzionale)
|
|
370
362
|
|
|
371
363
|
Crea un hook per gestire gli attributi lang e dir dell'HTML:
|
|
372
364
|
|
|
373
|
-
```tsx fileName="app/hooks/useI18nHTMLAttributes.tsx"
|
|
374
|
-
// app/hooks/useI18nHTMLAttributes.tsx
|
|
365
|
+
```tsx fileName="app/hooks/useI18nHTMLAttributes.tsx"
|
|
375
366
|
import { getHTMLTextDir } from "intlayer";
|
|
376
367
|
import { useEffect } from "react";
|
|
377
368
|
import { useLocale } from "react-intlayer";
|
|
@@ -388,8 +379,7 @@ export const useI18nHTMLAttributes = () => {
|
|
|
388
379
|
|
|
389
380
|
Quindi usalo nel tuo componente root:
|
|
390
381
|
|
|
391
|
-
```tsx fileName="app/
|
|
392
|
-
// app/routes/layout.tsx
|
|
382
|
+
```tsx fileName="app/routes/layout.tsx"
|
|
393
383
|
import { Outlet } from "react-router";
|
|
394
384
|
import { IntlayerProvider } from "react-intlayer";
|
|
395
385
|
|
|
@@ -406,45 +396,34 @@ export default function RootLayout() {
|
|
|
406
396
|
}
|
|
407
397
|
```
|
|
408
398
|
|
|
409
|
-
### Passo 11:
|
|
410
|
-
|
|
411
|
-
Costruisci i dizionari di contenuto e avvia la tua applicazione:
|
|
399
|
+
### Passo 11: Aggiungere il middleware (Opzionale)
|
|
412
400
|
|
|
413
|
-
|
|
414
|
-
# Costruisci i dizionari di Intlayer
|
|
415
|
-
npm run intlayer:build
|
|
401
|
+
Puoi anche utilizzare `intlayerMiddleware` per aggiungere il routing lato server alla tua applicazione. Questo plugin rileverà automaticamente la lingua corrente basandosi sull'URL e imposterà il cookie della lingua appropriata. Se non viene specificata alcuna lingua, il plugin determinerà la lingua più adatta in base alle preferenze linguistiche del browser dell'utente. Se non viene rilevata alcuna lingua, verrà effettuato un reindirizzamento alla lingua predefinita.
|
|
416
402
|
|
|
417
|
-
|
|
418
|
-
npm run dev
|
|
419
|
-
```
|
|
403
|
+
> Nota che per utilizzare `intlayerMiddleware` in produzione, è necessario spostare il pacchetto `vite-intlayer` da `devDependencies` a `dependencies`.
|
|
420
404
|
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
|
|
405
|
+
```typescript {3,7} fileName="vite.config.ts"
|
|
406
|
+
import { defineConfig } from "vite";
|
|
407
|
+
import react from "@vitejs/plugin-react-swc";
|
|
408
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
424
409
|
|
|
425
|
-
|
|
426
|
-
|
|
410
|
+
// https://vitejs.dev/config/
|
|
411
|
+
export default defineConfig({
|
|
412
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
413
|
+
});
|
|
427
414
|
```
|
|
428
415
|
|
|
429
|
-
|
|
430
|
-
# Costruisci i dizionari di Intlayer
|
|
431
|
-
yarn intlayer:build
|
|
432
|
-
|
|
433
|
-
# Avvia il server di sviluppo
|
|
434
|
-
yarn dev
|
|
435
|
-
```
|
|
416
|
+
---
|
|
436
417
|
|
|
437
|
-
|
|
418
|
+
## Configurare TypeScript
|
|
438
419
|
|
|
439
|
-
Intlayer utilizza l'
|
|
420
|
+
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
|
|
440
421
|
|
|
441
422
|
Assicurati che la tua configurazione di TypeScript includa i tipi generati automaticamente:
|
|
442
423
|
|
|
443
424
|
```json5 fileName="tsconfig.json"
|
|
444
425
|
{
|
|
445
|
-
|
|
446
|
-
// ... le tue configurazioni TypeScript esistenti
|
|
447
|
-
},
|
|
426
|
+
// ... le tue configurazioni esistenti
|
|
448
427
|
include: [
|
|
449
428
|
// ... i tuoi include esistenti
|
|
450
429
|
".intlayer/**/*.ts", // Includi i tipi generati automaticamente
|
|
@@ -452,11 +431,13 @@ Assicurati che la tua configurazione di TypeScript includa i tipi generati autom
|
|
|
452
431
|
}
|
|
453
432
|
```
|
|
454
433
|
|
|
455
|
-
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Configurazione Git
|
|
456
437
|
|
|
457
|
-
|
|
438
|
+
È consigliato ignorare i file generati da Intlayer. Questo ti permette di evitare di committarli nel tuo repository Git.
|
|
458
439
|
|
|
459
|
-
Per farlo, puoi aggiungere le seguenti istruzioni
|
|
440
|
+
Per farlo, puoi aggiungere le seguenti istruzioni nel tuo file `.gitignore`:
|
|
460
441
|
|
|
461
442
|
```plaintext fileName=".gitignore"
|
|
462
443
|
# Ignora i file generati da Intlayer
|
|
@@ -465,71 +446,43 @@ Per farlo, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
|
465
446
|
|
|
466
447
|
---
|
|
467
448
|
|
|
468
|
-
## Distribuzione in Produzione
|
|
469
|
-
|
|
470
|
-
Quando distribuisci la tua applicazione:
|
|
471
|
-
|
|
472
|
-
1. **Compila la tua applicazione:**
|
|
473
|
-
|
|
474
|
-
```bash
|
|
475
|
-
npm run build
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
2. **Compila i dizionari di Intlayer:**
|
|
479
|
-
|
|
480
|
-
```bash
|
|
481
|
-
npm run intlayer:build
|
|
482
|
-
```
|
|
483
|
-
|
|
484
|
-
3. **Sposta `vite-intlayer` nelle dipendenze** se usi il middleware in produzione:
|
|
485
|
-
```bash
|
|
486
|
-
npm install vite-intlayer --save
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
La tua applicazione supporterà ora:
|
|
490
|
-
|
|
491
|
-
- **Struttura URL**: `/en`, `/en/about`, `/tr`, `/tr/about`
|
|
492
|
-
- **Rilevamento automatico della lingua** basato sulle preferenze del browser
|
|
493
|
-
- **Routing consapevole della lingua** con React Router v7
|
|
494
|
-
- **Supporto TypeScript** con tipi generati automaticamente
|
|
495
|
-
- **Rendering lato server** con gestione corretta della lingua
|
|
496
|
-
|
|
497
449
|
## Estensione VS Code
|
|
498
450
|
|
|
499
|
-
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare
|
|
451
|
+
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare l'**Estensione ufficiale Intlayer per VS Code**.
|
|
500
452
|
|
|
501
453
|
[Installa dal Marketplace di VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
502
454
|
|
|
503
455
|
Questa estensione offre:
|
|
504
456
|
|
|
505
457
|
- **Completamento automatico** per le chiavi di traduzione.
|
|
506
|
-
- **Rilevamento in tempo reale
|
|
507
|
-
- **Anteprime inline**
|
|
458
|
+
- **Rilevamento errori in tempo reale** per traduzioni mancanti.
|
|
459
|
+
- **Anteprime inline** del contenuto tradotto.
|
|
508
460
|
- **Azioni rapide** per creare e aggiornare facilmente le traduzioni.
|
|
509
461
|
|
|
510
|
-
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione dell'
|
|
462
|
+
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione dell'Estensione Intlayer per VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
511
463
|
|
|
512
464
|
---
|
|
513
465
|
|
|
514
|
-
##
|
|
466
|
+
## Andare Oltre
|
|
515
467
|
|
|
516
|
-
Per andare oltre, puoi implementare l
|
|
468
|
+
Per andare oltre, puoi implementare l’[editor visuale](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_visual_editor.md) oppure esternalizzare i tuoi contenuti utilizzando il [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_CMS.md).
|
|
517
469
|
|
|
518
470
|
---
|
|
519
471
|
|
|
520
|
-
## Riferimenti alla
|
|
472
|
+
## Riferimenti alla Documentazione
|
|
521
473
|
|
|
522
474
|
- [Documentazione Intlayer](https://intlayer.org)
|
|
523
475
|
- [Documentazione React Router v7](https://reactrouter.com/)
|
|
524
476
|
- [Hook useIntlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/react-intlayer/useIntlayer.md)
|
|
525
|
-
- [useLocale
|
|
526
|
-
- [Dichiarazione
|
|
477
|
+
- [Hook useLocale](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/react-intlayer/useLocale.md)
|
|
478
|
+
- [Dichiarazione dei Contenuti](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md)
|
|
527
479
|
- [Configurazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/configuration.md)
|
|
528
480
|
|
|
529
481
|
Questa guida completa fornisce tutto il necessario per integrare Intlayer con React Router v7 per un'applicazione completamente internazionalizzata con routing consapevole della localizzazione e supporto TypeScript.
|
|
530
482
|
|
|
531
|
-
## Cronologia della
|
|
483
|
+
## Cronologia della documentazione
|
|
532
484
|
|
|
533
|
-
| Versione | Data
|
|
534
|
-
| -------- |
|
|
535
|
-
|
|
|
485
|
+
| Versione | Data | Modifiche |
|
|
486
|
+
| -------- | ---------- | ---------------------------- |
|
|
487
|
+
| 6.1.5 | 2025-10-03 | Documentazione aggiornata |
|
|
488
|
+
| 5.8.2 | 2025-09-04 | Aggiunto per React Router v7 |
|