@intlayer/docs 7.3.11 → 7.3.12
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 +305 -421
- 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 +296 -394
- 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 +242 -321
- 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 +262 -358
- 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 +284 -375
- 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 +288 -387
- 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 +318 -434
- 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 +275 -376
- 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 +312 -408
- 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 +319 -414
- 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 +307 -406
- 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 +282 -457
- 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 +288 -403
- 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 +300 -410
- 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 +327 -392
- 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 +282 -399
- 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 +311 -444
- 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 +6 -6
- 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,68 @@ 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=IE3XWkZ6a5U
|
|
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
|
+
<iframe
|
|
50
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
51
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
52
|
+
title="Demo CodeSandbox - Come internazionalizzare la tua applicazione usando Intlayer"
|
|
53
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
54
|
+
loading="lazy"
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
### Passo 1: Installa le dipendenze
|
|
58
|
+
|
|
59
|
+
<Tab defaultTab="video">
|
|
60
|
+
<TabItem label="Video" value="video">
|
|
61
|
+
|
|
62
|
+
<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/IE3XWkZ6a5U?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
63
|
+
|
|
64
|
+
</TabItem>
|
|
65
|
+
<TabItem label="Codice" value="code">
|
|
66
|
+
|
|
67
|
+
<iframe
|
|
68
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
69
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
70
|
+
title="Demo CodeSandbox - Come internazionalizzare la tua applicazione usando Intlayer"
|
|
71
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
72
|
+
loading="lazy"
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
</TabItem>
|
|
76
|
+
</Tab>
|
|
42
77
|
|
|
43
|
-
|
|
78
|
+
Vedi il [Template dell'Applicazione](https://github.com/aymericzip/intlayer-nuxt-4-template) su GitHub.
|
|
44
79
|
|
|
45
80
|
Installa i pacchetti necessari usando npm:
|
|
46
81
|
|
|
@@ -61,17 +96,17 @@ yarn add --save-dev nuxt-intlayer
|
|
|
61
96
|
|
|
62
97
|
- **intlayer**
|
|
63
98
|
|
|
64
|
-
Il pacchetto
|
|
99
|
+
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
100
|
|
|
66
101
|
- **vue-intlayer**
|
|
67
102
|
Il pacchetto che integra Intlayer con l'applicazione Vue. Fornisce i composables per i componenti Vue.
|
|
68
103
|
|
|
69
104
|
- **nuxt-intlayer**
|
|
70
|
-
Il modulo Nuxt che integra Intlayer con le applicazioni Nuxt. Fornisce una configurazione automatica, middleware per il rilevamento della
|
|
105
|
+
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
106
|
|
|
72
107
|
### Passo 2: Configurazione del tuo progetto
|
|
73
108
|
|
|
74
|
-
Crea un file di configurazione per
|
|
109
|
+
Crea un file di configurazione per configurare le lingue della tua applicazione:
|
|
75
110
|
|
|
76
111
|
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
77
112
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -82,13 +117,10 @@ const config: IntlayerConfig = {
|
|
|
82
117
|
Locales.ENGLISH,
|
|
83
118
|
Locales.FRENCH,
|
|
84
119
|
Locales.SPANISH,
|
|
85
|
-
// Le tue altre
|
|
120
|
+
// Le tue altre localizzazioni
|
|
86
121
|
],
|
|
87
122
|
defaultLocale: Locales.ENGLISH,
|
|
88
123
|
},
|
|
89
|
-
content: {
|
|
90
|
-
contentDir: ["."], // Perché di default Intlayer monitorerà i file di dichiarazione dei contenuti dalla directory `./src`
|
|
91
|
-
},
|
|
92
124
|
};
|
|
93
125
|
|
|
94
126
|
export default config;
|
|
@@ -98,20 +130,16 @@ export default config;
|
|
|
98
130
|
import { Locales } from "intlayer";
|
|
99
131
|
|
|
100
132
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
101
|
-
// Configurazione per Intlayer
|
|
102
133
|
const config = {
|
|
103
134
|
internationalization: {
|
|
104
135
|
locales: [
|
|
105
136
|
Locales.ENGLISH,
|
|
106
137
|
Locales.FRENCH,
|
|
107
138
|
Locales.SPANISH,
|
|
108
|
-
// Le tue altre
|
|
139
|
+
// Le tue altre localizzazioni
|
|
109
140
|
],
|
|
110
141
|
defaultLocale: Locales.ENGLISH,
|
|
111
142
|
},
|
|
112
|
-
content: {
|
|
113
|
-
contentDir: ["."],
|
|
114
|
-
},
|
|
115
143
|
};
|
|
116
144
|
|
|
117
145
|
export default config;
|
|
@@ -121,20 +149,16 @@ export default config;
|
|
|
121
149
|
const { Locales } = require("intlayer");
|
|
122
150
|
|
|
123
151
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
124
|
-
// Configurazione per Intlayer
|
|
125
152
|
const config = {
|
|
126
153
|
internationalization: {
|
|
127
154
|
locales: [
|
|
128
155
|
Locales.ENGLISH,
|
|
129
156
|
Locales.FRENCH,
|
|
130
157
|
Locales.SPANISH,
|
|
131
|
-
// Le tue altre
|
|
158
|
+
// Le tue altre localizzazioni
|
|
132
159
|
],
|
|
133
160
|
defaultLocale: Locales.ENGLISH,
|
|
134
161
|
},
|
|
135
|
-
content: {
|
|
136
|
-
contentDir: ["."],
|
|
137
|
-
},
|
|
138
162
|
};
|
|
139
163
|
|
|
140
164
|
module.exports = config;
|
|
@@ -155,233 +179,47 @@ export default defineNuxtConfig({
|
|
|
155
179
|
});
|
|
156
180
|
```
|
|
157
181
|
|
|
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
|
|
182
|
+
> 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
183
|
|
|
160
|
-
### Passo 4: Dichiara il
|
|
184
|
+
### Passo 4: Dichiara il tuo contenuto
|
|
161
185
|
|
|
162
186
|
Crea e gestisci le tue dichiarazioni di contenuto per memorizzare le traduzioni:
|
|
163
187
|
|
|
164
|
-
```tsx fileName="
|
|
165
|
-
import {
|
|
188
|
+
```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
|
|
189
|
+
import { type Dictionary, t } from "intlayer";
|
|
166
190
|
|
|
167
|
-
const
|
|
168
|
-
key: "
|
|
191
|
+
const content = {
|
|
192
|
+
key: "home-page",
|
|
169
193
|
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 ",
|
|
194
|
+
title: t({
|
|
195
|
+
en: "Hello world",
|
|
196
|
+
fr: "Bonjour le monde",
|
|
197
|
+
es: "Hola mundo",
|
|
193
198
|
}),
|
|
194
|
-
|
|
195
|
-
en: "
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
es: "Documentación de Nuxt",
|
|
199
|
+
metaTitle: t({
|
|
200
|
+
en: "Welcome | My Application",
|
|
201
|
+
fr: "Bienvenue | Mon Application",
|
|
202
|
+
es: "Bienvenido | Mi Aplicación",
|
|
199
203
|
}),
|
|
200
|
-
|
|
201
|
-
en: "
|
|
202
|
-
it: "
|
|
203
|
-
fr: "
|
|
204
|
-
es: "
|
|
205
|
-
it: "Clicca sul logo di Nuxt per saperne di più",
|
|
204
|
+
metaDescription: t({
|
|
205
|
+
en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
|
|
206
|
+
it: "Scopri la homepage multilingue della tua app Nuxt alimentata da Intlayer.",
|
|
207
|
+
fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
|
|
208
|
+
es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
|
|
206
209
|
}),
|
|
207
210
|
},
|
|
208
211
|
} satisfies Dictionary;
|
|
209
212
|
|
|
210
|
-
export default
|
|
213
|
+
export default content;
|
|
211
214
|
```
|
|
212
215
|
|
|
213
|
-
|
|
214
|
-
import { t } from "intlayer";
|
|
216
|
+
> 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
217
|
|
|
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
|
-
};
|
|
218
|
+
> Per maggiori dettagli, consulta la [documentazione sulla dichiarazione dei contenuti](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/content_file.md).
|
|
264
219
|
|
|
265
|
-
|
|
266
|
-
```
|
|
220
|
+
### Passo 5: Utilizza Intlayer nel Tuo Codice
|
|
267
221
|
|
|
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
|
-
};
|
|
311
|
-
|
|
312
|
-
module.exports = helloWorldContent;
|
|
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`:
|
|
222
|
+
Accedi ai tuoi dizionari di contenuti in tutta l'applicazione Nuxt utilizzando il composable `useIntlayer`:
|
|
385
223
|
|
|
386
224
|
```vue fileName="components/HelloWorld.vue"
|
|
387
225
|
<script setup lang="ts">
|
|
@@ -434,82 +272,72 @@ const countRef = ref(0);
|
|
|
434
272
|
|
|
435
273
|
Intlayer offre diverse API per accedere ai tuoi contenuti:
|
|
436
274
|
|
|
437
|
-
- **Sintassi basata su componenti** (consigliata):
|
|
438
|
-
Usa la sintassi `<myContent
|
|
275
|
+
- **Sintassi basata su componenti** (consigliata):
|
|
276
|
+
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
277
|
|
|
440
|
-
- **Sintassi basata su stringhe**:
|
|
441
|
-
Usa `{{ myContent }}` per rendere il contenuto come testo semplice, senza supporto
|
|
278
|
+
- **Sintassi basata su stringhe**:
|
|
279
|
+
Usa `{{ myContent }}` per rendere il contenuto come testo semplice, senza supporto per il Visual Editor.
|
|
442
280
|
|
|
443
|
-
- **Sintassi HTML grezzo**:
|
|
444
|
-
Usa `<div v-html="myContent" />` per rendere il contenuto come HTML grezzo, senza supporto
|
|
281
|
+
- **Sintassi HTML grezzo**:
|
|
282
|
+
Usa `<div v-html="myContent" />` per rendere il contenuto come HTML grezzo, senza supporto per il Visual Editor.
|
|
445
283
|
|
|
446
|
-
- **Sintassi di destrutturazione**:
|
|
284
|
+
- **Sintassi di destrutturazione**:
|
|
447
285
|
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.
|
|
286
|
+
- Usa `const content = useIntlayer("myContent");` e `{{ content.myContent }}` / `<content.myContent />`.
|
|
287
|
+
- Oppure usa `const { myContent } = useIntlayer("myContent");` e `{{ myContent}}` / `<myContent/>` per destrutturare il contenuto.
|
|
450
288
|
|
|
451
289
|
### (Opzionale) Passo 6: Cambiare la lingua del tuo contenuto
|
|
452
290
|
|
|
453
|
-
Per cambiare la lingua del tuo contenuto, puoi usare la funzione `setLocale` fornita dal composable `useLocale`. Questa funzione ti permette di impostare la
|
|
291
|
+
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
292
|
|
|
455
|
-
Crea un componente per cambiare lingua:
|
|
293
|
+
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
294
|
|
|
457
295
|
```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
296
|
<script setup lang="ts">
|
|
469
|
-
import {
|
|
470
|
-
import { getLocaleName } from "intlayer";
|
|
297
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
471
298
|
import { useLocale } from "vue-intlayer";
|
|
472
299
|
|
|
473
|
-
//
|
|
300
|
+
// Nuxt importa automaticamente useRoute
|
|
301
|
+
const route = useRoute();
|
|
474
302
|
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
303
|
</script>
|
|
304
|
+
|
|
305
|
+
<template>
|
|
306
|
+
<nav class="locale-switcher">
|
|
307
|
+
<NuxtLink
|
|
308
|
+
v-for="localeEl in availableLocales"
|
|
309
|
+
:key="localeEl"
|
|
310
|
+
:to="getLocalizedUrl(route.fullPath, localeEl)"
|
|
311
|
+
class="locale-link"
|
|
312
|
+
:class="{ 'active-locale': localeEl === locale }"
|
|
313
|
+
@click="setLocale(localeEl)"
|
|
314
|
+
>
|
|
315
|
+
{{ getLocaleName(localeEl) }}
|
|
316
|
+
</NuxtLink>
|
|
317
|
+
</nav>
|
|
490
318
|
</template>
|
|
319
|
+
```
|
|
491
320
|
|
|
492
|
-
|
|
493
|
-
.locale-switcher {
|
|
494
|
-
margin: 1rem 0;
|
|
495
|
-
}
|
|
321
|
+
> 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
322
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
323
|
+
Quindi, configura il tuo `app.vue` per utilizzare i layout:
|
|
324
|
+
|
|
325
|
+
```vue fileName="app.vue"
|
|
326
|
+
<template>
|
|
327
|
+
<NuxtLayout>
|
|
328
|
+
<NuxtPage />
|
|
329
|
+
</NuxtLayout>
|
|
330
|
+
</template>
|
|
503
331
|
```
|
|
504
332
|
|
|
505
|
-
|
|
333
|
+
### (Opzionale) Passo 6b: Crea un Layout con Navigazione
|
|
506
334
|
|
|
507
|
-
|
|
335
|
+
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:
|
|
336
|
+
|
|
337
|
+
```vue fileName="layouts/default.vue"
|
|
508
338
|
<script setup lang="ts">
|
|
509
|
-
import
|
|
339
|
+
import Links from "~/components/Links.vue";
|
|
510
340
|
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
511
|
-
|
|
512
|
-
const content = useIntlayer("app"); // Crea il file di dichiarazione intlayer correlato
|
|
513
341
|
</script>
|
|
514
342
|
|
|
515
343
|
<template>
|
|
@@ -518,15 +346,20 @@ const content = useIntlayer("app"); // Crea il file di dichiarazione intlayer co
|
|
|
518
346
|
<LocaleSwitcher />
|
|
519
347
|
</header>
|
|
520
348
|
<main>
|
|
521
|
-
<
|
|
349
|
+
<slot />
|
|
522
350
|
</main>
|
|
351
|
+
|
|
352
|
+
<Links href="/">Home</Links>
|
|
353
|
+
<Links href="/about">About</Links>
|
|
523
354
|
</div>
|
|
524
355
|
</template>
|
|
525
356
|
```
|
|
526
357
|
|
|
527
|
-
|
|
358
|
+
Il componente `Links` (mostrato di seguito) garantisce che i link di navigazione interna siano automaticamente localizzati.
|
|
528
359
|
|
|
529
|
-
|
|
360
|
+
### (Opzionale) Passo 7: Aggiungi il Routing localizzato alla tua applicazione
|
|
361
|
+
|
|
362
|
+
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
363
|
|
|
531
364
|
Esempio:
|
|
532
365
|
|
|
@@ -538,217 +371,290 @@ pages/
|
|
|
538
371
|
└── index.vue → /contact, /fr/contact, /es/contact
|
|
539
372
|
```
|
|
540
373
|
|
|
541
|
-
Per creare
|
|
374
|
+
Per creare pagine localizzate, crea semplicemente i tuoi file Vue nella directory `pages/`. Ecco due esempi di pagine:
|
|
375
|
+
|
|
376
|
+
**Pagina Home (`pages/index.vue`):**
|
|
377
|
+
|
|
378
|
+
```vue fileName="pages/index.vue"
|
|
379
|
+
<script setup lang="ts">
|
|
380
|
+
import { useIntlayer } from "vue-intlayer";
|
|
381
|
+
|
|
382
|
+
const content = useIntlayer("home-page");
|
|
383
|
+
|
|
384
|
+
useHead({
|
|
385
|
+
title: content.metaTitle.value,
|
|
386
|
+
meta: [
|
|
387
|
+
{
|
|
388
|
+
name: "description",
|
|
389
|
+
content: content.metaDescription.value,
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
});
|
|
393
|
+
</script>
|
|
394
|
+
|
|
395
|
+
<template>
|
|
396
|
+
<h1><content.title /></h1>
|
|
397
|
+
</template>
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**Pagina About (`pages/about.vue`):**
|
|
542
401
|
|
|
543
402
|
```vue fileName="pages/about.vue"
|
|
544
403
|
<script setup lang="ts">
|
|
545
404
|
import { useIntlayer } from "vue-intlayer";
|
|
546
405
|
|
|
547
|
-
const content = useIntlayer("about");
|
|
406
|
+
const content = useIntlayer("about-page");
|
|
407
|
+
|
|
408
|
+
useHead({
|
|
409
|
+
title: content.metaTitle.raw, // Usa .raw per accedere alla stringa primitiva
|
|
410
|
+
meta: [
|
|
411
|
+
{
|
|
412
|
+
name: "description",
|
|
413
|
+
content: content.metaDescription.raw, // Usa .raw per accedere alla stringa primitiva
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
});
|
|
548
417
|
</script>
|
|
549
418
|
|
|
550
419
|
<template>
|
|
551
|
-
<
|
|
552
|
-
<h1>{{ content.title }}</h1>
|
|
553
|
-
<p>{{ content.description }}</p>
|
|
554
|
-
</div>
|
|
420
|
+
<h1><content.title /></h1>
|
|
555
421
|
</template>
|
|
556
422
|
```
|
|
557
423
|
|
|
558
|
-
|
|
424
|
+
> Nota: `useHead` è importato automaticamente in Nuxt. Puoi accedere ai valori del contenuto usando `.value` (reattivo) o `.raw` (stringa primitiva) a seconda delle tue esigenze.
|
|
425
|
+
|
|
426
|
+
Il modulo `nuxt-intlayer` farà automaticamente:
|
|
559
427
|
|
|
560
|
-
- Rilevare la
|
|
561
|
-
- Gestire il cambio di
|
|
428
|
+
- Rilevare la locale preferita dall'utente
|
|
429
|
+
- Gestire il cambio di locale tramite URL
|
|
562
430
|
- Impostare l'attributo `<html lang="">` appropriato
|
|
563
|
-
- Gestire i cookie della
|
|
431
|
+
- Gestire i cookie della locale
|
|
564
432
|
- Reindirizzare gli utenti all'URL localizzato corretto
|
|
565
433
|
|
|
566
434
|
### (Opzionale) Passo 8: Creare un componente Link localizzato
|
|
567
435
|
|
|
568
|
-
Per
|
|
569
|
-
|
|
570
|
-
```vue fileName="components/LocalizedLink.vue"
|
|
571
|
-
<template>
|
|
572
|
-
<NuxtLink :to="localizedHref" v-bind="$attrs">
|
|
573
|
-
<slot />
|
|
574
|
-
</NuxtLink>
|
|
575
|
-
</template>
|
|
436
|
+
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
437
|
|
|
438
|
+
```vue fileName="components/Links.vue"
|
|
577
439
|
<script setup lang="ts">
|
|
578
|
-
import { computed } from "vue";
|
|
579
440
|
import { getLocalizedUrl } from "intlayer";
|
|
441
|
+
// Importa il composable per la gestione della lingua corrente
|
|
580
442
|
import { useLocale } from "vue-intlayer";
|
|
581
443
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
444
|
+
interface Props {
|
|
445
|
+
href: string;
|
|
446
|
+
locale?: string;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const props = defineProps<Props>();
|
|
450
|
+
|
|
451
|
+
const { locale: currentLocale } = useLocale();
|
|
588
452
|
|
|
589
|
-
|
|
453
|
+
// Calcola il percorso finale
|
|
454
|
+
const finalPath = computed(() => {
|
|
455
|
+
// 1. Verifica se il link è esterno
|
|
456
|
+
const isExternal = /^https?:\/\//.test(props.href || "");
|
|
590
457
|
|
|
591
|
-
//
|
|
592
|
-
|
|
458
|
+
// 2. Se esterno, restituisci così com'è (NuxtLink gestisce la generazione del tag <a>)
|
|
459
|
+
if (isExternal) return props.href;
|
|
593
460
|
|
|
594
|
-
//
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
);
|
|
461
|
+
// 3. Se è interno, localizza l'URL
|
|
462
|
+
const targetLocale = props.locale || currentLocale.value;
|
|
463
|
+
return getLocalizedUrl(props.href, targetLocale);
|
|
464
|
+
});
|
|
598
465
|
</script>
|
|
466
|
+
|
|
467
|
+
<template>
|
|
468
|
+
<NuxtLink :to="finalPath" v-bind="$attrs">
|
|
469
|
+
<slot />
|
|
470
|
+
</NuxtLink>
|
|
471
|
+
</template>
|
|
599
472
|
```
|
|
600
473
|
|
|
601
474
|
Quindi usa questo componente in tutta la tua applicazione:
|
|
602
475
|
|
|
603
|
-
```vue fileName="
|
|
476
|
+
```vue fileName="layouts/default.vue"
|
|
477
|
+
<script setup lang="ts">
|
|
478
|
+
import Links from "~/components/Links.vue";
|
|
479
|
+
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
480
|
+
</script>
|
|
481
|
+
|
|
604
482
|
<template>
|
|
605
483
|
<div>
|
|
606
|
-
<
|
|
607
|
-
|
|
608
|
-
</
|
|
609
|
-
<
|
|
610
|
-
|
|
611
|
-
</
|
|
484
|
+
<header>
|
|
485
|
+
<LocaleSwitcher />
|
|
486
|
+
</header>
|
|
487
|
+
<main>
|
|
488
|
+
<slot />
|
|
489
|
+
</main>
|
|
490
|
+
|
|
491
|
+
<Links href="/">Home</Links>
|
|
492
|
+
<Links href="/about">About</Links>
|
|
612
493
|
</div>
|
|
613
494
|
</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
495
|
```
|
|
622
496
|
|
|
623
|
-
|
|
497
|
+
> Utilizzando `NuxtLink` con percorsi localizzati, si garantisce che:
|
|
498
|
+
>
|
|
499
|
+
> - I motori di ricerca possano eseguire la scansione e indicizzare tutte le versioni linguistiche delle tue pagine
|
|
500
|
+
> - Gli utenti possano condividere direttamente URL localizzati
|
|
501
|
+
> - La cronologia del browser funzioni correttamente con URL prefissati dalla locale
|
|
624
502
|
|
|
625
|
-
|
|
503
|
+
### (Opzionale) Passo 9: Gestire Metadata e SEO
|
|
504
|
+
|
|
505
|
+
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
506
|
|
|
627
507
|
```vue fileName="pages/about.vue"
|
|
628
508
|
<script setup lang="ts">
|
|
629
|
-
import {
|
|
630
|
-
import { getIntlayer } from "intlayer";
|
|
631
|
-
import { useLocale } from "vue-intlayer";
|
|
509
|
+
import { useIntlayer } from "vue-intlayer";
|
|
632
510
|
|
|
633
|
-
|
|
634
|
-
const content =
|
|
511
|
+
// useHead è auto-importato in Nuxt
|
|
512
|
+
const content = useIntlayer("about-page");
|
|
635
513
|
|
|
636
|
-
|
|
637
|
-
title: content.
|
|
638
|
-
|
|
514
|
+
useHead({
|
|
515
|
+
title: content.metaTitle.raw, // Usa .raw per accedere al valore stringa primitivo
|
|
516
|
+
meta: [
|
|
517
|
+
{
|
|
518
|
+
name: "description",
|
|
519
|
+
content: content.metaDescription.raw, // Usa .raw per accedere alla stringa primitiva
|
|
520
|
+
},
|
|
521
|
+
],
|
|
639
522
|
});
|
|
640
523
|
</script>
|
|
641
524
|
|
|
642
525
|
<template>
|
|
643
|
-
<
|
|
644
|
-
<h1>{{ content.pageTitle }}</h1>
|
|
645
|
-
<p>{{ content.pageContent }}</p>
|
|
646
|
-
</div>
|
|
526
|
+
<h1><content.title /></h1>
|
|
647
527
|
</template>
|
|
648
528
|
```
|
|
649
529
|
|
|
530
|
+
> In alternativa, puoi usare la funzione `import { getIntlayer } from "intlayer"` per ottenere il contenuto senza la reattività di Vue.
|
|
531
|
+
|
|
532
|
+
> **Accesso ai valori del contenuto:**
|
|
533
|
+
>
|
|
534
|
+
> - Usa `.raw` per ottenere il valore stringa primitivo (non reattivo)
|
|
535
|
+
> - Usa `.value` per ottenere il valore reattivo
|
|
536
|
+
> - Usa la sintassi componente `<content.key />` per il supporto all'Editor Visuale
|
|
537
|
+
|
|
650
538
|
Crea la dichiarazione di contenuto corrispondente:
|
|
651
539
|
|
|
652
|
-
```ts fileName="pages/about-
|
|
540
|
+
```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
|
|
653
541
|
import { t, type Dictionary } from "intlayer";
|
|
654
|
-
import type { useSeoMeta } from "nuxt/app";
|
|
655
542
|
|
|
656
|
-
const
|
|
657
|
-
key: "about-
|
|
543
|
+
const aboutPageContent = {
|
|
544
|
+
key: "about-page",
|
|
658
545
|
content: {
|
|
659
|
-
|
|
546
|
+
metaTitle: t({
|
|
660
547
|
en: "About Us - My Company",
|
|
661
548
|
fr: "À Propos - Ma Société",
|
|
662
549
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
663
|
-
it: "Chi Siamo - La Mia Azienda",
|
|
664
550
|
}),
|
|
665
|
-
|
|
551
|
+
metaDescription: t({
|
|
552
|
+
it: "Scopri di più sulla nostra azienda e sulla nostra missione",
|
|
666
553
|
en: "Learn more about our company and our mission",
|
|
667
554
|
fr: "En savoir plus sur notre société et notre mission",
|
|
668
555
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
669
|
-
|
|
556
|
+
}),
|
|
557
|
+
title: t({
|
|
558
|
+
it: "Chi Siamo",
|
|
559
|
+
en: "About Us",
|
|
560
|
+
fr: "À Propos",
|
|
561
|
+
es: "Acerca de Nosotros",
|
|
670
562
|
}),
|
|
671
563
|
},
|
|
672
|
-
} satisfies Dictionary
|
|
564
|
+
} satisfies Dictionary;
|
|
673
565
|
|
|
674
|
-
export default
|
|
566
|
+
export default aboutPageContent;
|
|
675
567
|
```
|
|
676
568
|
|
|
677
|
-
```
|
|
569
|
+
```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
|
|
678
570
|
import { t } from "intlayer";
|
|
679
571
|
|
|
680
572
|
/** @type {import('intlayer').Dictionary} */
|
|
681
|
-
const
|
|
682
|
-
key: "about-
|
|
573
|
+
const aboutPageContent = {
|
|
574
|
+
key: "about-page",
|
|
683
575
|
content: {
|
|
684
|
-
|
|
685
|
-
zh: "关于我们 - 我的公司",
|
|
576
|
+
metaTitle: t({
|
|
686
577
|
it: "Chi Siamo - La Mia Azienda",
|
|
687
578
|
en: "About Us - My Company",
|
|
688
579
|
fr: "À Propos - Ma Société",
|
|
689
580
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
690
581
|
}),
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
it: "Scopri di più sulla nostra azienda e sulla nostra missione",
|
|
694
|
-
en: "Learn more about our company and our mission",
|
|
582
|
+
metaDescription: t({
|
|
583
|
+
en: "Scopri di più sulla nostra azienda e sulla nostra missione",
|
|
695
584
|
fr: "En savoir plus sur notre société et notre mission",
|
|
696
585
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
697
586
|
}),
|
|
587
|
+
title: t({
|
|
588
|
+
en: "Chi Siamo",
|
|
589
|
+
fr: "À Propos",
|
|
590
|
+
es: "Acerca de Nosotros",
|
|
591
|
+
}),
|
|
698
592
|
},
|
|
699
593
|
};
|
|
700
594
|
|
|
701
|
-
export default
|
|
595
|
+
export default aboutPageContent;
|
|
702
596
|
```
|
|
703
597
|
|
|
704
|
-
```
|
|
598
|
+
```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
|
|
705
599
|
const { t } = require("intlayer");
|
|
706
600
|
|
|
707
601
|
/** @type {import('intlayer').Dictionary} */
|
|
708
|
-
const
|
|
709
|
-
key: "about-
|
|
602
|
+
const aboutPageContent = {
|
|
603
|
+
key: "about-page",
|
|
710
604
|
content: {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
it: "Chi Siamo - La Mia Azienda",
|
|
714
|
-
en: "About Us - My Company",
|
|
605
|
+
metaTitle: t({
|
|
606
|
+
en: "Chi Siamo - La Mia Azienda",
|
|
715
607
|
fr: "À Propos - Ma Société",
|
|
716
608
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
717
609
|
}),
|
|
718
|
-
|
|
719
|
-
zh: "了解更多关于我们公司和我们的使命",
|
|
610
|
+
metaDescription: t({
|
|
720
611
|
en: "Learn more about our company and our mission",
|
|
721
612
|
fr: "En savoir plus sur notre société et notre mission",
|
|
722
613
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
723
614
|
it: "Scopri di più sulla nostra azienda e sulla nostra missione",
|
|
724
615
|
}),
|
|
616
|
+
title: t({
|
|
617
|
+
en: "About Us",
|
|
618
|
+
fr: "À Propos",
|
|
619
|
+
es: "Acerca de Nosotros",
|
|
620
|
+
it: "Chi Siamo",
|
|
621
|
+
}),
|
|
725
622
|
},
|
|
726
623
|
};
|
|
727
624
|
|
|
728
|
-
module.exports =
|
|
625
|
+
module.exports = aboutPageContent;
|
|
729
626
|
```
|
|
730
627
|
|
|
731
|
-
```json fileName="pages/about-
|
|
628
|
+
```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
|
|
732
629
|
{
|
|
733
|
-
"
|
|
630
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
631
|
+
"key": "about-page",
|
|
734
632
|
"content": {
|
|
735
|
-
"
|
|
633
|
+
"metaTitle": {
|
|
736
634
|
"nodeType": "translation",
|
|
737
|
-
"
|
|
738
|
-
"zh": "关于我们 - 我的公司",
|
|
635
|
+
"translation": {
|
|
739
636
|
"en": "About Us - My Company",
|
|
740
637
|
"fr": "À Propos - Ma Société",
|
|
741
638
|
"es": "Acerca de Nosotros - Mi Empresa",
|
|
742
639
|
"it": "Chi Siamo - La Mia Azienda"
|
|
743
640
|
}
|
|
744
641
|
},
|
|
745
|
-
"
|
|
642
|
+
"metaDescription": {
|
|
746
643
|
"nodeType": "translation",
|
|
747
|
-
"
|
|
748
|
-
"zh": "了解更多关于我们公司和我们的使命",
|
|
644
|
+
"translation": {
|
|
749
645
|
"en": "Learn more about our company and our mission",
|
|
750
646
|
"fr": "En savoir plus sur notre société et notre mission",
|
|
751
|
-
"es": "Conozca más sobre nuestra empresa y nuestra misión"
|
|
647
|
+
"es": "Conozca más sobre nuestra empresa y nuestra misión",
|
|
648
|
+
"it": "Scopri di più sulla nostra azienda e sulla nostra missione"
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
"title": {
|
|
652
|
+
"nodeType": "translation",
|
|
653
|
+
"translation": {
|
|
654
|
+
"en": "About Us",
|
|
655
|
+
"fr": "À Propos",
|
|
656
|
+
"es": "Acerca de Nosotros",
|
|
657
|
+
"it": "Chi Siamo"
|
|
752
658
|
}
|
|
753
659
|
}
|
|
754
660
|
}
|
|
@@ -757,17 +663,17 @@ module.exports = aboutMetaContent;
|
|
|
757
663
|
|
|
758
664
|
### Configurare TypeScript
|
|
759
665
|
|
|
760
|
-
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere
|
|
666
|
+
Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere la tua codebase più robusta.
|
|
761
667
|
|
|
762
|
-

|
|
763
669
|
|
|
764
|
-

|
|
765
671
|
|
|
766
|
-
Assicurati che la tua configurazione
|
|
672
|
+
Assicurati che la tua configurazione TypeScript includa i tipi generati automaticamente.
|
|
767
673
|
|
|
768
674
|
```json5 fileName="tsconfig.json"
|
|
769
675
|
{
|
|
770
|
-
// ... Le tue configurazioni esistenti
|
|
676
|
+
// ... Le tue configurazioni TypeScript esistenti
|
|
771
677
|
"include": [
|
|
772
678
|
// ... Le tue configurazioni TypeScript esistenti
|
|
773
679
|
".intlayer/**/*.ts", // Includi i tipi generati automaticamente
|
|
@@ -779,7 +685,7 @@ Assicurati che la tua configurazione di TypeScript includa i tipi generati autom
|
|
|
779
685
|
|
|
780
686
|
Si consiglia di ignorare i file generati da Intlayer. Questo ti permette di evitare di committarli nel tuo repository Git.
|
|
781
687
|
|
|
782
|
-
Per
|
|
688
|
+
Per farlo, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
783
689
|
|
|
784
690
|
```plaintext fileName=".gitignore"
|
|
785
691
|
# Ignora i file generati da Intlayer
|
|
@@ -788,23 +694,21 @@ Per fare ciò, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
|
788
694
|
|
|
789
695
|
### Estensione VS Code
|
|
790
696
|
|
|
791
|
-
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare
|
|
697
|
+
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare la **Intlayer VS Code Extension** ufficiale.
|
|
792
698
|
|
|
793
699
|
[Installa dal VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
794
700
|
|
|
795
|
-
Questa estensione
|
|
701
|
+
Questa estensione offre:
|
|
796
702
|
|
|
797
|
-
- **
|
|
798
|
-
- **Rilevamento errori in tempo reale** per
|
|
703
|
+
- **Autocompletamento** per le chiavi di traduzione.
|
|
704
|
+
- **Rilevamento errori in tempo reale** per traduzioni mancanti.
|
|
799
705
|
- **Anteprime inline** del contenuto tradotto.
|
|
800
706
|
- **Azioni rapide** per creare e aggiornare facilmente le traduzioni.
|
|
801
707
|
|
|
802
|
-
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione
|
|
708
|
+
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione della Intlayer VS Code Extension](https://intlayer.org/doc/vs-code-extension).
|
|
803
709
|
|
|
804
710
|
---
|
|
805
711
|
|
|
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).
|
|
712
|
+
### Vai oltre
|
|
809
713
|
|
|
810
|
-
|
|
714
|
+
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).
|