@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
|
@@ -15,13 +15,11 @@ keywords:
|
|
|
15
15
|
slugs:
|
|
16
16
|
- doc
|
|
17
17
|
- environment
|
|
18
|
-
- vite-and-react
|
|
19
18
|
- tanstack-start
|
|
20
|
-
applicationTemplate: https://github.com/
|
|
21
|
-
author: AydinTheFirst
|
|
19
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
|
|
22
20
|
---
|
|
23
21
|
|
|
24
|
-
# Iniziare con l'internazionalizzazione (i18n)
|
|
22
|
+
# Iniziare con l'internazionalizzazione (i18n) con Intlayer e Tanstack Start
|
|
25
23
|
|
|
26
24
|
Questa guida dimostra come integrare **Intlayer** per un'internazionalizzazione senza soluzione di continuità nei progetti Tanstack Start con routing consapevole della localizzazione, supporto TypeScript e pratiche di sviluppo moderne.
|
|
27
25
|
|
|
@@ -33,7 +31,7 @@ Con Intlayer, puoi:
|
|
|
33
31
|
|
|
34
32
|
- **Gestire facilmente le traduzioni** utilizzando dizionari dichiarativi a livello di componente.
|
|
35
33
|
- **Localizzare dinamicamente i metadata**, le rotte e i contenuti.
|
|
36
|
-
- **Garantire il supporto TypeScript** con tipi
|
|
34
|
+
- **Garantire il supporto TypeScript** con tipi generati automaticamente, migliorando l'autocompletamento e il rilevamento degli errori.
|
|
37
35
|
- **Beneficiare di funzionalità avanzate**, come il rilevamento e il cambio dinamico della localizzazione.
|
|
38
36
|
- **Abilitare il routing consapevole della localizzazione** con il sistema di routing basato su file di Tanstack Start.
|
|
39
37
|
|
|
@@ -66,7 +64,7 @@ pnpm add vite-intlayer --save-dev
|
|
|
66
64
|
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).
|
|
67
65
|
|
|
68
66
|
- **react-intlayer**
|
|
69
|
-
Il pacchetto che integra Intlayer con
|
|
67
|
+
Il pacchetto che integra Intlayer con l'applicazione React. Fornisce provider di contesto e hook per l'internazionalizzazione in React.
|
|
70
68
|
|
|
71
69
|
- **vite-intlayer**
|
|
72
70
|
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 localizzazione preferita dall'utente, gestire i cookie e gestire il reindirizzamento degli URL.
|
|
@@ -75,7 +73,7 @@ pnpm add vite-intlayer --save-dev
|
|
|
75
73
|
|
|
76
74
|
Crea un file di configurazione per configurare le lingue della tua applicazione:
|
|
77
75
|
|
|
78
|
-
```typescript fileName="intlayer.config.ts"
|
|
76
|
+
```typescript fileName="intlayer.config.ts"
|
|
79
77
|
import type { IntlayerConfig } from "intlayer";
|
|
80
78
|
|
|
81
79
|
import { Locales } from "intlayer";
|
|
@@ -83,75 +81,27 @@ import { Locales } from "intlayer";
|
|
|
83
81
|
const config: IntlayerConfig = {
|
|
84
82
|
internationalization: {
|
|
85
83
|
defaultLocale: Locales.ENGLISH,
|
|
86
|
-
locales: [
|
|
87
|
-
Locales.ENGLISH,
|
|
88
|
-
Locales.FRENCH,
|
|
89
|
-
Locales.SPANISH,
|
|
90
|
-
// Le tue altre lingue
|
|
91
|
-
],
|
|
84
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
92
85
|
},
|
|
93
86
|
};
|
|
94
87
|
|
|
95
88
|
export default config;
|
|
96
89
|
```
|
|
97
90
|
|
|
98
|
-
|
|
99
|
-
import { Locales } from "intlayer";
|
|
100
|
-
|
|
101
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
102
|
-
const config = {
|
|
103
|
-
internationalization: {
|
|
104
|
-
defaultLocale: Locales.ENGLISH,
|
|
105
|
-
locales: [
|
|
106
|
-
Locales.ENGLISH,
|
|
107
|
-
Locales.FRENCH,
|
|
108
|
-
Locales.SPANISH,
|
|
109
|
-
// Le tue altre lingue
|
|
110
|
-
],
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export default config;
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
118
|
-
const { Locales } = require("intlayer");
|
|
119
|
-
|
|
120
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
121
|
-
const config = {
|
|
122
|
-
internationalization: {
|
|
123
|
-
defaultLocale: Locales.ENGLISH,
|
|
124
|
-
locales: [
|
|
125
|
-
Locales.ENGLISH,
|
|
126
|
-
Locales.FRENCH,
|
|
127
|
-
Locales.SPANISH,
|
|
128
|
-
// Le tue altre lingue
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
module.exports = config;
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
> Attraverso questo file di configurazione, puoi impostare URL localizzati, reindirizzamenti middleware, nomi dei cookie, la posizione e l'estensione delle tue dichiarazioni di contenuto, disabilitare i log di Intlayer nella console e altro ancora. Per un elenco completo dei parametri disponibili, consulta la [documentazione della configurazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/configuration.md).
|
|
91
|
+
> Attraverso questo file di configurazione, puoi impostare URL localizzati, reindirizzamenti middleware, nomi dei cookie, la posizione e l'estensione delle tue 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).
|
|
137
92
|
|
|
138
93
|
### Passo 4: Integra Intlayer nella tua configurazione Vite
|
|
139
94
|
|
|
140
95
|
Aggiungi il plugin intlayer nella tua configurazione:
|
|
141
96
|
|
|
142
|
-
```typescript fileName="vite.config.ts"
|
|
97
|
+
```typescript fileName="vite.config.ts"
|
|
143
98
|
import { reactRouter } from "@react-router/dev/vite";
|
|
144
99
|
import { defineConfig } from "vite";
|
|
145
|
-
import {
|
|
100
|
+
import { intlayer } from "vite-intlayer";
|
|
146
101
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
147
102
|
|
|
148
103
|
export default defineConfig({
|
|
149
|
-
plugins: [
|
|
150
|
-
reactRouter(),
|
|
151
|
-
tsconfigPaths(),
|
|
152
|
-
intlayer(),
|
|
153
|
-
intlayerMiddlewarePlugin(),
|
|
154
|
-
],
|
|
104
|
+
plugins: [reactRouter(), tsconfigPaths(), intlayer()],
|
|
155
105
|
});
|
|
156
106
|
```
|
|
157
107
|
|
|
@@ -159,14 +109,12 @@ export default defineConfig({
|
|
|
159
109
|
|
|
160
110
|
### Passo 5: Crea i Componenti di Layout
|
|
161
111
|
|
|
162
|
-
Configura il
|
|
112
|
+
Configura il layout principale e i layout specifici per locale:
|
|
163
113
|
|
|
164
114
|
#### Layout Principale
|
|
165
115
|
|
|
166
|
-
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
167
|
-
// src/routes/{-$locale}/route.tsx
|
|
116
|
+
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
168
117
|
import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
|
|
169
|
-
import { configuration } from "intlayer";
|
|
170
118
|
import { IntlayerProvider, useLocale } from "react-intlayer";
|
|
171
119
|
|
|
172
120
|
import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes";
|
|
@@ -176,21 +124,22 @@ export const Route = createFileRoute("/{-$locale}")({
|
|
|
176
124
|
});
|
|
177
125
|
|
|
178
126
|
function LayoutComponent() {
|
|
127
|
+
const { defaultLocale } = useLocale();
|
|
179
128
|
const { locale } = Route.useParams();
|
|
180
129
|
|
|
181
130
|
return (
|
|
182
|
-
<IntlayerProvider locale={
|
|
131
|
+
<IntlayerProvider locale={defaultLocale}>
|
|
183
132
|
<Outlet />
|
|
184
133
|
</IntlayerProvider>
|
|
185
134
|
);
|
|
186
135
|
}
|
|
187
136
|
```
|
|
188
137
|
|
|
189
|
-
### Passo 6:
|
|
138
|
+
### Passo 6: Dichiara il Tuo Contenuto
|
|
190
139
|
|
|
191
140
|
Crea e gestisci le tue dichiarazioni di contenuto per memorizzare le traduzioni:
|
|
192
141
|
|
|
193
|
-
```tsx fileName="src/contents/page.content.ts"
|
|
142
|
+
```tsx fileName="src/contents/page.content.ts"
|
|
194
143
|
import type { Dictionary } from "intlayer";
|
|
195
144
|
|
|
196
145
|
import { t } from "intlayer";
|
|
@@ -199,11 +148,13 @@ const appContent = {
|
|
|
199
148
|
content: {
|
|
200
149
|
links: {
|
|
201
150
|
about: t({
|
|
151
|
+
it: "Informazioni",
|
|
202
152
|
en: "About",
|
|
203
153
|
es: "Acerca de",
|
|
204
154
|
fr: "À propos",
|
|
205
155
|
}),
|
|
206
156
|
home: t({
|
|
157
|
+
it: "Home",
|
|
207
158
|
en: "Home",
|
|
208
159
|
es: "Inicio",
|
|
209
160
|
fr: "Accueil",
|
|
@@ -211,13 +162,15 @@ const appContent = {
|
|
|
211
162
|
},
|
|
212
163
|
meta: {
|
|
213
164
|
description: t({
|
|
214
|
-
|
|
165
|
+
it: "Questo è un esempio di utilizzo di Intlayer con TanStack Router",
|
|
166
|
+
en: "This is an example of using Intlayer with TanStack Router",
|
|
215
167
|
es: "Este es un ejemplo de uso de Intlayer con TanStack Router",
|
|
216
168
|
fr: "Ceci est un exemple d'utilisation d'Intlayer avec TanStack Router",
|
|
217
169
|
}),
|
|
218
170
|
},
|
|
219
171
|
title: t({
|
|
220
|
-
|
|
172
|
+
it: "Benvenuto in Intlayer + TanStack Router",
|
|
173
|
+
en: "Welcome to Intlayer + TanStack Router",
|
|
221
174
|
es: "Bienvenido a Intlayer + TanStack Router",
|
|
222
175
|
fr: "Bienvenue à Intlayer + TanStack Router",
|
|
223
176
|
}),
|
|
@@ -225,97 +178,130 @@ const appContent = {
|
|
|
225
178
|
key: "app",
|
|
226
179
|
} satisfies Dictionary;
|
|
227
180
|
|
|
181
|
+
export default appContent;
|
|
182
|
+
fr: "Bienvenue à Intlayer + TanStack Router",
|
|
183
|
+
}),
|
|
184
|
+
},
|
|
185
|
+
key: "app",
|
|
186
|
+
} satisfies Dictionary;
|
|
187
|
+
|
|
228
188
|
export default appContent;
|
|
229
189
|
```
|
|
230
190
|
|
|
231
|
-
> Le dichiarazioni di contenuto possono essere definite ovunque nella tua applicazione non appena
|
|
191
|
+
> Le tue dichiarazioni di contenuto possono essere definite ovunque nella tua applicazione non appena sono incluse nella directory `contentDir` (di default, `./app`). E devono corrispondere all'estensione del file di dichiarazione del contenuto (di default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
232
192
|
|
|
233
193
|
> Per maggiori dettagli, consulta la [documentazione sulla dichiarazione del contenuto](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md).
|
|
234
194
|
|
|
235
|
-
### Passo 7: Crea Componenti e Hook
|
|
195
|
+
### Passo 7: Crea Componenti e Hook Consapevoli della Localizzazione
|
|
236
196
|
|
|
237
|
-
Crea un componente `LocalizedLink` per
|
|
197
|
+
Crea un componente `LocalizedLink` per la navigazione consapevole della localizzazione:
|
|
238
198
|
|
|
239
|
-
```tsx fileName="src/components/localized-link.tsx"
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
import { Link, type
|
|
243
|
-
import { getLocalizedUrl } from "intlayer";
|
|
199
|
+
```tsx fileName="src/components/localized-link.tsx"
|
|
200
|
+
import type { FC } from "react";
|
|
201
|
+
|
|
202
|
+
import { Link, type LinkComponentProps } from "@tanstack/react-router";
|
|
244
203
|
import { useLocale } from "react-intlayer";
|
|
245
204
|
|
|
205
|
+
export const LOCALE_ROUTE = "{-$locale}" as const;
|
|
206
|
+
|
|
207
|
+
// Utilità principale
|
|
208
|
+
export type RemoveLocaleParam<T> = T extends string
|
|
209
|
+
? RemoveLocaleFromString<T>
|
|
210
|
+
: T;
|
|
211
|
+
|
|
212
|
+
export type To = RemoveLocaleParam<LinkComponentProps["to"]>;
|
|
213
|
+
|
|
214
|
+
type CollapseDoubleSlashes<S extends string> =
|
|
215
|
+
S extends `${infer H}//${infer T}` ? CollapseDoubleSlashes<`${H}/${T}`> : S;
|
|
216
|
+
|
|
246
217
|
type LocalizedLinkProps = {
|
|
247
|
-
to
|
|
248
|
-
} & Omit<
|
|
218
|
+
to?: To;
|
|
219
|
+
} & Omit<LinkComponentProps, "to">;
|
|
249
220
|
|
|
250
|
-
|
|
251
|
-
|
|
221
|
+
// Helper
|
|
222
|
+
type RemoveAll<
|
|
223
|
+
S extends string,
|
|
224
|
+
Sub extends string,
|
|
225
|
+
> = S extends `${infer H}${Sub}${infer T}` ? RemoveAll<`${H}${T}`, Sub> : S;
|
|
252
226
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
227
|
+
type RemoveLocaleFromString<S extends string> = CollapseDoubleSlashes<
|
|
228
|
+
RemoveAll<S, typeof LOCALE_ROUTE>
|
|
229
|
+
>;
|
|
256
230
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
: getLocalizedUrl(props.to, locale);
|
|
231
|
+
export const LocalizedLink: FC<LocalizedLinkProps> = (props) => {
|
|
232
|
+
const { locale } = useLocale();
|
|
260
233
|
|
|
261
|
-
return
|
|
262
|
-
|
|
234
|
+
return (
|
|
235
|
+
<Link
|
|
236
|
+
{...props}
|
|
237
|
+
params={{
|
|
238
|
+
locale,
|
|
239
|
+
...(typeof props?.params === "object" ? props?.params : {}),
|
|
240
|
+
}}
|
|
241
|
+
to={`/${LOCALE_ROUTE}${props.to}` as LinkComponentProps["to"]}
|
|
242
|
+
/>
|
|
243
|
+
);
|
|
244
|
+
};
|
|
263
245
|
```
|
|
264
246
|
|
|
265
|
-
|
|
247
|
+
Questo componente ha due obiettivi:
|
|
266
248
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
import { getLocalizedUrl } from "intlayer";
|
|
272
|
-
import { useLocale } from "react-intlayer";
|
|
249
|
+
- Rimuovere il prefisso `{-$locale}` non necessario dall'URL.
|
|
250
|
+
- Iniettare il parametro locale nell'URL per garantire che l'utente venga reindirizzato direttamente alla rotta localizzata.
|
|
251
|
+
|
|
252
|
+
Successivamente possiamo creare un hook `useLocalizedNavigate` per la navigazione programmatica:
|
|
273
253
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
254
|
+
```tsx fileName="src/hooks/useLocalizedNavigate.tsx"
|
|
255
|
+
import { useLocale } from "react-intlayer";
|
|
256
|
+
import { useNavigate } from "@tanstack/react-router";
|
|
257
|
+
import { LOCALE_ROUTE } from "@/components/localized-link";
|
|
258
|
+
import type { FileRouteTypes } from "@/routeTree.gen";
|
|
277
259
|
|
|
278
260
|
export const useLocalizedNavigate = () => {
|
|
279
261
|
const navigate = useNavigate();
|
|
262
|
+
|
|
280
263
|
const { locale } = useLocale();
|
|
281
264
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
265
|
+
type StripLocalePrefix<T extends string> = T extends
|
|
266
|
+
| `/${typeof LOCALE_ROUTE}`
|
|
267
|
+
| `/${typeof LOCALE_ROUTE}/`
|
|
268
|
+
? "/"
|
|
269
|
+
: T extends `/${typeof LOCALE_ROUTE}/${infer Rest}`
|
|
270
|
+
? `/${Rest}`
|
|
271
|
+
: never;
|
|
272
|
+
|
|
273
|
+
type LocalizedTo = StripLocalePrefix<FileRouteTypes["to"]>;
|
|
274
|
+
|
|
275
|
+
interface LocalizedNavigate {
|
|
276
|
+
(to: LocalizedTo): ReturnType<typeof navigate>;
|
|
277
|
+
(
|
|
278
|
+
opts: { to: LocalizedTo } & Record<string, unknown>
|
|
279
|
+
): ReturnType<typeof navigate>;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const localizedNavigate: LocalizedNavigate = (args: any) => {
|
|
283
|
+
if (typeof args === "string") {
|
|
284
|
+
return navigate({ to: `/${LOCALE_ROUTE}${args}`, params: { locale } });
|
|
285
|
+
}
|
|
285
286
|
|
|
286
|
-
|
|
287
|
-
const to = isExternal(options.to)
|
|
288
|
-
? options.to
|
|
289
|
-
: getLocalizedUrl(options.to, locale);
|
|
287
|
+
const { to, ...rest } = args;
|
|
290
288
|
|
|
291
|
-
|
|
289
|
+
const localedTo = `/${LOCALE_ROUTE}${to}` as any;
|
|
290
|
+
|
|
291
|
+
return navigate({ to: localedTo, params: { locale, ...rest } as any });
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
return localizedNavigate;
|
|
295
295
|
};
|
|
296
296
|
```
|
|
297
297
|
|
|
298
|
-
### Passo 8:
|
|
298
|
+
### Passo 8: Utilizza Intlayer nelle tue Pagine
|
|
299
299
|
|
|
300
300
|
Accedi ai tuoi dizionari di contenuti in tutta l'applicazione:
|
|
301
301
|
|
|
302
|
-
#### Pagina di Reindirizzamento Radice
|
|
303
|
-
|
|
304
|
-
```tsx fileName="src/routes/page.tsx" codeFormat="typescript"
|
|
305
|
-
// src/routes/page.tsx
|
|
306
|
-
import { useLocale } from "react-intlayer";
|
|
307
|
-
import { Navigate } from "react-router";
|
|
308
|
-
|
|
309
|
-
export default function Page() {
|
|
310
|
-
const { locale } = useLocale();
|
|
311
|
-
|
|
312
|
-
return <Navigate replace to={locale} />;
|
|
313
|
-
}
|
|
314
|
-
```
|
|
315
|
-
|
|
316
302
|
#### Pagina Home Localizzata
|
|
317
303
|
|
|
318
|
-
```tsx fileName="src/routes/{-$locale}/index.tsx"
|
|
304
|
+
```tsx fileName="src/routes/{-$locale}/index.tsx"
|
|
319
305
|
import { createFileRoute } from "@tanstack/react-router";
|
|
320
306
|
import { getIntlayer } from "intlayer";
|
|
321
307
|
import { useIntlayer } from "react-intlayer";
|
|
@@ -344,16 +330,15 @@ function RouteComponent() {
|
|
|
344
330
|
const navigate = useLocalizedNavigate();
|
|
345
331
|
|
|
346
332
|
return (
|
|
347
|
-
<div
|
|
348
|
-
<div
|
|
333
|
+
<div>
|
|
334
|
+
<div>
|
|
349
335
|
{content.title}
|
|
350
336
|
<LocaleSwitcher />
|
|
351
|
-
<div
|
|
352
|
-
<a href="/">Indice</a>
|
|
337
|
+
<div>
|
|
353
338
|
<LocalizedLink to="/">{content.links.home}</LocalizedLink>
|
|
354
339
|
<LocalizedLink to="/about">{content.links.about}</LocalizedLink>
|
|
355
340
|
</div>
|
|
356
|
-
<div
|
|
341
|
+
<div>
|
|
357
342
|
<button onClick={() => navigate({ to: "/" })}>
|
|
358
343
|
{content.links.home}
|
|
359
344
|
</button>
|
|
@@ -369,61 +354,69 @@ function RouteComponent() {
|
|
|
369
354
|
|
|
370
355
|
> 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).
|
|
371
356
|
|
|
372
|
-
### Passo 9: Crea un
|
|
357
|
+
### Passo 9: Crea un Componente per il Cambio di Lingua
|
|
373
358
|
|
|
374
359
|
Crea un componente per permettere agli utenti di cambiare lingua:
|
|
375
360
|
|
|
376
|
-
```tsx fileName="src/components/locale-switcher.tsx"
|
|
361
|
+
```tsx fileName="src/components/locale-switcher.tsx"
|
|
362
|
+
import type { FC } from "react";
|
|
363
|
+
|
|
377
364
|
import { useLocation } from "@tanstack/react-router";
|
|
378
|
-
import {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
const { availableLocales, locale, setLocale } = useLocale({
|
|
391
|
-
onLocaleChange: (newLocale) => {
|
|
392
|
-
const pathWithLocale = getLocalizedUrl(pathname + searchStr, newLocale);
|
|
393
|
-
location.replace(pathWithLocale);
|
|
394
|
-
},
|
|
395
|
-
});
|
|
365
|
+
import { getHTMLTextDir, getLocaleName, getPathWithoutLocale } from "intlayer";
|
|
366
|
+
import { setLocaleCookie, useIntlayer, useLocale } from "react-intlayer";
|
|
367
|
+
|
|
368
|
+
import { LocalizedLink, To } from "./localized-link";
|
|
369
|
+
|
|
370
|
+
export const LocaleSwitcher: FC = () => {
|
|
371
|
+
const { localeSwitcherLabel } = useIntlayer("locale-switcher");
|
|
372
|
+
const { pathname } = useLocation();
|
|
373
|
+
|
|
374
|
+
const { availableLocales, locale } = useLocale();
|
|
375
|
+
|
|
376
|
+
const pathWithoutLocale = getPathWithoutLocale(pathname);
|
|
396
377
|
|
|
397
378
|
return (
|
|
398
|
-
<
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
379
|
+
<ol>
|
|
380
|
+
{availableLocales.map((localeEl) => (
|
|
381
|
+
<li key={localeEl}>
|
|
382
|
+
<LocalizedLink
|
|
383
|
+
aria-current={localeEl === locale ? "page" : undefined}
|
|
384
|
+
aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeEl)}`}
|
|
385
|
+
onClick={() => setLocaleCookie(localeEl)}
|
|
386
|
+
params={{ locale: localeEl }}
|
|
387
|
+
to={pathWithoutLocale as To}
|
|
388
|
+
>
|
|
389
|
+
<span>
|
|
390
|
+
{/* Lingua - es. FR */}
|
|
391
|
+
{localeItem}
|
|
392
|
+
</span>
|
|
393
|
+
<span>
|
|
394
|
+
{/* Lingua nella sua stessa lingua - es. Français */}
|
|
395
|
+
{getLocaleName(localeItem, locale)}
|
|
396
|
+
</span>
|
|
397
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
398
|
+
{/* Lingua nella lingua corrente - es. Francés con la lingua corrente impostata su Locales.SPANISH */}
|
|
399
|
+
{getLocaleName(localeItem)}
|
|
400
|
+
</span>
|
|
401
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
402
|
+
{/* Lingua in inglese - es. French */}
|
|
403
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
404
|
+
</span>
|
|
405
|
+
</LocalizedLink>
|
|
406
|
+
</li>
|
|
414
407
|
))}
|
|
415
|
-
</
|
|
408
|
+
</ol>
|
|
416
409
|
);
|
|
417
|
-
}
|
|
410
|
+
};
|
|
418
411
|
```
|
|
419
412
|
|
|
420
|
-
> Per saperne di più
|
|
413
|
+
> Per saperne di più sul hook `useLocale`, consulta la [documentazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/react-intlayer/useLocale.md).
|
|
421
414
|
|
|
422
|
-
### Passo 10: Aggiungere la
|
|
415
|
+
### Passo 10: Aggiungere la gestione degli attributi HTML (Opzionale)
|
|
423
416
|
|
|
424
417
|
Crea un hook per gestire gli attributi lang e dir dell'HTML:
|
|
425
418
|
|
|
426
|
-
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx"
|
|
419
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx"
|
|
427
420
|
// src/hooks/useI18nHTMLAttributes.tsx
|
|
428
421
|
import { getHTMLTextDir } from "intlayer";
|
|
429
422
|
import { useEffect } from "react";
|
|
@@ -439,11 +432,10 @@ export const useI18nHTMLAttributes = () => {
|
|
|
439
432
|
};
|
|
440
433
|
```
|
|
441
434
|
|
|
442
|
-
|
|
435
|
+
Poi usalo nel tuo componente root:
|
|
443
436
|
|
|
444
|
-
```tsx fileName="src/routes/{-$locale}/index.tsx"
|
|
437
|
+
```tsx fileName="src/routes/{-$locale}/index.tsx"
|
|
445
438
|
import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
|
|
446
|
-
import { configuration } from "intlayer";
|
|
447
439
|
import { IntlayerProvider, useLocale } from "react-intlayer";
|
|
448
440
|
|
|
449
441
|
import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes"; // importa il hook
|
|
@@ -455,55 +447,54 @@ export const Route = createFileRoute("/{-$locale}")({
|
|
|
455
447
|
function LayoutComponent() {
|
|
456
448
|
useI18nHTMLAttributes(); // aggiungi questa riga
|
|
457
449
|
|
|
450
|
+
const { defaultLocale } = useLocale();
|
|
458
451
|
const { locale } = Route.useParams();
|
|
459
452
|
|
|
460
453
|
return (
|
|
461
|
-
<IntlayerProvider locale={locale}>
|
|
454
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
462
455
|
<Outlet />
|
|
463
456
|
</IntlayerProvider>
|
|
464
457
|
);
|
|
465
458
|
}
|
|
466
459
|
```
|
|
467
460
|
|
|
468
|
-
|
|
461
|
+
---
|
|
469
462
|
|
|
470
|
-
|
|
463
|
+
### Passo 11: Aggiungere middleware (Opzionale)
|
|
471
464
|
|
|
472
|
-
|
|
473
|
-
# Compila i dizionari di Intlayer
|
|
474
|
-
npm run intlayer:build
|
|
465
|
+
Puoi anche utilizzare `intlayerMiddleware` per aggiungere il routing lato server alla tua applicazione. Questo plugin rileverà automaticamente la locale corrente basandosi sull'URL e imposterà il cookie della locale appropriata. Se non viene specificata alcuna locale, il plugin determinerà la locale più adatta in base alle preferenze linguistiche del browser dell'utente. Se non viene rilevata alcuna locale, verrà effettuato un reindirizzamento alla locale predefinita.
|
|
475
466
|
|
|
476
|
-
|
|
477
|
-
npm run dev
|
|
478
|
-
```
|
|
467
|
+
> Nota che per utilizzare `intlayerMiddleware` in produzione, è necessario spostare il pacchetto `vite-intlayer` da `devDependencies` a `dependencies`.
|
|
479
468
|
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
|
|
469
|
+
```typescript {3,7} fileName="vite.config.ts"
|
|
470
|
+
import { reactRouter } from "@react-router/dev/vite";
|
|
471
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
472
|
+
import { defineConfig } from "vite";
|
|
473
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
474
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
483
475
|
|
|
484
|
-
|
|
485
|
-
|
|
476
|
+
export default defineConfig({
|
|
477
|
+
plugins: [
|
|
478
|
+
tailwindcss(),
|
|
479
|
+
reactRouter(),
|
|
480
|
+
tsconfigPaths(),
|
|
481
|
+
intlayer(),
|
|
482
|
+
intlayerMiddleware(),
|
|
483
|
+
],
|
|
484
|
+
});
|
|
486
485
|
```
|
|
487
486
|
|
|
488
|
-
|
|
489
|
-
# Compila i dizionari di Intlayer
|
|
490
|
-
yarn intlayer:build
|
|
491
|
-
|
|
492
|
-
# Avvia il server di sviluppo
|
|
493
|
-
yarn dev
|
|
494
|
-
```
|
|
487
|
+
---
|
|
495
488
|
|
|
496
|
-
### Passo 12:
|
|
489
|
+
### Passo 12: Configurare TypeScript (Opzionale)
|
|
497
490
|
|
|
498
|
-
Intlayer utilizza l'
|
|
491
|
+
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
|
|
499
492
|
|
|
500
493
|
Assicurati che la tua configurazione di TypeScript includa i tipi generati automaticamente:
|
|
501
494
|
|
|
502
495
|
```json5 fileName="tsconfig.json"
|
|
503
496
|
{
|
|
504
|
-
|
|
505
|
-
// ... le tue configurazioni TypeScript esistenti
|
|
506
|
-
},
|
|
497
|
+
// ... le tue configurazioni esistenti
|
|
507
498
|
include: [
|
|
508
499
|
// ... i tuoi include esistenti
|
|
509
500
|
".intlayer/**/*.ts", // Includi i tipi generati automaticamente
|
|
@@ -511,11 +502,13 @@ Assicurati che la tua configurazione di TypeScript includa i tipi generati autom
|
|
|
511
502
|
}
|
|
512
503
|
```
|
|
513
504
|
|
|
505
|
+
---
|
|
506
|
+
|
|
514
507
|
### Configurazione Git
|
|
515
508
|
|
|
516
509
|
Si consiglia di ignorare i file generati da Intlayer. Questo ti permette di evitare di committarli nel tuo repository Git.
|
|
517
510
|
|
|
518
|
-
Per
|
|
511
|
+
Per fare ciò, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
519
512
|
|
|
520
513
|
```plaintext fileName=".gitignore"
|
|
521
514
|
# Ignora i file generati da Intlayer
|
|
@@ -524,67 +517,9 @@ Per farlo, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
|
524
517
|
|
|
525
518
|
---
|
|
526
519
|
|
|
527
|
-
### Passo 13: Crea un Reindirizzamento (Opzionale)
|
|
528
|
-
|
|
529
|
-
```typescript fileName="src/routes/{-$locale}/rotue.tsx" codeFormat="typescript"
|
|
530
|
-
function LayoutComponent() {
|
|
531
|
-
useI18nHTMLAttributes();
|
|
532
|
-
|
|
533
|
-
const { locale } = Route.useParams();
|
|
534
|
-
const { locale: selectedLocale } = useLocale();
|
|
535
|
-
const { defaultLocale } = configuration.internationalization;
|
|
536
|
-
const { prefixDefault } = configuration.middleware;
|
|
537
|
-
|
|
538
|
-
// Reindirizza alla lingua predefinita se non è presente alcuna lingua nell'URL quando prefixDefault è true
|
|
539
|
-
if (selectedLocale === defaultLocale && !locale && prefixDefault) {
|
|
540
|
-
return <Navigate replace to={defaultLocale} />;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
// Reindirizza alla lingua selezionata se la lingua nell'URL non corrisponde a quella selezionata
|
|
544
|
-
if (selectedLocale !== defaultLocale && !locale) {
|
|
545
|
-
return <Navigate replace to={selectedLocale} />;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
return (
|
|
549
|
-
<IntlayerProvider locale={locale}>
|
|
550
|
-
<Outlet />
|
|
551
|
-
</IntlayerProvider>
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
```
|
|
555
|
-
|
|
556
|
-
## Distribuzione in Produzione
|
|
557
|
-
|
|
558
|
-
Quando distribuisci la tua applicazione:
|
|
559
|
-
|
|
560
|
-
1. **Compila la tua applicazione:**
|
|
561
|
-
|
|
562
|
-
```bash
|
|
563
|
-
npm run build
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
2. **Compila i dizionari di Intlayer:**
|
|
567
|
-
|
|
568
|
-
```bash
|
|
569
|
-
npm run intlayer:build
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
3. **Sposta `vite-intlayer` nelle dipendenze** se usi il middleware in produzione:
|
|
573
|
-
```bash
|
|
574
|
-
npm install vite-intlayer --save
|
|
575
|
-
```
|
|
576
|
-
|
|
577
|
-
La tua applicazione supporterà ora:
|
|
578
|
-
|
|
579
|
-
- **Struttura URL**: `/en`, `/en/about`, `/tr`, `/tr/about`
|
|
580
|
-
- **Rilevamento automatico della lingua** basato sulle preferenze del browser
|
|
581
|
-
- **Routing consapevole della lingua** con Tanstack Start
|
|
582
|
-
- **Supporto TypeScript** con tipi generati automaticamente
|
|
583
|
-
- **Rendering lato server** con gestione corretta della lingua
|
|
584
|
-
|
|
585
520
|
## Estensione VS Code
|
|
586
521
|
|
|
587
|
-
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare l'**Estensione Intlayer per VS Code
|
|
522
|
+
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare l'**Estensione ufficiale Intlayer per VS Code**.
|
|
588
523
|
|
|
589
524
|
[Installa dal Marketplace di VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
590
525
|
|
|
@@ -592,32 +527,33 @@ Questa estensione offre:
|
|
|
592
527
|
|
|
593
528
|
- **Completamento automatico** per le chiavi di traduzione.
|
|
594
529
|
- **Rilevamento errori in tempo reale** per traduzioni mancanti.
|
|
595
|
-
- **Anteprime inline**
|
|
530
|
+
- **Anteprime inline** del contenuto tradotto.
|
|
596
531
|
- **Azioni rapide** per creare e aggiornare facilmente le traduzioni.
|
|
597
532
|
|
|
598
|
-
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione dell'
|
|
533
|
+
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione dell'estensione Intlayer per VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
599
534
|
|
|
600
535
|
---
|
|
601
536
|
|
|
602
537
|
## Vai oltre
|
|
603
538
|
|
|
604
|
-
Per andare oltre, puoi implementare l'[editor visuale](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_visual_editor.md)
|
|
539
|
+
Per andare oltre, puoi implementare l'[editor visuale](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_visual_editor.md) o esternalizzare i tuoi contenuti utilizzando il [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_CMS.md).
|
|
605
540
|
|
|
606
541
|
---
|
|
607
542
|
|
|
608
|
-
## Riferimenti alla
|
|
543
|
+
## Riferimenti alla documentazione
|
|
609
544
|
|
|
610
545
|
- [Documentazione Intlayer](https://intlayer.org)
|
|
611
546
|
- [Documentazione Tanstack Start](https://reactrouter.com/)
|
|
612
547
|
- [Hook useIntlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/react-intlayer/useIntlayer.md)
|
|
613
|
-
- [
|
|
614
|
-
- [Dichiarazione
|
|
548
|
+
- [useLocale hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/react-intlayer/useLocale.md)
|
|
549
|
+
- [Dichiarazione del Contenuto](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md)
|
|
615
550
|
- [Configurazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/configuration.md)
|
|
616
551
|
|
|
617
552
|
Questa guida completa fornisce tutto il necessario per integrare Intlayer con Tanstack Start per un'applicazione completamente internazionalizzata con routing consapevole della localizzazione e supporto TypeScript.
|
|
618
553
|
|
|
619
554
|
## Cronologia della Documentazione
|
|
620
555
|
|
|
621
|
-
| Versione | Data | Modifiche
|
|
622
|
-
| -------- | ---------- |
|
|
623
|
-
| 5.
|
|
556
|
+
| Versione | Data | Modifiche |
|
|
557
|
+
| -------- | ---------- | ---------------------------- |
|
|
558
|
+
| 6.5.2 | 2025-10-03 | Aggiornamento documentazione |
|
|
559
|
+
| 5.8.1 | 2025-09-09 | Aggiunto per Tanstack Start |
|