@intlayer/docs 7.5.9 → 7.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- 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/cli/push.md +1 -1
- package/docs/ar/configuration.md +3 -3
- package/docs/ar/interest_of_intlayer.md +1 -1
- package/docs/ar/intlayer_CMS.md +5 -5
- package/docs/ar/intlayer_with_express.md +1 -0
- package/docs/ar/intlayer_with_fastify.md +516 -0
- package/docs/ar/readme.md +1 -1
- package/docs/de/cli/push.md +1 -1
- package/docs/de/configuration.md +3 -3
- package/docs/de/interest_of_intlayer.md +1 -1
- package/docs/de/intlayer_CMS.md +5 -5
- package/docs/de/intlayer_with_express.md +1 -0
- package/docs/de/intlayer_with_fastify.md +449 -0
- package/docs/de/readme.md +1 -1
- package/docs/en/cli/push.md +1 -1
- package/docs/en/configuration.md +3 -3
- package/docs/en/interest_of_intlayer.md +1 -1
- package/docs/en/intlayer_CMS.md +5 -5
- package/docs/en/intlayer_with_express.md +1 -0
- package/docs/en/intlayer_with_fastify.md +439 -0
- package/docs/en/readme.md +3 -1
- package/docs/en-GB/cli/push.md +1 -1
- package/docs/en-GB/configuration.md +3 -3
- package/docs/en-GB/interest_of_intlayer.md +1 -1
- package/docs/en-GB/intlayer_CMS.md +5 -5
- package/docs/en-GB/intlayer_with_express.md +1 -0
- package/docs/en-GB/intlayer_with_fastify.md +445 -0
- package/docs/en-GB/readme.md +3 -1
- package/docs/es/cli/push.md +1 -1
- package/docs/es/configuration.md +3 -3
- package/docs/es/interest_of_intlayer.md +1 -1
- package/docs/es/intlayer_CMS.md +5 -5
- package/docs/es/intlayer_with_express.md +1 -0
- package/docs/es/intlayer_with_fastify.md +480 -0
- package/docs/es/readme.md +1 -1
- package/docs/fr/cli/push.md +1 -1
- package/docs/fr/configuration.md +3 -3
- package/docs/fr/interest_of_intlayer.md +1 -1
- package/docs/fr/intlayer_CMS.md +5 -5
- package/docs/fr/intlayer_with_express.md +1 -0
- package/docs/fr/intlayer_with_fastify.md +439 -0
- package/docs/fr/readme.md +1 -1
- package/docs/hi/cli/push.md +1 -1
- package/docs/hi/configuration.md +3 -3
- package/docs/hi/interest_of_intlayer.md +1 -1
- package/docs/hi/intlayer_CMS.md +5 -5
- package/docs/hi/intlayer_with_express.md +1 -0
- package/docs/hi/intlayer_with_fastify.md +540 -0
- package/docs/hi/readme.md +1 -1
- package/docs/id/cli/push.md +1 -1
- package/docs/id/configuration.md +3 -3
- package/docs/id/interest_of_intlayer.md +1 -1
- package/docs/id/intlayer_CMS.md +5 -5
- package/docs/id/intlayer_with_express.md +1 -0
- package/docs/id/intlayer_with_fastify.md +470 -0
- package/docs/id/readme.md +1 -1
- package/docs/it/cli/push.md +1 -1
- package/docs/it/configuration.md +3 -3
- package/docs/it/interest_of_intlayer.md +1 -1
- package/docs/it/intlayer_CMS.md +5 -5
- package/docs/it/intlayer_with_express.md +1 -0
- package/docs/it/intlayer_with_fastify.md +445 -0
- package/docs/it/readme.md +1 -1
- package/docs/ja/cli/push.md +1 -1
- package/docs/ja/configuration.md +3 -3
- package/docs/ja/interest_of_intlayer.md +1 -1
- package/docs/ja/intlayer_CMS.md +5 -5
- package/docs/ja/intlayer_with_express.md +1 -0
- package/docs/ja/intlayer_with_fastify.md +516 -0
- package/docs/ja/readme.md +1 -1
- package/docs/ko/cli/push.md +1 -1
- package/docs/ko/configuration.md +3 -3
- package/docs/ko/interest_of_intlayer.md +1 -1
- package/docs/ko/intlayer_CMS.md +5 -5
- package/docs/ko/intlayer_with_express.md +1 -0
- package/docs/ko/intlayer_with_fastify.md +463 -0
- package/docs/ko/readme.md +1 -1
- package/docs/pl/cli/push.md +1 -1
- package/docs/pl/configuration.md +3 -3
- package/docs/pl/interest_of_intlayer.md +1 -1
- package/docs/pl/intlayer_CMS.md +5 -5
- package/docs/pl/intlayer_with_express.md +1 -0
- package/docs/pl/intlayer_with_fastify.md +457 -0
- package/docs/pl/readme.md +1 -1
- package/docs/pt/cli/push.md +1 -1
- package/docs/pt/configuration.md +3 -3
- package/docs/pt/interest_of_intlayer.md +1 -1
- package/docs/pt/intlayer_CMS.md +5 -5
- package/docs/pt/intlayer_with_express.md +1 -0
- package/docs/pt/intlayer_with_fastify.md +502 -0
- package/docs/pt/readme.md +1 -1
- package/docs/ru/cli/push.md +1 -1
- package/docs/ru/configuration.md +3 -3
- package/docs/ru/interest_of_intlayer.md +1 -1
- package/docs/ru/intlayer_CMS.md +5 -5
- package/docs/ru/intlayer_with_express.md +1 -0
- package/docs/ru/intlayer_with_fastify.md +468 -0
- package/docs/ru/readme.md +1 -1
- package/docs/tr/cli/push.md +1 -1
- package/docs/tr/configuration.md +3 -3
- package/docs/tr/interest_of_intlayer.md +1 -1
- package/docs/tr/intlayer_CMS.md +5 -5
- package/docs/tr/intlayer_with_express.md +1 -0
- package/docs/tr/intlayer_with_fastify.md +471 -0
- package/docs/tr/readme.md +1 -1
- package/docs/vi/cli/push.md +1 -1
- package/docs/vi/configuration.md +3 -3
- package/docs/vi/interest_of_intlayer.md +1 -1
- package/docs/vi/intlayer_CMS.md +5 -5
- package/docs/vi/intlayer_with_express.md +1 -0
- package/docs/vi/intlayer_with_fastify.md +490 -0
- package/docs/vi/readme.md +1 -1
- package/docs/zh/cli/push.md +1 -1
- package/docs/zh/configuration.md +3 -3
- package/docs/zh/interest_of_intlayer.md +1 -1
- package/docs/zh/intlayer_CMS.md +5 -5
- package/docs/zh/intlayer_with_express.md +1 -0
- package/docs/zh/intlayer_with_fastify.md +451 -0
- package/docs/zh/readme.md +1 -1
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +19 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-12-30
|
|
3
|
+
updatedAt: 2025-12-30
|
|
4
|
+
title: Come tradurre il tuo backend Fastify – Guida i18n 2026
|
|
5
|
+
description: Scopri come rendere il tuo backend Fastify multilingue. Segui la documentazione per internazionalizzare (i18n) e tradurlo.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internazionalizzazione
|
|
8
|
+
- Documentazione
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Fastify
|
|
11
|
+
- JavaScript
|
|
12
|
+
- Backend
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- environment
|
|
16
|
+
- fastify
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-fastify-template
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.6.0
|
|
20
|
+
date: 2025-12-31
|
|
21
|
+
changes: Add init command
|
|
22
|
+
- version: 7.6.0
|
|
23
|
+
date: 2025-12-31
|
|
24
|
+
changes: Init history
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Traduci il tuo backend Fastify utilizzando Intlayer | Internazionalizzazione (i18n)
|
|
28
|
+
|
|
29
|
+
`fastify-intlayer` è un plugin di internazionalizzazione (i18n) potente per le applicazioni Fastify, progettato per rendere i tuoi servizi backend accessibili a livello globale fornendo risposte localizzate in base alle preferenze del client.
|
|
30
|
+
|
|
31
|
+
### Casi d'uso pratici
|
|
32
|
+
|
|
33
|
+
- **Mostrare gli errori del backend nella lingua dell'utente**: Quando si verifica un errore, mostrare i messaggi nella lingua nativa dell'utente migliora la comprensione e riduce la frustrazione. Questo è particolarmente utile per i messaggi di errore dinamici che potrebbero essere mostrati in componenti front-end come toast o modal.
|
|
34
|
+
- **Recuperare contenuti multilingue**: Per applicazioni che estraggono contenuti da un database, l'internazionalizzazione garantisce la possibilità di servire tali contenuti in più lingue. Questo è fondamentale per piattaforme come siti di e-commerce o sistemi di gestione dei contenuti che devono mostrare descrizioni di prodotti, articoli e altri contenuti nella lingua preferita dall'utente.
|
|
35
|
+
- **Invio di email multilingue**: Sia che si tratti di email transazionali, campagne di marketing o notifiche, inviare le email nella lingua del destinatario può aumentare significativamente il coinvolgimento e l'efficacia.
|
|
36
|
+
- **Notifiche push multilingue**: Per le applicazioni mobili, inviare notifiche push nella lingua preferita dall'utente può migliorare l'interazione e la retention. Questo tocco personale può rendere le notifiche più rilevanti e facilmente azionabili.
|
|
37
|
+
- **Altre comunicazioni**: Qualsiasi forma di comunicazione dal backend, come SMS, avvisi di sistema o aggiornamenti dell'interfaccia utente, trae vantaggio dall'essere nella lingua dell'utente, garantendo chiarezza e migliorando l'esperienza utente complessiva.
|
|
38
|
+
|
|
39
|
+
Internationalizzando il backend, la tua applicazione non solo rispetta le differenze culturali ma si allinea anche meglio alle esigenze dei mercati globali, diventando così un passaggio chiave per scalare i tuoi servizi a livello mondiale.
|
|
40
|
+
|
|
41
|
+
## Per iniziare
|
|
42
|
+
|
|
43
|
+
### Installazione
|
|
44
|
+
|
|
45
|
+
Per iniziare a utilizzare `fastify-intlayer`, installa il pacchetto usando npm:
|
|
46
|
+
|
|
47
|
+
```bash packageManager="npm"
|
|
48
|
+
npm install intlayer fastify-intlayer
|
|
49
|
+
npx intlayer init
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```bash packageManager="pnpm"
|
|
54
|
+
pnpm add intlayer fastify-intlayer
|
|
55
|
+
pnpm intlayer init
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```bash packageManager="yarn"
|
|
60
|
+
yarn add intlayer fastify-intlayer
|
|
61
|
+
yarn intlayer init
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```bash packageManager="bun"
|
|
66
|
+
bun add intlayer fastify-intlayer
|
|
67
|
+
bunx intlayer init
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Configurazione
|
|
72
|
+
|
|
73
|
+
Configura le impostazioni di internazionalizzazione creando un file `intlayer.config.ts` nella root del tuo progetto:
|
|
74
|
+
|
|
75
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
76
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
77
|
+
|
|
78
|
+
const config: IntlayerConfig = {
|
|
79
|
+
internationalization: {
|
|
80
|
+
locales: [
|
|
81
|
+
Locales.ENGLISH,
|
|
82
|
+
Locales.FRENCH,
|
|
83
|
+
Locales.SPANISH_MEXICO,
|
|
84
|
+
Locales.SPANISH_SPAIN,
|
|
85
|
+
],
|
|
86
|
+
defaultLocale: Locales.ENGLISH,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default config;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
94
|
+
import { Locales } from "intlayer";
|
|
95
|
+
|
|
96
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
97
|
+
const config = {
|
|
98
|
+
internationalization: {
|
|
99
|
+
locales: [
|
|
100
|
+
Locales.ENGLISH,
|
|
101
|
+
Locales.FRENCH,
|
|
102
|
+
Locales.SPANISH_MEXICO,
|
|
103
|
+
Locales.SPANISH_SPAIN,
|
|
104
|
+
],
|
|
105
|
+
defaultLocale: Locales.ENGLISH,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default config;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
113
|
+
const { Locales } = require("intlayer");
|
|
114
|
+
|
|
115
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
116
|
+
const config = {
|
|
117
|
+
internationalization: {
|
|
118
|
+
locales: [
|
|
119
|
+
Locales.ENGLISH,
|
|
120
|
+
Locales.FRENCH,
|
|
121
|
+
Locales.SPANISH_MEXICO,
|
|
122
|
+
Locales.SPANISH_SPAIN,
|
|
123
|
+
],
|
|
124
|
+
defaultLocale: Locales.ENGLISH,
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
module.exports = config;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Dichiarare il contenuto
|
|
132
|
+
|
|
133
|
+
Crea e gestisci le dichiarazioni di contenuto per memorizzare le traduzioni:
|
|
134
|
+
|
|
135
|
+
```typescript fileName="src/index.content.ts" contentDeclarationFormat="typescript"
|
|
136
|
+
import { t, type Dictionary } from "intlayer";
|
|
137
|
+
|
|
138
|
+
const indexContent = {
|
|
139
|
+
key: "index",
|
|
140
|
+
content: {
|
|
141
|
+
exampleOfContent: t({
|
|
142
|
+
it: "Esempio di contenuto restituito in italiano",
|
|
143
|
+
en: "Example of returned content in English",
|
|
144
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
145
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
146
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
} satisfies Dictionary;
|
|
150
|
+
|
|
151
|
+
export default indexContent;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```javascript fileName="src/index.content.mjs" contentDeclarationFormat="esm"
|
|
155
|
+
import { t } from "intlayer";
|
|
156
|
+
|
|
157
|
+
/** @type {import('intlayer').Dictionary} */
|
|
158
|
+
const indexContent = {
|
|
159
|
+
key: "index",
|
|
160
|
+
content: {
|
|
161
|
+
exampleOfContent: t({
|
|
162
|
+
it: "Esempio di contenuto restituito in italiano",
|
|
163
|
+
en: "Example of returned content in English",
|
|
164
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
165
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
166
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
167
|
+
}),
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export default indexContent;
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```javascript fileName="src/index.content.cjs" contentDeclarationFormat="commonjs"
|
|
175
|
+
const { t } = require("intlayer");
|
|
176
|
+
|
|
177
|
+
/** @type {import('intlayer').Dictionary} */
|
|
178
|
+
const indexContent = {
|
|
179
|
+
key: "index",
|
|
180
|
+
content: {
|
|
181
|
+
exampleOfContent: t({
|
|
182
|
+
it: "Esempio di contenuto restituito in italiano",
|
|
183
|
+
en: "Example of returned content in English",
|
|
184
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
185
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
186
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
187
|
+
}),
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
module.exports = indexContent;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
```json fileName="src/index.content.json" contentDeclarationFormat="json"
|
|
195
|
+
{
|
|
196
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
197
|
+
"key": "index",
|
|
198
|
+
"content": {
|
|
199
|
+
"exampleOfContent": {
|
|
200
|
+
"nodeType": "translation",
|
|
201
|
+
"translation": {
|
|
202
|
+
"it": "Esempio di contenuto restituito in italiano",
|
|
203
|
+
"en": "Example of returned content in English",
|
|
204
|
+
"fr": "Exemple de contenu renvoyé en français",
|
|
205
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
206
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
> Le tue dichiarazioni di contenuto possono essere definite ovunque nella tua applicazione purché siano incluse nella directory `contentDir` (per impostazione predefinita, `./src`). E corrispondano all'estensione dei file di dichiarazione del contenuto (per impostazione predefinita, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
214
|
+
|
|
215
|
+
> Per maggiori dettagli, consulta la [documentazione sulle dichiarazioni di contenuto](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/content_file.md).
|
|
216
|
+
|
|
217
|
+
### Impostazione dell'applicazione Fastify
|
|
218
|
+
|
|
219
|
+
Configura la tua applicazione Fastify per usare `fastify-intlayer`:
|
|
220
|
+
|
|
221
|
+
```typescript fileName="src/index.ts" codeFormat="typescript"
|
|
222
|
+
import Fastify from "fastify";
|
|
223
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
224
|
+
import dictionaryExample from "./index.content";
|
|
225
|
+
|
|
226
|
+
const fastify = Fastify({ logger: true });
|
|
227
|
+
|
|
228
|
+
// Carica il plugin di internazionalizzazione
|
|
229
|
+
await fastify.register(intlayer);
|
|
230
|
+
|
|
231
|
+
// Rotte
|
|
232
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
233
|
+
return t({
|
|
234
|
+
it: "Esempio di contenuto restituito in italiano",
|
|
235
|
+
en: "Example of returned content in English",
|
|
236
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
237
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
238
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
243
|
+
return getIntlayer("index").exampleOfContent;
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
247
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Avvia il server
|
|
251
|
+
const start = async () => {
|
|
252
|
+
try {
|
|
253
|
+
await fastify.listen({ port: 3000 });
|
|
254
|
+
} catch (err) {
|
|
255
|
+
fastify.log.error(err);
|
|
256
|
+
process.exit(1);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
start();
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
```javascript fileName="src/index.mjs" codeFormat="esm"
|
|
264
|
+
import Fastify from "fastify";
|
|
265
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
266
|
+
import dictionaryExample from "./index.content";
|
|
267
|
+
|
|
268
|
+
const fastify = Fastify({ logger: true });
|
|
269
|
+
|
|
270
|
+
// Carica il plugin di internazionalizzazione
|
|
271
|
+
await fastify.register(intlayer);
|
|
272
|
+
|
|
273
|
+
// Rotte
|
|
274
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
275
|
+
return t({
|
|
276
|
+
it: "Esempio di contenuto restituito in italiano",
|
|
277
|
+
en: "Example of returned content in English",
|
|
278
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
279
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
280
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
285
|
+
return getIntlayer("index").exampleOfContent;
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
289
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// Avvia il server
|
|
293
|
+
const start = async () => {
|
|
294
|
+
try {
|
|
295
|
+
await fastify.listen({ port: 3000 });
|
|
296
|
+
} catch (err) {
|
|
297
|
+
fastify.log.error(err);
|
|
298
|
+
process.exit(1);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
start();
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
```javascript fileName="src/index.cjs" codeFormat="commonjs"
|
|
306
|
+
const Fastify = require("fastify");
|
|
307
|
+
const { intlayer, t, getDictionary, getIntlayer } = require("fastify-intlayer");
|
|
308
|
+
const dictionaryExample = require("./index.content");
|
|
309
|
+
|
|
310
|
+
const fastify = Fastify({ logger: true });
|
|
311
|
+
|
|
312
|
+
// Wrapper per l'avvio del server con async/await
|
|
313
|
+
const start = async () => {
|
|
314
|
+
try {
|
|
315
|
+
// Carica il plugin di internazionalizzazione
|
|
316
|
+
await fastify.register(intlayer);
|
|
317
|
+
|
|
318
|
+
// Rotte
|
|
319
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
320
|
+
return t({
|
|
321
|
+
it: "Esempio di contenuto restituito in italiano",
|
|
322
|
+
en: "Example of returned content in English",
|
|
323
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
324
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
325
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
330
|
+
return getIntlayer("index").exampleOfContent;
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
334
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
await fastify.listen({ port: 3000 });
|
|
338
|
+
} catch (err) {
|
|
339
|
+
fastify.log.error(err);
|
|
340
|
+
process.exit(1);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
start();
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Compatibilità
|
|
348
|
+
|
|
349
|
+
`fastify-intlayer` è completamente compatibile con:
|
|
350
|
+
|
|
351
|
+
- [`react-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/react-intlayer/index.md) per applicazioni React
|
|
352
|
+
- [`next-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/next-intlayer/index.md) per applicazioni Next.js
|
|
353
|
+
- [`vite-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/packages/vite-intlayer/index.md) per applicazioni Vite
|
|
354
|
+
|
|
355
|
+
Funziona anche perfettamente con qualsiasi soluzione di internazionalizzazione in diversi ambienti, inclusi browser e richieste API. Puoi personalizzare il middleware per rilevare la locale tramite header o cookie:
|
|
356
|
+
|
|
357
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
358
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
359
|
+
|
|
360
|
+
const config: IntlayerConfig = {
|
|
361
|
+
// ... Altre opzioni di configurazione
|
|
362
|
+
middleware: {
|
|
363
|
+
headerName: "my-locale-header",
|
|
364
|
+
cookieName: "my-locale-cookie",
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export default config;
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
372
|
+
import { Locales } from "intlayer";
|
|
373
|
+
|
|
374
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
375
|
+
const config = {
|
|
376
|
+
// ... Altre opzioni di configurazione
|
|
377
|
+
middleware: {
|
|
378
|
+
headerName: "my-locale-header",
|
|
379
|
+
cookieName: "my-locale-cookie",
|
|
380
|
+
},
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export default config;
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
387
|
+
const { Locales } = require("intlayer");
|
|
388
|
+
|
|
389
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
390
|
+
const config = {
|
|
391
|
+
// ... Altre opzioni di configurazione
|
|
392
|
+
middleware: {
|
|
393
|
+
headerName: "my-locale-header",
|
|
394
|
+
cookieName: "my-locale-cookie",
|
|
395
|
+
},
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
module.exports = config;
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Per impostazione predefinita, `fastify-intlayer` interpreterà l'intestazione `Accept-Language` per determinare la lingua preferita del client.
|
|
402
|
+
|
|
403
|
+
> Per ulteriori informazioni sulla configurazione e argomenti avanzati, visita la nostra [documentazione](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/configuration.md).
|
|
404
|
+
|
|
405
|
+
### Configurare TypeScript
|
|
406
|
+
|
|
407
|
+
`fastify-intlayer` sfrutta le robuste capacità di TypeScript per migliorare il processo di internazionalizzazione. Il typing statico di TypeScript garantisce che ogni chiave di traduzione sia conteggiata, riducendo il rischio di traduzioni mancanti e migliorando la manutenibilità.
|
|
408
|
+
|
|
409
|
+
Assicurati che i tipi autogenerati (per impostazione predefinita in ./types/intlayer.d.ts) siano inclusi nel tuo file tsconfig.json.
|
|
410
|
+
|
|
411
|
+
```json5 fileName="tsconfig.json"
|
|
412
|
+
{
|
|
413
|
+
// ... Le tue configurazioni TypeScript esistenti
|
|
414
|
+
"include": [
|
|
415
|
+
// ... Le tue configurazioni TypeScript esistenti
|
|
416
|
+
".intlayer/**/*.ts", // Includi i tipi auto-generati
|
|
417
|
+
],
|
|
418
|
+
}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### Estensione per VS Code
|
|
422
|
+
|
|
423
|
+
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare l'**Estensione Intlayer per VS Code** ufficiale.
|
|
424
|
+
|
|
425
|
+
[Installa dal VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
426
|
+
|
|
427
|
+
Questa estensione offre:
|
|
428
|
+
|
|
429
|
+
- **Completamento automatico** per le chiavi di traduzione.
|
|
430
|
+
- **Rilevamento degli errori in tempo reale** per traduzioni mancanti.
|
|
431
|
+
- **Anteprime inline** dei contenuti tradotti.
|
|
432
|
+
- **Azioni rapide** per creare e aggiornare facilmente le traduzioni.
|
|
433
|
+
|
|
434
|
+
Per maggiori dettagli su come usare l'estensione, consulta la [documentazione dell'Estensione Intlayer per VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
435
|
+
|
|
436
|
+
### Configurazione Git
|
|
437
|
+
|
|
438
|
+
È consigliabile ignorare i file generati da Intlayer. Questo ti permette di evitare di commetterli nel tuo repository Git.
|
|
439
|
+
|
|
440
|
+
Per farlo, puoi aggiungere le seguenti istruzioni al file `.gitignore`:
|
|
441
|
+
|
|
442
|
+
```plaintext fileName=".gitignore"
|
|
443
|
+
# Ignora i file generati da Intlayer
|
|
444
|
+
.intlayer
|
|
445
|
+
```
|
package/docs/it/readme.md
CHANGED
|
@@ -50,7 +50,7 @@ Con **file di contenuto per ogni locale**, **autocompletamento TypeScript**, **d
|
|
|
50
50
|
| Caratteristica | Descrizione |
|
|
51
51
|
| --------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
52
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Supporto Cross-Framework**<br><br>Intlayer è compatibile con tutti i principali framework e librerie, inclusi Next.js, React, Vite, Vue.js, Nuxt, Preact, Express e altri ancora. |
|
|
53
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.
|
|
53
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **Gestione dei Contenuti con JavaScript**<br><br>Sfrutta la flessibilità di JavaScript per definire e gestire i tuoi contenuti in modo efficiente. <br><br> - [Dichiarazione dei contenuti](https://intlayer.org/doc/concept/content) |
|
|
54
54
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **File di Dichiarazione dei Contenuti per Locale**<br><br>Accelera il tuo sviluppo dichiarando i contenuti una sola volta, prima della generazione automatica.<br><br> - [File di Dichiarazione dei Contenuti per Locale](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
55
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Ambiente Type-Safe**<br><br>Sfrutta TypeScript per garantire che le definizioni dei tuoi contenuti e il codice siano privi di errori, beneficiando anche dell'autocompletamento nell'IDE.<br><br> - [Configurazione di TypeScript](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
56
56
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Configurazione Semplificata**<br><br>Avvia rapidamente con una configurazione minima. Regola facilmente le impostazioni per l'internazionalizzazione, il routing, l'IA, la build e la gestione dei contenuti.<br><br> - [Esplora l'integrazione con Next.js](https://intlayer.org/doc/environment/nextjs) |
|
package/docs/ja/cli/push.md
CHANGED
|
@@ -23,7 +23,7 @@ slugs:
|
|
|
23
23
|
npx intlayer dictionary push
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
[intlayer editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_visual_editor.md)がインストールされている場合、辞書をエディターにプッシュすることもできます。このコマンドにより、辞書を[エディター](https://intlayer.org/
|
|
26
|
+
[intlayer editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_visual_editor.md)がインストールされている場合、辞書をエディターにプッシュすることもできます。このコマンドにより、辞書を[エディター](https://app.intlayer.org/)で利用可能にします。これにより、チームと辞書を共有し、アプリケーションのコードを編集せずにコンテンツを編集できます。
|
|
27
27
|
|
|
28
28
|
## エイリアス:
|
|
29
29
|
|
package/docs/ja/configuration.md
CHANGED
|
@@ -245,14 +245,14 @@ module.exports = config;
|
|
|
245
245
|
- **clientId**:
|
|
246
246
|
- _タイプ_: `string` | `undefined`
|
|
247
247
|
- _デフォルト_: `undefined`
|
|
248
|
-
- _説明_: clientId と clientSecret は、intlayer パッケージが oAuth2 認証を使用してバックエンドと認証するために使用されます。アクセストークンは、プロジェクトに関連するユーザーを認証するために使用されます。アクセストークンを取得するには、https://intlayer.org/
|
|
248
|
+
- _説明_: clientId と clientSecret は、intlayer パッケージが oAuth2 認証を使用してバックエンドと認証するために使用されます。アクセストークンは、プロジェクトに関連するユーザーを認証するために使用されます。アクセストークンを取得するには、https://app.intlayer.org/project にアクセスしてアカウントを作成してください。
|
|
249
249
|
- _例_: `true`
|
|
250
250
|
- _注意_: 重要: clientId と clientSecret は秘密にしておく必要があり、公開しないでください。環境変数などの安全な場所に保管することをお勧めします。
|
|
251
251
|
|
|
252
252
|
- **clientSecret**:
|
|
253
253
|
- _タイプ_: `string` | `undefined`
|
|
254
254
|
- _デフォルト_: `undefined`
|
|
255
|
-
- _説明_: clientId と clientSecret は、intlayer パッケージが oAuth2 認証を使用してバックエンドと認証するために使用されます。アクセストークンは、プロジェクトに関連するユーザーを認証するために使用されます。アクセストークンを取得するには、https://intlayer.org/
|
|
255
|
+
- _説明_: clientId と clientSecret は、intlayer パッケージが oAuth2 認証を使用してバックエンドと認証するために使用されます。アクセストークンは、プロジェクトに関連するユーザーを認証するために使用されます。アクセストークンを取得するには、https://app.intlayer.org/project にアクセスしてアカウントを作成してください。
|
|
256
256
|
- _例_: `true`
|
|
257
257
|
- _注意_: 重要: clientId と clientSecret は秘密にしておく必要があり、公開しないでください。環境変数などの安全な場所に保管することを推奨します。
|
|
258
258
|
|
|
@@ -466,7 +466,7 @@ module.exports = config;
|
|
|
466
466
|
|
|
467
467
|
IntlayerのAI機能を制御する設定で、プロバイダー、モデル、APIキーを含みます。
|
|
468
468
|
|
|
469
|
-
この設定は、アクセスキーを使用して[Intlayerダッシュボード](https://intlayer.org/
|
|
469
|
+
この設定は、アクセスキーを使用して[Intlayerダッシュボード](https://app.intlayer.org/project)に登録している場合はオプションです。Intlayerは、最も効率的でコスト効果の高いAIソリューションを自動的に管理します。デフォルトのオプションを使用することで、Intlayerが継続的に最適なモデルを使用するように更新されるため、長期的な保守性が向上します。
|
|
470
470
|
|
|
471
471
|
独自のAPIキーや特定のモデルを使用したい場合は、カスタムAI構成を定義できます。
|
|
472
472
|
このAI構成は、Intlayer環境全体でグローバルに使用されます。CLIコマンドはこれらの設定をコマンド(例:`fill`)のデフォルトとして使用し、SDK、ビジュアルエディター、CMSでも同様です。特定のユースケースに対しては、コマンドパラメータを使ってこれらのデフォルト値を上書きすることができます。
|
|
@@ -225,7 +225,7 @@ const ComponentExample = () => {
|
|
|
225
225
|
| 機能 | 説明 |
|
|
226
226
|
| ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
227
227
|
|  | **クロスフレームワーク対応**<br><br>Intlayerは、Next.js、React、Vite、Vue.js、Nuxt、Preact、Expressなど、主要なフレームワークやライブラリすべてに対応しています。 |
|
|
228
|
-
|  | **JavaScriptによるコンテンツ管理**<br><br>JavaScriptの柔軟性を活用して、コンテンツを効率的に定義・管理します。<br><br> - [コンテンツ宣言](https://intlayer.org/doc/concept/content) |
|
|
229
229
|
|  | **ロケール別コンテンツ宣言ファイル**<br><br>自動生成の前に一度だけコンテンツを宣言することで、開発をスピードアップします。<br><br> - [ロケール別コンテンツ宣言ファイル](https://intlayer.org/doc/concept/per-locale-file) |
|
|
230
230
|
|  | **型安全な環境**<br><br>TypeScriptを活用して、コンテンツ定義やコードのエラーを防ぎ、IDEのオートコンプリート機能も利用できます。<br><br> - [TypeScriptの設定](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
231
231
|
|  | **簡素化されたセットアップ**<br><br>最小限の設定で迅速に開始できます。国際化、ルーティング、AI、ビルド、コンテンツ処理の設定を簡単に調整可能です。<br><br> - [Next.js統合を探る](https://intlayer.org/doc/environment/nextjs) |
|
package/docs/ja/intlayer_CMS.md
CHANGED
|
@@ -92,7 +92,7 @@ const config: IntlayerConfig = {
|
|
|
92
92
|
*
|
|
93
93
|
* エディターを有効にするためにクライアントIDとクライアントシークレットが必要です。
|
|
94
94
|
* これらはコンテンツを編集しているユーザーを識別するために使用されます。
|
|
95
|
-
* Intlayerダッシュボードのプロジェクト(https://intlayer.org/
|
|
95
|
+
* Intlayerダッシュボードのプロジェクト(https://app.intlayer.org/projects)で新しいクライアントを作成することで取得できます。
|
|
96
96
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
97
97
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
98
98
|
*/
|
|
@@ -142,7 +142,7 @@ const config = {
|
|
|
142
142
|
*
|
|
143
143
|
* エディタを有効にするには、クライアントIDとクライアントシークレットが必要です。
|
|
144
144
|
* これらはコンテンツを編集しているユーザーを識別するために使用されます。
|
|
145
|
-
* Intlayerダッシュボードのプロジェクト(https://intlayer.org/
|
|
145
|
+
* Intlayerダッシュボードのプロジェクト(https://app.intlayer.org/projects)で新しいクライアントを作成することで取得できます。
|
|
146
146
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
147
147
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
148
148
|
*/
|
|
@@ -192,7 +192,7 @@ const config = {
|
|
|
192
192
|
*
|
|
193
193
|
* エディターを有効にするには、クライアントIDとクライアントシークレットが必要です。
|
|
194
194
|
* これらはコンテンツを編集しているユーザーを識別するために使用されます。
|
|
195
|
-
* Intlayerダッシュボードのプロジェクトページ(https://intlayer.org/
|
|
195
|
+
* Intlayerダッシュボードのプロジェクトページ(https://app.intlayer.org/projects)で新しいクライアントを作成することで取得できます。
|
|
196
196
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
197
197
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
198
198
|
*/
|
|
@@ -224,7 +224,7 @@ const config = {
|
|
|
224
224
|
module.exports = config;
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
> クライアントIDとクライアントシークレットをお持ちでない場合は、[Intlayerダッシュボード - プロジェクト](https://intlayer.org/
|
|
227
|
+
> クライアントIDとクライアントシークレットをお持ちでない場合は、[Intlayerダッシュボード - プロジェクト](https://app.intlayer.org/projects)で新しいクライアントを作成して取得できます。
|
|
228
228
|
|
|
229
229
|
> 利用可能なすべてのパラメータについては、[設定ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/configuration.md)を参照してください。
|
|
230
230
|
|
|
@@ -264,7 +264,7 @@ npx intlayer dictionary push -d my-first-dictionary-key --env production
|
|
|
264
264
|
|
|
265
265
|
### 辞書の編集
|
|
266
266
|
|
|
267
|
-
その後、[Intlayer CMS](https://intlayer.org/
|
|
267
|
+
その後、[Intlayer CMS](https://app.intlayer.org/content) で辞書を確認および管理できるようになります。
|
|
268
268
|
|
|
269
269
|
## ライブ同期
|
|
270
270
|
|