@intlayer/docs 7.3.11 → 7.3.13
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/dist/cjs/generated/docs.entry.cjs +19 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +19 -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_nuxt.md +294 -438
- package/docs/ar/intlayer_with_react_router_v7.md +33 -4
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/ar/intlayer_with_tanstack.md +2 -12
- package/docs/ar/intlayer_with_vite+vue.md +1 -0
- package/docs/de/intlayer_with_nuxt.md +284 -410
- package/docs/de/intlayer_with_react_router_v7.md +33 -4
- package/docs/de/intlayer_with_react_router_v7_fs_routes.md +573 -0
- package/docs/de/intlayer_with_tanstack.md +1 -0
- package/docs/de/intlayer_with_vite+vue.md +1 -0
- package/docs/en/intlayer_with_nuxt.md +237 -341
- package/docs/en/intlayer_with_react_router_v7.md +24 -0
- package/docs/en/intlayer_with_react_router_v7_fs_routes.md +570 -0
- package/docs/en/intlayer_with_tanstack.md +2 -12
- package/docs/en/intlayer_with_vite+vue.md +49 -48
- package/docs/en-GB/intlayer_with_nuxt.md +254 -378
- package/docs/en-GB/intlayer_with_react_router_v7.md +33 -4
- package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +513 -0
- package/docs/en-GB/intlayer_with_tanstack.md +2 -12
- package/docs/en-GB/intlayer_with_vite+vue.md +1 -0
- package/docs/es/intlayer_with_nuxt.md +271 -390
- package/docs/es/intlayer_with_react_router_v7.md +33 -4
- package/docs/es/intlayer_with_react_router_v7_fs_routes.md +575 -0
- package/docs/es/intlayer_with_tanstack.md +1 -0
- package/docs/es/intlayer_with_vite+vue.md +1 -2
- package/docs/fr/intlayer_with_nuxt.md +278 -405
- package/docs/fr/intlayer_with_react_router_v7.md +34 -5
- package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/fr/intlayer_with_tanstack.md +1 -0
- package/docs/fr/intlayer_with_vite+vue.md +1 -0
- package/docs/hi/intlayer_with_nuxt.md +303 -447
- package/docs/hi/intlayer_with_react_router_v7.md +33 -4
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +518 -0
- package/docs/hi/intlayer_with_tanstack.md +2 -12
- package/docs/hi/intlayer_with_vite+vue.md +1 -0
- package/docs/id/intlayer_with_nuxt.md +266 -395
- package/docs/id/intlayer_with_react_router_v7.md +29 -4
- package/docs/id/intlayer_with_react_router_v7_fs_routes.md +521 -0
- package/docs/id/intlayer_with_tanstack.md +2 -12
- package/docs/id/intlayer_with_vite+vue.md +1 -0
- package/docs/it/intlayer_with_nuxt.md +299 -423
- package/docs/it/intlayer_with_react_router_v7.md +33 -4
- package/docs/it/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/it/intlayer_with_tanstack.md +1 -0
- package/docs/ja/intlayer_with_nuxt.md +309 -432
- package/docs/ja/intlayer_with_react_router_v7.md +33 -4
- package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ja/intlayer_with_tanstack.md +2 -12
- package/docs/ja/intlayer_with_vite+vue.md +1 -0
- package/docs/ko/intlayer_with_nuxt.md +295 -422
- package/docs/ko/intlayer_with_react_router_v7.md +33 -4
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +515 -0
- package/docs/ko/intlayer_with_tanstack.md +2 -12
- package/docs/ko/intlayer_with_vite+vue.md +1 -0
- package/docs/pl/intlayer_with_nuxt.md +273 -476
- package/docs/pl/intlayer_with_react_router_v7.md +32 -5
- package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +615 -0
- package/docs/pl/intlayer_with_tanstack.md +2 -12
- package/docs/pl/intlayer_with_vite+vue.md +1 -0
- package/docs/pt/intlayer_with_nuxt.md +277 -420
- package/docs/pt/intlayer_with_react_router_v7.md +28 -0
- package/docs/pt/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_nuxt.md +287 -425
- package/docs/ru/intlayer_with_react_router_v7.md +33 -4
- package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ru/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_vite+vue.md +1 -0
- package/docs/tr/intlayer_with_nuxt.md +313 -406
- package/docs/tr/intlayer_with_react_router_v7.md +33 -4
- package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +572 -0
- package/docs/tr/intlayer_with_tanstack.md +2 -12
- package/docs/tr/intlayer_with_vite+vue.md +1 -0
- package/docs/vi/intlayer_with_nuxt.md +273 -418
- package/docs/vi/intlayer_with_react_router_v7.md +29 -4
- package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +523 -0
- package/docs/vi/intlayer_with_tanstack.md +2 -12
- package/docs/vi/intlayer_with_vite+vue.md +1 -0
- package/docs/zh/intlayer_with_nuxt.md +300 -461
- package/docs/zh/intlayer_with_react_router_v7.md +33 -4
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/zh/intlayer_with_tanstack.md +2 -12
- package/docs/zh/intlayer_with_vite+vue.md +1 -0
- package/package.json +10 -11
- package/src/generated/docs.entry.ts +19 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-06-18
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title: Come tradurre la tua Nuxt
|
|
3
|
+
updatedAt: 2025-12-07
|
|
4
|
+
title: Come tradurre la tua app Nuxt e Vue – guida i18n 2025
|
|
5
5
|
description: Scopri come rendere il tuo sito Nuxt e Vue multilingue. Segui la documentazione per internazionalizzare (i18n) e tradurlo.
|
|
6
6
|
keywords:
|
|
7
7
|
- Internazionalizzazione
|
|
@@ -14,33 +14,60 @@ slugs:
|
|
|
14
14
|
- doc
|
|
15
15
|
- environment
|
|
16
16
|
- nuxt-and-vue
|
|
17
|
-
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-template
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-4-template
|
|
18
|
+
youtubeVideo: https://www.youtube.com/watch?v=nhUcUAVQ6eQ
|
|
18
19
|
history:
|
|
20
|
+
- version: 7.3.11
|
|
21
|
+
date: 2025-12-07
|
|
22
|
+
changes: Aggiornamento LocaleSwitcher, SEO, metadata
|
|
19
23
|
- version: 5.5.10
|
|
20
24
|
date: 2025-06-29
|
|
21
|
-
changes:
|
|
25
|
+
changes: Inizializzazione cronologia
|
|
22
26
|
---
|
|
23
27
|
|
|
24
|
-
# Traduci
|
|
28
|
+
# Traduci il tuo sito Nuxt e Vue usando Intlayer | Internazionalizzazione (i18n)
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
## Indice
|
|
31
|
+
|
|
32
|
+
<TOC/>
|
|
27
33
|
|
|
28
34
|
## Cos'è Intlayer?
|
|
29
35
|
|
|
30
|
-
**Intlayer** è una libreria innovativa e open-source
|
|
36
|
+
**Intlayer** è una libreria di internazionalizzazione (i18n) innovativa e open-source progettata per semplificare il supporto multilingue nelle moderne applicazioni web.
|
|
31
37
|
|
|
32
38
|
Con Intlayer, puoi:
|
|
33
39
|
|
|
34
40
|
- **Gestire facilmente le traduzioni** utilizzando dizionari dichiarativi a livello di componente.
|
|
35
|
-
- **Localizzare dinamicamente
|
|
41
|
+
- **Localizzare dinamicamente metadata**, rotte e contenuti.
|
|
36
42
|
- **Garantire il supporto a TypeScript** con tipi autogenerati, migliorando l'autocompletamento e il rilevamento degli errori.
|
|
37
|
-
- **Beneficiare di funzionalità avanzate**, come il rilevamento e
|
|
43
|
+
- **Beneficiare di funzionalità avanzate**, come il rilevamento e lo switch dinamico della locale.
|
|
38
44
|
|
|
39
45
|
---
|
|
40
46
|
|
|
41
|
-
## Guida passo
|
|
47
|
+
## Guida passo-passo per configurare Intlayer in un'applicazione Nuxt
|
|
48
|
+
|
|
49
|
+
<Tab defaultTab="video">
|
|
50
|
+
<TabItem label="Video" value="video">
|
|
51
|
+
|
|
52
|
+
<iframe title="Come tradurre la tua app Nuxt e Vue usando Intlayer? Scopri Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/nhUcUAVQ6eQ?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
53
|
+
|
|
54
|
+
</TabItem>
|
|
55
|
+
<TabItem label="Codice" value="code">
|
|
56
|
+
|
|
57
|
+
<iframe
|
|
58
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
59
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
60
|
+
title="Demo CodeSandbox - Come internazionalizzare la tua applicazione usando Intlayer"
|
|
61
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
62
|
+
loading="lazy"
|
|
63
|
+
/>
|
|
42
64
|
|
|
43
|
-
|
|
65
|
+
</TabItem>
|
|
66
|
+
</Tab>
|
|
67
|
+
|
|
68
|
+
Vedi il [Template dell'Applicazione](https://github.com/aymericzip/intlayer-nuxt-4-template) su GitHub.
|
|
69
|
+
|
|
70
|
+
### Passo 1: Installa le dipendenze
|
|
44
71
|
|
|
45
72
|
Installa i pacchetti necessari usando npm:
|
|
46
73
|
|
|
@@ -61,17 +88,17 @@ yarn add --save-dev nuxt-intlayer
|
|
|
61
88
|
|
|
62
89
|
- **intlayer**
|
|
63
90
|
|
|
64
|
-
Il pacchetto
|
|
91
|
+
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/content_file.md), la traspilazione e i [comandi CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/cli/index.md).
|
|
65
92
|
|
|
66
93
|
- **vue-intlayer**
|
|
67
94
|
Il pacchetto che integra Intlayer con l'applicazione Vue. Fornisce i composables per i componenti Vue.
|
|
68
95
|
|
|
69
96
|
- **nuxt-intlayer**
|
|
70
|
-
Il modulo Nuxt che integra Intlayer con le applicazioni Nuxt. Fornisce una configurazione automatica, middleware per il rilevamento della
|
|
97
|
+
Il modulo Nuxt che integra Intlayer con le applicazioni Nuxt. Fornisce una configurazione automatica, middleware per il rilevamento della locale, gestione dei cookie e reindirizzamento degli URL.
|
|
71
98
|
|
|
72
99
|
### Passo 2: Configurazione del tuo progetto
|
|
73
100
|
|
|
74
|
-
Crea un file di configurazione per
|
|
101
|
+
Crea un file di configurazione per configurare le lingue della tua applicazione:
|
|
75
102
|
|
|
76
103
|
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
77
104
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -82,13 +109,10 @@ const config: IntlayerConfig = {
|
|
|
82
109
|
Locales.ENGLISH,
|
|
83
110
|
Locales.FRENCH,
|
|
84
111
|
Locales.SPANISH,
|
|
85
|
-
// Le tue altre
|
|
112
|
+
// Le tue altre localizzazioni
|
|
86
113
|
],
|
|
87
114
|
defaultLocale: Locales.ENGLISH,
|
|
88
115
|
},
|
|
89
|
-
content: {
|
|
90
|
-
contentDir: ["."], // Perché di default Intlayer monitorerà i file di dichiarazione dei contenuti dalla directory `./src`
|
|
91
|
-
},
|
|
92
116
|
};
|
|
93
117
|
|
|
94
118
|
export default config;
|
|
@@ -98,20 +122,16 @@ export default config;
|
|
|
98
122
|
import { Locales } from "intlayer";
|
|
99
123
|
|
|
100
124
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
101
|
-
// Configurazione per Intlayer
|
|
102
125
|
const config = {
|
|
103
126
|
internationalization: {
|
|
104
127
|
locales: [
|
|
105
128
|
Locales.ENGLISH,
|
|
106
129
|
Locales.FRENCH,
|
|
107
130
|
Locales.SPANISH,
|
|
108
|
-
// Le tue altre
|
|
131
|
+
// Le tue altre localizzazioni
|
|
109
132
|
],
|
|
110
133
|
defaultLocale: Locales.ENGLISH,
|
|
111
134
|
},
|
|
112
|
-
content: {
|
|
113
|
-
contentDir: ["."],
|
|
114
|
-
},
|
|
115
135
|
};
|
|
116
136
|
|
|
117
137
|
export default config;
|
|
@@ -121,20 +141,16 @@ export default config;
|
|
|
121
141
|
const { Locales } = require("intlayer");
|
|
122
142
|
|
|
123
143
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
124
|
-
// Configurazione per Intlayer
|
|
125
144
|
const config = {
|
|
126
145
|
internationalization: {
|
|
127
146
|
locales: [
|
|
128
147
|
Locales.ENGLISH,
|
|
129
148
|
Locales.FRENCH,
|
|
130
149
|
Locales.SPANISH,
|
|
131
|
-
// Le tue altre
|
|
150
|
+
// Le tue altre localizzazioni
|
|
132
151
|
],
|
|
133
152
|
defaultLocale: Locales.ENGLISH,
|
|
134
153
|
},
|
|
135
|
-
content: {
|
|
136
|
-
contentDir: ["."],
|
|
137
|
-
},
|
|
138
154
|
};
|
|
139
155
|
|
|
140
156
|
module.exports = config;
|
|
@@ -155,233 +171,47 @@ export default defineNuxtConfig({
|
|
|
155
171
|
});
|
|
156
172
|
```
|
|
157
173
|
|
|
158
|
-
> Il modulo `nuxt-intlayer` gestisce automaticamente l'integrazione di Intlayer con Nuxt. Configura la costruzione delle dichiarazioni di contenuto, monitora i file in modalità sviluppo, fornisce
|
|
174
|
+
> Il modulo `nuxt-intlayer` gestisce automaticamente l'integrazione di Intlayer con Nuxt. Configura la costruzione delle dichiarazioni di contenuto, monitora i file in modalità sviluppo, fornisce middleware per il rilevamento della locale e gestisce il routing localizzato.
|
|
159
175
|
|
|
160
|
-
### Passo 4: Dichiara il
|
|
176
|
+
### Passo 4: Dichiara il tuo contenuto
|
|
161
177
|
|
|
162
178
|
Crea e gestisci le tue dichiarazioni di contenuto per memorizzare le traduzioni:
|
|
163
179
|
|
|
164
|
-
```tsx fileName="
|
|
165
|
-
import {
|
|
180
|
+
```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
|
|
181
|
+
import { type Dictionary, t } from "intlayer";
|
|
166
182
|
|
|
167
|
-
const
|
|
168
|
-
key: "
|
|
183
|
+
const content = {
|
|
184
|
+
key: "home-page",
|
|
169
185
|
content: {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
175
|
-
}),
|
|
176
|
-
checkOut: t({
|
|
177
|
-
en: "Check out ",
|
|
178
|
-
it: "Dai un'occhiata a ",
|
|
179
|
-
fr: "Vérifiez ",
|
|
180
|
-
es: "Compruebe ",
|
|
181
|
-
}),
|
|
182
|
-
nuxtIntlayer: t({
|
|
183
|
-
en: "Nuxt Intlayer documentation",
|
|
184
|
-
it: "Documentazione di Nuxt Intlayer",
|
|
185
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
186
|
-
es: "Documentación de Nuxt Intlayer",
|
|
187
|
-
}),
|
|
188
|
-
learnMore: t({
|
|
189
|
-
en: "Learn more about Nuxt in the ",
|
|
190
|
-
it: "Per saperne di più su Nuxt in ",
|
|
191
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
192
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
186
|
+
title: t({
|
|
187
|
+
en: "Hello world",
|
|
188
|
+
fr: "Bonjour le monde",
|
|
189
|
+
es: "Hola mundo",
|
|
193
190
|
}),
|
|
194
|
-
|
|
195
|
-
en: "
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
es: "Documentación de Nuxt",
|
|
191
|
+
metaTitle: t({
|
|
192
|
+
en: "Welcome | My Application",
|
|
193
|
+
fr: "Bienvenue | Mon Application",
|
|
194
|
+
es: "Bienvenido | Mi Aplicación",
|
|
199
195
|
}),
|
|
200
|
-
|
|
201
|
-
en: "
|
|
202
|
-
it: "
|
|
203
|
-
fr: "
|
|
204
|
-
es: "
|
|
205
|
-
it: "Clicca sul logo di Nuxt per saperne di più",
|
|
196
|
+
metaDescription: t({
|
|
197
|
+
en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
|
|
198
|
+
it: "Scopri la homepage multilingue della tua app Nuxt alimentata da Intlayer.",
|
|
199
|
+
fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
|
|
200
|
+
es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
|
|
206
201
|
}),
|
|
207
202
|
},
|
|
208
203
|
} satisfies Dictionary;
|
|
209
204
|
|
|
210
|
-
export default
|
|
205
|
+
export default content;
|
|
211
206
|
```
|
|
212
207
|
|
|
213
|
-
|
|
214
|
-
import { t } from "intlayer";
|
|
208
|
+
> Le tue dichiarazioni di contenuto possono essere definite ovunque nella tua applicazione purché siano incluse nella directory `contentDir` (di default, `./src`). E corrispondano all'estensione del file di dichiarazione del contenuto (di default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
215
209
|
|
|
216
|
-
|
|
217
|
-
const helloWorldContent = {
|
|
218
|
-
key: "helloworld",
|
|
219
|
-
content: {
|
|
220
|
-
count: t({
|
|
221
|
-
en: "count is ",
|
|
222
|
-
fr: "le compte est ",
|
|
223
|
-
es: "el recuento es ",
|
|
224
|
-
it: "il conteggio è ",
|
|
225
|
-
}),
|
|
226
|
-
edit: t({
|
|
227
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
228
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
229
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
230
|
-
it: "Modifica <code>components/HelloWorld.vue</code> e salva per testare HMR",
|
|
231
|
-
}),
|
|
232
|
-
checkOut: t({
|
|
233
|
-
en: "Check out ",
|
|
234
|
-
it: "Dai un'occhiata a ",
|
|
235
|
-
fr: "Vérifiez ",
|
|
236
|
-
es: "Compruebe ",
|
|
237
|
-
}),
|
|
238
|
-
nuxtIntlayer: t({
|
|
239
|
-
en: "Nuxt Intlayer documentation",
|
|
240
|
-
it: "Documentazione di Nuxt Intlayer",
|
|
241
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
242
|
-
es: "Documentación de Nuxt Intlayer",
|
|
243
|
-
}),
|
|
244
|
-
learnMore: t({
|
|
245
|
-
en: "Learn more about Nuxt in the ",
|
|
246
|
-
it: "Scopri di più su Nuxt in ",
|
|
247
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
248
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
249
|
-
}),
|
|
250
|
-
nuxtDocs: t({
|
|
251
|
-
en: "Nuxt Documentation",
|
|
252
|
-
it: "Documentazione Nuxt",
|
|
253
|
-
fr: "Documentation Nuxt",
|
|
254
|
-
es: "Documentación de Nuxt",
|
|
255
|
-
}),
|
|
256
|
-
readTheDocs: t({
|
|
257
|
-
en: "Click on the Nuxt logo to learn more",
|
|
258
|
-
it: "Clicca sul logo di Nuxt per saperne di più",
|
|
259
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
260
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
261
|
-
}),
|
|
262
|
-
},
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
export default helloWorldContent;
|
|
266
|
-
```
|
|
210
|
+
> Per maggiori dettagli, consulta la [documentazione sulla dichiarazione dei contenuti](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/content_file.md).
|
|
267
211
|
|
|
268
|
-
|
|
269
|
-
const { t } = require("intlayer");
|
|
270
|
-
|
|
271
|
-
/** @type {import('intlayer').Dictionary} */
|
|
272
|
-
const helloWorldContent = {
|
|
273
|
-
key: "helloworld",
|
|
274
|
-
content: {
|
|
275
|
-
count: t({ en: "count is ", fr: "le compte est ", es: "el recuento es ", it: "il conteggio è " }),
|
|
276
|
-
edit: t({
|
|
277
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
278
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
279
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
280
|
-
it: "Modifica <code>components/HelloWorld.vue</code> e salva per testare HMR",
|
|
281
|
-
}),
|
|
282
|
-
checkOut: t({ en: "Check out ", fr: "Vérifiez ", es: "Compruebe ", it: "Dai un'occhiata a " }),
|
|
283
|
-
nuxtIntlayer: t({
|
|
284
|
-
en: "Nuxt Intlayer documentation",
|
|
285
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
286
|
-
es: "Documentación de Nuxt Intlayer",
|
|
287
|
-
it: "Documentazione di Nuxt Intlayer",
|
|
288
|
-
}),
|
|
289
|
-
es: "Documentación de Nuxt Intlayer",
|
|
290
|
-
}),
|
|
291
|
-
learnMore: t({
|
|
292
|
-
en: "Learn more about Nuxt in the ",
|
|
293
|
-
it: "Per saperne di più su Nuxt in ",
|
|
294
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
295
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
296
|
-
}),
|
|
297
|
-
nuxtDocs: t({
|
|
298
|
-
en: "Nuxt Documentation",
|
|
299
|
-
it: "Documentazione Nuxt",
|
|
300
|
-
fr: "Documentation Nuxt",
|
|
301
|
-
es: "Documentación de Nuxt",
|
|
302
|
-
}),
|
|
303
|
-
readTheDocs: t({
|
|
304
|
-
en: "Click on the Nuxt logo to learn more",
|
|
305
|
-
it: "Clicca sul logo di Nuxt per saperne di più",
|
|
306
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
307
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
308
|
-
}),
|
|
309
|
-
},
|
|
310
|
-
};
|
|
212
|
+
### Passo 5: Utilizza Intlayer nel Tuo Codice
|
|
311
213
|
|
|
312
|
-
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
```json fileName="components/helloWorld.content.json" contentDeclarationFormat="json"
|
|
316
|
-
{
|
|
317
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
318
|
-
"key": "helloworld",
|
|
319
|
-
"content": {
|
|
320
|
-
"count": {
|
|
321
|
-
"nodeType": "translation",
|
|
322
|
-
"translation": {
|
|
323
|
-
"en": "count is ",
|
|
324
|
-
"fr": "le compte est ",
|
|
325
|
-
"es": "el recuento es ",
|
|
326
|
-
"it": "il conteggio è "
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
"edit": {
|
|
330
|
-
"nodeType": "translation",
|
|
331
|
-
"translation": {
|
|
332
|
-
"en": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
333
|
-
"fr": "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
334
|
-
"es": "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
335
|
-
"it": "Modifica <code>components/HelloWorld.vue</code> e salva per testare HMR"
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
"checkOut": {
|
|
339
|
-
"nodeType": "translation",
|
|
340
|
-
"translation": {
|
|
341
|
-
"en": "Check out ",
|
|
342
|
-
"fr": "Vérifiez ",
|
|
343
|
-
"es": "Compruebe ",
|
|
344
|
-
"it": "Dai un'occhiata a "
|
|
345
|
-
}
|
|
346
|
-
},
|
|
347
|
-
"nuxtIntlayer": {
|
|
348
|
-
"nodeType": "translation",
|
|
349
|
-
"translation": {
|
|
350
|
-
"it": "Documentazione di Nuxt Intlayer"
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
"learnMore": {
|
|
354
|
-
"nodeType": "translation",
|
|
355
|
-
"translation": {
|
|
356
|
-
"it": "Scopri di più su Nuxt in "
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
"nuxtDocs": {
|
|
360
|
-
"nodeType": "translation",
|
|
361
|
-
"translation": {
|
|
362
|
-
"it": "Documentazione di Nuxt"
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
"readTheDocs": {
|
|
366
|
-
"nodeType": "translation",
|
|
367
|
-
"translation": {
|
|
368
|
-
"it": "Clicca sul logo di Nuxt per saperne di più"
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
"es": "Haga clic en el logotipo de Nuxt para obtener más información"
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
```
|
|
377
|
-
|
|
378
|
-
> Le dichiarazioni di contenuto possono essere definite ovunque nella tua applicazione purché siano incluse nella directory `contentDir` (di default, `./src`). E corrispondano all'estensione del file di dichiarazione del contenuto (di default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
379
|
-
|
|
380
|
-
> Per maggiori dettagli, consulta la [documentazione sulla dichiarazione del contenuto](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md).
|
|
381
|
-
|
|
382
|
-
### Passo 5: Utilizza Intlayer nel tuo codice
|
|
383
|
-
|
|
384
|
-
Accedi ai tuoi dizionari di contenuto in tutta la tua applicazione Nuxt utilizzando il composable `useIntlayer`:
|
|
214
|
+
Accedi ai tuoi dizionari di contenuti in tutta l'applicazione Nuxt utilizzando il composable `useIntlayer`:
|
|
385
215
|
|
|
386
216
|
```vue fileName="components/HelloWorld.vue"
|
|
387
217
|
<script setup lang="ts">
|
|
@@ -434,82 +264,72 @@ const countRef = ref(0);
|
|
|
434
264
|
|
|
435
265
|
Intlayer offre diverse API per accedere ai tuoi contenuti:
|
|
436
266
|
|
|
437
|
-
- **Sintassi basata su componenti** (consigliata):
|
|
438
|
-
Usa la sintassi `<myContent
|
|
267
|
+
- **Sintassi basata su componenti** (consigliata):
|
|
268
|
+
Usa la sintassi `<myContent />`, o `<Component :is="myContent" />` per rendere il contenuto come un Nodo Intlayer. Questo si integra perfettamente con il [Visual Editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_visual_editor.md) e il [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_CMS.md).
|
|
439
269
|
|
|
440
|
-
- **Sintassi basata su stringhe**:
|
|
441
|
-
Usa `{{ myContent }}` per rendere il contenuto come testo semplice, senza supporto
|
|
270
|
+
- **Sintassi basata su stringhe**:
|
|
271
|
+
Usa `{{ myContent }}` per rendere il contenuto come testo semplice, senza supporto per il Visual Editor.
|
|
442
272
|
|
|
443
|
-
- **Sintassi HTML grezzo**:
|
|
444
|
-
Usa `<div v-html="myContent" />` per rendere il contenuto come HTML grezzo, senza supporto
|
|
273
|
+
- **Sintassi HTML grezzo**:
|
|
274
|
+
Usa `<div v-html="myContent" />` per rendere il contenuto come HTML grezzo, senza supporto per il Visual Editor.
|
|
445
275
|
|
|
446
|
-
- **Sintassi di destrutturazione**:
|
|
276
|
+
- **Sintassi di destrutturazione**:
|
|
447
277
|
Il composable `useIntlayer` restituisce un Proxy con il contenuto. Questo proxy può essere destrutturato per accedere al contenuto mantenendo la reattività.
|
|
448
|
-
- Usa `const content = useIntlayer("myContent");` e `{{ content.myContent }}` / `<content.myContent />`.
|
|
449
|
-
- Oppure usa `const { myContent } = useIntlayer("myContent");` e `{{ myContent}}` / `<myContent/>` per destrutturare il contenuto.
|
|
278
|
+
- Usa `const content = useIntlayer("myContent");` e `{{ content.myContent }}` / `<content.myContent />`.
|
|
279
|
+
- Oppure usa `const { myContent } = useIntlayer("myContent");` e `{{ myContent}}` / `<myContent/>` per destrutturare il contenuto.
|
|
450
280
|
|
|
451
281
|
### (Opzionale) Passo 6: Cambiare la lingua del tuo contenuto
|
|
452
282
|
|
|
453
|
-
Per cambiare la lingua del tuo contenuto, puoi usare la funzione `setLocale` fornita dal composable `useLocale`. Questa funzione ti permette di impostare la
|
|
283
|
+
Per cambiare la lingua del tuo contenuto, puoi usare la funzione `setLocale` fornita dal composable `useLocale`. Questa funzione ti permette di impostare la locale dell'applicazione e aggiornare di conseguenza il contenuto.
|
|
454
284
|
|
|
455
|
-
Crea un componente per cambiare lingua:
|
|
285
|
+
Crea un componente per cambiare lingua usando `NuxtLink`. **Usare link invece di pulsanti per il cambio di locale è una best practice per la SEO e la scoperta delle pagine**, poiché permette ai motori di ricerca di scansionare e indicizzare tutte le versioni localizzate delle tue pagine:
|
|
456
286
|
|
|
457
287
|
```vue fileName="components/LocaleSwitcher.vue"
|
|
458
|
-
<template>
|
|
459
|
-
<div class="locale-switcher">
|
|
460
|
-
<select v-model="selectedLocale" @change="changeLocale">
|
|
461
|
-
<option v-for="loc in availableLocales" :key="loc" :value="loc">
|
|
462
|
-
{{ getLocaleName(loc) }}
|
|
463
|
-
</option>
|
|
464
|
-
</select>
|
|
465
|
-
</div>
|
|
466
|
-
</template>
|
|
467
|
-
|
|
468
288
|
<script setup lang="ts">
|
|
469
|
-
import {
|
|
470
|
-
import { getLocaleName } from "intlayer";
|
|
289
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
471
290
|
import { useLocale } from "vue-intlayer";
|
|
472
291
|
|
|
473
|
-
//
|
|
292
|
+
// Nuxt importa automaticamente useRoute
|
|
293
|
+
const route = useRoute();
|
|
474
294
|
const { locale, availableLocales, setLocale } = useLocale();
|
|
475
|
-
|
|
476
|
-
// Tieni traccia della localizzazione selezionata con un ref
|
|
477
|
-
const selectedLocale = ref(locale.value);
|
|
478
|
-
|
|
479
|
-
// Aggiorna la localizzazione quando la selezione cambia
|
|
480
|
-
const changeLocale = () => setLocale(selectedLocale.value);
|
|
481
|
-
|
|
482
|
-
// Mantieni selectedLocale sincronizzato con la localizzazione globale
|
|
483
|
-
watch(
|
|
484
|
-
() => locale.value,
|
|
485
|
-
(newLocale) => {
|
|
486
|
-
selectedLocale.value = newLocale;
|
|
487
|
-
}
|
|
488
|
-
);
|
|
489
295
|
</script>
|
|
296
|
+
|
|
297
|
+
<template>
|
|
298
|
+
<nav class="locale-switcher">
|
|
299
|
+
<NuxtLink
|
|
300
|
+
v-for="localeEl in availableLocales"
|
|
301
|
+
:key="localeEl"
|
|
302
|
+
:to="getLocalizedUrl(route.fullPath, localeEl)"
|
|
303
|
+
class="locale-link"
|
|
304
|
+
:class="{ 'active-locale': localeEl === locale }"
|
|
305
|
+
@click="setLocale(localeEl)"
|
|
306
|
+
>
|
|
307
|
+
{{ getLocaleName(localeEl) }}
|
|
308
|
+
</NuxtLink>
|
|
309
|
+
</nav>
|
|
490
310
|
</template>
|
|
311
|
+
```
|
|
491
312
|
|
|
492
|
-
|
|
493
|
-
.locale-switcher {
|
|
494
|
-
margin: 1rem 0;
|
|
495
|
-
}
|
|
313
|
+
> L'uso di `NuxtLink` con attributi `href` corretti (tramite `getLocalizedUrl`) garantisce che i motori di ricerca possano scoprire tutte le varianti linguistiche delle tue pagine. Questo è preferibile rispetto al cambio di lingua basato solo su JavaScript, che i crawler dei motori di ricerca potrebbero non seguire.
|
|
496
314
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
315
|
+
Quindi, configura il tuo `app.vue` per utilizzare i layout:
|
|
316
|
+
|
|
317
|
+
```vue fileName="app.vue"
|
|
318
|
+
<template>
|
|
319
|
+
<NuxtLayout>
|
|
320
|
+
<NuxtPage />
|
|
321
|
+
</NuxtLayout>
|
|
322
|
+
</template>
|
|
503
323
|
```
|
|
504
324
|
|
|
505
|
-
|
|
325
|
+
### (Opzionale) Passo 6b: Crea un Layout con Navigazione
|
|
506
326
|
|
|
507
|
-
|
|
327
|
+
I layout di Nuxt ti permettono di definire una struttura comune per le tue pagine. Crea un layout di default che includa il selettore di lingua e la navigazione:
|
|
328
|
+
|
|
329
|
+
```vue fileName="layouts/default.vue"
|
|
508
330
|
<script setup lang="ts">
|
|
509
|
-
import
|
|
331
|
+
import Links from "~/components/Links.vue";
|
|
510
332
|
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
511
|
-
|
|
512
|
-
const content = useIntlayer("app"); // Crea il file di dichiarazione intlayer correlato
|
|
513
333
|
</script>
|
|
514
334
|
|
|
515
335
|
<template>
|
|
@@ -518,15 +338,20 @@ const content = useIntlayer("app"); // Crea il file di dichiarazione intlayer co
|
|
|
518
338
|
<LocaleSwitcher />
|
|
519
339
|
</header>
|
|
520
340
|
<main>
|
|
521
|
-
<
|
|
341
|
+
<slot />
|
|
522
342
|
</main>
|
|
343
|
+
|
|
344
|
+
<Links href="/">Home</Links>
|
|
345
|
+
<Links href="/about">About</Links>
|
|
523
346
|
</div>
|
|
524
347
|
</template>
|
|
525
348
|
```
|
|
526
349
|
|
|
527
|
-
|
|
350
|
+
Il componente `Links` (mostrato di seguito) garantisce che i link di navigazione interna siano automaticamente localizzati.
|
|
528
351
|
|
|
529
|
-
|
|
352
|
+
### (Opzionale) Passo 7: Aggiungi il Routing localizzato alla tua applicazione
|
|
353
|
+
|
|
354
|
+
Nuxt gestisce automaticamente il routing localizzato quando si utilizza il modulo `nuxt-intlayer`. Questo crea rotte per ogni lingua automaticamente in base alla struttura della directory delle tue pagine.
|
|
530
355
|
|
|
531
356
|
Esempio:
|
|
532
357
|
|
|
@@ -538,248 +363,301 @@ pages/
|
|
|
538
363
|
└── index.vue → /contact, /fr/contact, /es/contact
|
|
539
364
|
```
|
|
540
365
|
|
|
541
|
-
Per creare
|
|
366
|
+
Per creare pagine localizzate, crea semplicemente i tuoi file Vue nella directory `pages/`. Ecco due esempi di pagine:
|
|
367
|
+
|
|
368
|
+
**Pagina Home (`pages/index.vue`):**
|
|
369
|
+
|
|
370
|
+
```vue fileName="pages/index.vue"
|
|
371
|
+
<script setup lang="ts">
|
|
372
|
+
import { useIntlayer } from "vue-intlayer";
|
|
373
|
+
|
|
374
|
+
const content = useIntlayer("home-page");
|
|
375
|
+
|
|
376
|
+
useHead({
|
|
377
|
+
title: content.metaTitle.value,
|
|
378
|
+
meta: [
|
|
379
|
+
{
|
|
380
|
+
name: "description",
|
|
381
|
+
content: content.metaDescription.value,
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
});
|
|
385
|
+
</script>
|
|
386
|
+
|
|
387
|
+
<template>
|
|
388
|
+
<h1><content.title /></h1>
|
|
389
|
+
</template>
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**Pagina About (`pages/about.vue`):**
|
|
542
393
|
|
|
543
394
|
```vue fileName="pages/about.vue"
|
|
544
395
|
<script setup lang="ts">
|
|
545
396
|
import { useIntlayer } from "vue-intlayer";
|
|
546
397
|
|
|
547
|
-
const content = useIntlayer("about");
|
|
398
|
+
const content = useIntlayer("about-page");
|
|
399
|
+
|
|
400
|
+
useHead({
|
|
401
|
+
title: content.metaTitle.raw, // Usa .raw per accedere alla stringa primitiva
|
|
402
|
+
meta: [
|
|
403
|
+
{
|
|
404
|
+
name: "description",
|
|
405
|
+
content: content.metaDescription.raw, // Usa .raw per accedere alla stringa primitiva
|
|
406
|
+
},
|
|
407
|
+
],
|
|
408
|
+
});
|
|
548
409
|
</script>
|
|
549
410
|
|
|
550
411
|
<template>
|
|
551
|
-
<
|
|
552
|
-
<h1>{{ content.title }}</h1>
|
|
553
|
-
<p>{{ content.description }}</p>
|
|
554
|
-
</div>
|
|
412
|
+
<h1><content.title /></h1>
|
|
555
413
|
</template>
|
|
556
414
|
```
|
|
557
415
|
|
|
558
|
-
|
|
416
|
+
> Nota: `useHead` è importato automaticamente in Nuxt. Puoi accedere ai valori del contenuto usando `.value` (reattivo) o `.raw` (stringa primitiva) a seconda delle tue esigenze.
|
|
417
|
+
|
|
418
|
+
Il modulo `nuxt-intlayer` farà automaticamente:
|
|
559
419
|
|
|
560
|
-
- Rilevare la
|
|
561
|
-
- Gestire il cambio di
|
|
420
|
+
- Rilevare la locale preferita dall'utente
|
|
421
|
+
- Gestire il cambio di locale tramite URL
|
|
562
422
|
- Impostare l'attributo `<html lang="">` appropriato
|
|
563
|
-
- Gestire i cookie della
|
|
423
|
+
- Gestire i cookie della locale
|
|
564
424
|
- Reindirizzare gli utenti all'URL localizzato corretto
|
|
565
425
|
|
|
566
426
|
### (Opzionale) Passo 8: Creare un componente Link localizzato
|
|
567
427
|
|
|
568
|
-
Per
|
|
569
|
-
|
|
570
|
-
```vue fileName="components/LocalizedLink.vue"
|
|
571
|
-
<template>
|
|
572
|
-
<NuxtLink :to="localizedHref" v-bind="$attrs">
|
|
573
|
-
<slot />
|
|
574
|
-
</NuxtLink>
|
|
575
|
-
</template>
|
|
428
|
+
Per garantire che la navigazione della tua applicazione rispetti la lingua corrente, puoi creare un componente `Links` personalizzato. Questo componente aggiunge automaticamente il prefisso della lingua corrente agli URL interni, cosa essenziale per la **SEO e la scoperta delle pagine**.
|
|
576
429
|
|
|
430
|
+
```vue fileName="components/Links.vue"
|
|
577
431
|
<script setup lang="ts">
|
|
578
|
-
import { computed } from "vue";
|
|
579
432
|
import { getLocalizedUrl } from "intlayer";
|
|
433
|
+
// Importa il composable per la gestione della lingua corrente
|
|
580
434
|
import { useLocale } from "vue-intlayer";
|
|
581
435
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
},
|
|
587
|
-
});
|
|
436
|
+
interface Props {
|
|
437
|
+
href: string;
|
|
438
|
+
locale?: string;
|
|
439
|
+
}
|
|
588
440
|
|
|
589
|
-
const
|
|
441
|
+
const props = defineProps<Props>();
|
|
590
442
|
|
|
591
|
-
|
|
592
|
-
const isExternalLink = computed(() => /^https?:\/\//.test(props.to || ""));
|
|
443
|
+
const { locale: currentLocale } = useLocale();
|
|
593
444
|
|
|
594
|
-
//
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
);
|
|
445
|
+
// Calcola il percorso finale
|
|
446
|
+
const finalPath = computed(() => {
|
|
447
|
+
// 1. Verifica se il link è esterno
|
|
448
|
+
const isExternal = /^https?:\/\//.test(props.href || "");
|
|
449
|
+
|
|
450
|
+
// 2. Se esterno, restituisci così com'è (NuxtLink gestisce la generazione del tag <a>)
|
|
451
|
+
if (isExternal) return props.href;
|
|
452
|
+
|
|
453
|
+
// 3. Se è interno, localizza l'URL
|
|
454
|
+
const targetLocale = props.locale || currentLocale.value;
|
|
455
|
+
return getLocalizedUrl(props.href, targetLocale);
|
|
456
|
+
});
|
|
598
457
|
</script>
|
|
458
|
+
|
|
459
|
+
<template>
|
|
460
|
+
<NuxtLink :to="finalPath" v-bind="$attrs">
|
|
461
|
+
<slot />
|
|
462
|
+
</NuxtLink>
|
|
463
|
+
</template>
|
|
599
464
|
```
|
|
600
465
|
|
|
601
466
|
Quindi usa questo componente in tutta la tua applicazione:
|
|
602
467
|
|
|
603
|
-
```vue fileName="
|
|
468
|
+
```vue fileName="layouts/default.vue"
|
|
469
|
+
<script setup lang="ts">
|
|
470
|
+
import Links from "~/components/Links.vue";
|
|
471
|
+
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
472
|
+
</script>
|
|
473
|
+
|
|
604
474
|
<template>
|
|
605
475
|
<div>
|
|
606
|
-
<
|
|
607
|
-
|
|
608
|
-
</
|
|
609
|
-
<
|
|
610
|
-
|
|
611
|
-
</
|
|
476
|
+
<header>
|
|
477
|
+
<LocaleSwitcher />
|
|
478
|
+
</header>
|
|
479
|
+
<main>
|
|
480
|
+
<slot />
|
|
481
|
+
</main>
|
|
482
|
+
|
|
483
|
+
<Links href="/">Home</Links>
|
|
484
|
+
<Links href="/about">About</Links>
|
|
612
485
|
</div>
|
|
613
486
|
</template>
|
|
614
|
-
|
|
615
|
-
<script setup lang="ts">
|
|
616
|
-
import { useIntlayer } from "vue-intlayer";
|
|
617
|
-
import LocalizedLink from "~/components/LocalizedLink.vue";
|
|
618
|
-
|
|
619
|
-
const content = useIntlayer("home");
|
|
620
|
-
</script>
|
|
621
487
|
```
|
|
622
488
|
|
|
623
|
-
|
|
489
|
+
> Utilizzando `NuxtLink` con percorsi localizzati, si garantisce che:
|
|
490
|
+
>
|
|
491
|
+
> - I motori di ricerca possano eseguire la scansione e indicizzare tutte le versioni linguistiche delle tue pagine
|
|
492
|
+
> - Gli utenti possano condividere direttamente URL localizzati
|
|
493
|
+
> - La cronologia del browser funzioni correttamente con URL prefissati dalla locale
|
|
494
|
+
|
|
495
|
+
### (Opzionale) Passo 9: Gestire Metadata e SEO
|
|
624
496
|
|
|
625
|
-
Nuxt offre eccellenti funzionalità SEO. Puoi
|
|
497
|
+
Nuxt offre eccellenti funzionalità SEO tramite il composable `useHead` (auto-importato). Puoi utilizzare Intlayer per gestire i metadata localizzati usando l'accessore `.raw` o `.value` per ottenere il valore stringa primitivo:
|
|
626
498
|
|
|
627
499
|
```vue fileName="pages/about.vue"
|
|
628
500
|
<script setup lang="ts">
|
|
629
|
-
import {
|
|
630
|
-
import { getIntlayer } from "intlayer";
|
|
631
|
-
import { useLocale } from "vue-intlayer";
|
|
501
|
+
import { useIntlayer } from "vue-intlayer";
|
|
632
502
|
|
|
633
|
-
|
|
634
|
-
const content =
|
|
503
|
+
// useHead è auto-importato in Nuxt
|
|
504
|
+
const content = useIntlayer("about-page");
|
|
635
505
|
|
|
636
|
-
|
|
637
|
-
title: content.
|
|
638
|
-
|
|
506
|
+
useHead({
|
|
507
|
+
title: content.metaTitle.raw, // Usa .raw per accedere al valore stringa primitivo
|
|
508
|
+
meta: [
|
|
509
|
+
{
|
|
510
|
+
name: "description",
|
|
511
|
+
content: content.metaDescription.raw, // Usa .raw per accedere alla stringa primitiva
|
|
512
|
+
},
|
|
513
|
+
],
|
|
639
514
|
});
|
|
640
515
|
</script>
|
|
641
516
|
|
|
642
517
|
<template>
|
|
643
|
-
<
|
|
644
|
-
<h1>{{ content.pageTitle }}</h1>
|
|
645
|
-
<p>{{ content.pageContent }}</p>
|
|
646
|
-
</div>
|
|
518
|
+
<h1><content.title /></h1>
|
|
647
519
|
</template>
|
|
648
520
|
```
|
|
649
521
|
|
|
522
|
+
> In alternativa, puoi usare la funzione `import { getIntlayer } from "intlayer"` per ottenere il contenuto senza la reattività di Vue.
|
|
523
|
+
|
|
524
|
+
> **Accesso ai valori del contenuto:**
|
|
525
|
+
>
|
|
526
|
+
> - Usa `.raw` per ottenere il valore stringa primitivo (non reattivo)
|
|
527
|
+
> - Usa `.value` per ottenere il valore reattivo
|
|
528
|
+
> - Usa la sintassi componente `<content.key />` per il supporto all'Editor Visuale
|
|
529
|
+
|
|
650
530
|
Crea la dichiarazione di contenuto corrispondente:
|
|
651
531
|
|
|
652
|
-
```ts fileName="pages/about-
|
|
532
|
+
```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
|
|
653
533
|
import { t, type Dictionary } from "intlayer";
|
|
654
|
-
import type { useSeoMeta } from "nuxt/app";
|
|
655
534
|
|
|
656
|
-
const
|
|
657
|
-
key: "about-
|
|
535
|
+
const aboutPageContent = {
|
|
536
|
+
key: "about-page",
|
|
658
537
|
content: {
|
|
659
|
-
|
|
538
|
+
metaTitle: t({
|
|
660
539
|
en: "About Us - My Company",
|
|
661
540
|
fr: "À Propos - Ma Société",
|
|
662
541
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
663
|
-
it: "Chi Siamo - La Mia Azienda",
|
|
664
542
|
}),
|
|
665
|
-
|
|
543
|
+
metaDescription: t({
|
|
544
|
+
it: "Scopri di più sulla nostra azienda e sulla nostra missione",
|
|
666
545
|
en: "Learn more about our company and our mission",
|
|
667
546
|
fr: "En savoir plus sur notre société et notre mission",
|
|
668
547
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
669
|
-
|
|
548
|
+
}),
|
|
549
|
+
title: t({
|
|
550
|
+
it: "Chi Siamo",
|
|
551
|
+
en: "About Us",
|
|
552
|
+
fr: "À Propos",
|
|
553
|
+
es: "Acerca de Nosotros",
|
|
670
554
|
}),
|
|
671
555
|
},
|
|
672
|
-
} satisfies Dictionary
|
|
556
|
+
} satisfies Dictionary;
|
|
673
557
|
|
|
674
|
-
export default
|
|
558
|
+
export default aboutPageContent;
|
|
675
559
|
```
|
|
676
560
|
|
|
677
|
-
```
|
|
561
|
+
```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
|
|
678
562
|
import { t } from "intlayer";
|
|
679
563
|
|
|
680
564
|
/** @type {import('intlayer').Dictionary} */
|
|
681
|
-
const
|
|
682
|
-
key: "about-
|
|
565
|
+
const aboutPageContent = {
|
|
566
|
+
key: "about-page",
|
|
683
567
|
content: {
|
|
684
|
-
|
|
685
|
-
zh: "关于我们 - 我的公司",
|
|
568
|
+
metaTitle: t({
|
|
686
569
|
it: "Chi Siamo - La Mia Azienda",
|
|
687
570
|
en: "About Us - My Company",
|
|
688
571
|
fr: "À Propos - Ma Société",
|
|
689
572
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
690
573
|
}),
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
it: "Scopri di più sulla nostra azienda e sulla nostra missione",
|
|
694
|
-
en: "Learn more about our company and our mission",
|
|
574
|
+
metaDescription: t({
|
|
575
|
+
en: "Scopri di più sulla nostra azienda e sulla nostra missione",
|
|
695
576
|
fr: "En savoir plus sur notre société et notre mission",
|
|
696
577
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
697
578
|
}),
|
|
579
|
+
title: t({
|
|
580
|
+
en: "Chi Siamo",
|
|
581
|
+
fr: "À Propos",
|
|
582
|
+
es: "Acerca de Nosotros",
|
|
583
|
+
}),
|
|
698
584
|
},
|
|
699
585
|
};
|
|
700
586
|
|
|
701
|
-
export default
|
|
587
|
+
export default aboutPageContent;
|
|
702
588
|
```
|
|
703
589
|
|
|
704
|
-
```
|
|
590
|
+
```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
|
|
705
591
|
const { t } = require("intlayer");
|
|
706
592
|
|
|
707
593
|
/** @type {import('intlayer').Dictionary} */
|
|
708
|
-
const
|
|
709
|
-
key: "about-
|
|
594
|
+
const aboutPageContent = {
|
|
595
|
+
key: "about-page",
|
|
710
596
|
content: {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
it: "Chi Siamo - La Mia Azienda",
|
|
714
|
-
en: "About Us - My Company",
|
|
597
|
+
metaTitle: t({
|
|
598
|
+
en: "Chi Siamo - La Mia Azienda",
|
|
715
599
|
fr: "À Propos - Ma Société",
|
|
716
600
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
717
601
|
}),
|
|
718
|
-
|
|
719
|
-
zh: "了解更多关于我们公司和我们的使命",
|
|
602
|
+
metaDescription: t({
|
|
720
603
|
en: "Learn more about our company and our mission",
|
|
721
604
|
fr: "En savoir plus sur notre société et notre mission",
|
|
722
605
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
723
606
|
it: "Scopri di più sulla nostra azienda e sulla nostra missione",
|
|
724
607
|
}),
|
|
608
|
+
title: t({
|
|
609
|
+
en: "About Us",
|
|
610
|
+
fr: "À Propos",
|
|
611
|
+
es: "Acerca de Nosotros",
|
|
612
|
+
it: "Chi Siamo",
|
|
613
|
+
}),
|
|
725
614
|
},
|
|
726
615
|
};
|
|
727
616
|
|
|
728
|
-
module.exports =
|
|
617
|
+
module.exports = aboutPageContent;
|
|
729
618
|
```
|
|
730
619
|
|
|
731
|
-
```json fileName="pages/about-
|
|
620
|
+
```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
|
|
732
621
|
{
|
|
733
|
-
"
|
|
622
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
623
|
+
"key": "about-page",
|
|
734
624
|
"content": {
|
|
735
|
-
"
|
|
625
|
+
"metaTitle": {
|
|
736
626
|
"nodeType": "translation",
|
|
737
|
-
"
|
|
738
|
-
"zh": "关于我们 - 我的公司",
|
|
627
|
+
"translation": {
|
|
739
628
|
"en": "About Us - My Company",
|
|
740
629
|
"fr": "À Propos - Ma Société",
|
|
741
630
|
"es": "Acerca de Nosotros - Mi Empresa",
|
|
742
631
|
"it": "Chi Siamo - La Mia Azienda"
|
|
743
632
|
}
|
|
744
633
|
},
|
|
745
|
-
"
|
|
634
|
+
"metaDescription": {
|
|
746
635
|
"nodeType": "translation",
|
|
747
|
-
"
|
|
748
|
-
"zh": "了解更多关于我们公司和我们的使命",
|
|
636
|
+
"translation": {
|
|
749
637
|
"en": "Learn more about our company and our mission",
|
|
750
638
|
"fr": "En savoir plus sur notre société et notre mission",
|
|
751
|
-
"es": "Conozca más sobre nuestra empresa y nuestra misión"
|
|
639
|
+
"es": "Conozca más sobre nuestra empresa y nuestra misión",
|
|
640
|
+
"it": "Scopri di più sulla nostra azienda e sulla nostra missione"
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
"title": {
|
|
644
|
+
"nodeType": "translation",
|
|
645
|
+
"translation": {
|
|
646
|
+
"en": "About Us",
|
|
647
|
+
"fr": "À Propos",
|
|
648
|
+
"es": "Acerca de Nosotros",
|
|
649
|
+
"it": "Chi Siamo"
|
|
752
650
|
}
|
|
753
651
|
}
|
|
754
652
|
}
|
|
755
653
|
}
|
|
756
654
|
```
|
|
757
655
|
|
|
758
|
-
### Configurare TypeScript
|
|
759
|
-
|
|
760
|
-
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
|
|
761
|
-
|
|
762
|
-

|
|
763
|
-
|
|
764
|
-

|
|
765
|
-
|
|
766
|
-
Assicurati che la tua configurazione di TypeScript includa i tipi generati automaticamente.
|
|
767
|
-
|
|
768
|
-
```json5 fileName="tsconfig.json"
|
|
769
|
-
{
|
|
770
|
-
// ... Le tue configurazioni esistenti di TypeScript
|
|
771
|
-
"include": [
|
|
772
|
-
// ... Le tue configurazioni TypeScript esistenti
|
|
773
|
-
".intlayer/**/*.ts", // Includi i tipi generati automaticamente
|
|
774
|
-
],
|
|
775
|
-
}
|
|
776
|
-
```
|
|
777
|
-
|
|
778
656
|
### Configurazione Git
|
|
779
657
|
|
|
780
658
|
Si consiglia di ignorare i file generati da Intlayer. Questo ti permette di evitare di committarli nel tuo repository Git.
|
|
781
659
|
|
|
782
|
-
Per
|
|
660
|
+
Per farlo, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
783
661
|
|
|
784
662
|
```plaintext fileName=".gitignore"
|
|
785
663
|
# Ignora i file generati da Intlayer
|
|
@@ -788,23 +666,21 @@ Per fare ciò, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
|
788
666
|
|
|
789
667
|
### Estensione VS Code
|
|
790
668
|
|
|
791
|
-
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare
|
|
669
|
+
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare la **Intlayer VS Code Extension** ufficiale.
|
|
792
670
|
|
|
793
671
|
[Installa dal VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
794
672
|
|
|
795
|
-
Questa estensione
|
|
673
|
+
Questa estensione offre:
|
|
796
674
|
|
|
797
|
-
- **
|
|
798
|
-
- **Rilevamento errori in tempo reale** per
|
|
675
|
+
- **Autocompletamento** per le chiavi di traduzione.
|
|
676
|
+
- **Rilevamento errori in tempo reale** per traduzioni mancanti.
|
|
799
677
|
- **Anteprime inline** del contenuto tradotto.
|
|
800
678
|
- **Azioni rapide** per creare e aggiornare facilmente le traduzioni.
|
|
801
679
|
|
|
802
|
-
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione
|
|
680
|
+
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione della Intlayer VS Code Extension](https://intlayer.org/doc/vs-code-extension).
|
|
803
681
|
|
|
804
682
|
---
|
|
805
683
|
|
|
806
|
-
###
|
|
807
|
-
|
|
808
|
-
Per approfondire, 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).
|
|
684
|
+
### Vai oltre
|
|
809
685
|
|
|
810
|
-
|
|
686
|
+
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).
|