@intlayer/docs 7.0.3 → 7.0.4

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.
Files changed (159) hide show
  1. package/blog/ar/intlayer_with_i18next.md +68 -106
  2. package/blog/ar/intlayer_with_next-i18next.md +84 -288
  3. package/blog/ar/intlayer_with_next-intl.md +58 -337
  4. package/blog/ar/intlayer_with_react-i18next.md +68 -290
  5. package/blog/ar/intlayer_with_react-intl.md +63 -266
  6. package/blog/de/intlayer_with_i18next.md +77 -97
  7. package/blog/de/intlayer_with_next-i18next.md +69 -296
  8. package/blog/de/intlayer_with_next-intl.md +59 -340
  9. package/blog/de/intlayer_with_react-i18next.md +68 -290
  10. package/blog/de/intlayer_with_react-intl.md +62 -264
  11. package/blog/en/intlayer_with_i18next.md +67 -103
  12. package/blog/en/intlayer_with_next-i18next.md +69 -294
  13. package/blog/en/intlayer_with_next-intl.md +48 -300
  14. package/blog/en/intlayer_with_react-i18next.md +61 -289
  15. package/blog/en/intlayer_with_react-intl.md +61 -284
  16. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +1 -1
  17. package/blog/en-GB/intlayer_with_i18next.md +67 -103
  18. package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
  19. package/blog/en-GB/intlayer_with_next-intl.md +58 -337
  20. package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
  21. package/blog/en-GB/intlayer_with_react-intl.md +61 -264
  22. package/blog/es/intlayer_with_i18next.md +67 -103
  23. package/blog/es/intlayer_with_next-i18next.md +71 -296
  24. package/blog/es/intlayer_with_next-intl.md +57 -338
  25. package/blog/es/intlayer_with_react-i18next.md +68 -290
  26. package/blog/es/intlayer_with_react-intl.md +62 -265
  27. package/blog/fr/intlayer_with_i18next.md +66 -104
  28. package/blog/fr/intlayer_with_next-i18next.md +82 -285
  29. package/blog/fr/intlayer_with_next-intl.md +57 -338
  30. package/blog/fr/intlayer_with_react-i18next.md +67 -289
  31. package/blog/fr/intlayer_with_react-intl.md +61 -264
  32. package/blog/hi/intlayer_with_i18next.md +68 -104
  33. package/blog/hi/intlayer_with_next-i18next.md +74 -299
  34. package/blog/hi/intlayer_with_next-intl.md +57 -239
  35. package/blog/hi/intlayer_with_react-i18next.md +69 -291
  36. package/blog/hi/intlayer_with_react-intl.md +65 -268
  37. package/blog/id/intlayer_with_i18next.md +126 -0
  38. package/blog/id/intlayer_with_next-i18next.md +142 -0
  39. package/blog/id/intlayer_with_next-intl.md +113 -0
  40. package/blog/id/intlayer_with_react-i18next.md +124 -0
  41. package/blog/id/intlayer_with_react-intl.md +122 -0
  42. package/blog/it/intlayer_with_i18next.md +67 -103
  43. package/blog/it/intlayer_with_next-i18next.md +71 -296
  44. package/blog/it/intlayer_with_next-intl.md +57 -338
  45. package/blog/it/intlayer_with_react-i18next.md +68 -290
  46. package/blog/it/intlayer_with_react-intl.md +62 -265
  47. package/blog/ja/intlayer_with_i18next.md +68 -103
  48. package/blog/ja/intlayer_with_next-i18next.md +85 -283
  49. package/blog/ja/intlayer_with_next-intl.md +58 -336
  50. package/blog/ja/intlayer_with_react-i18next.md +68 -290
  51. package/blog/ja/intlayer_with_react-intl.md +62 -264
  52. package/blog/ko/intlayer_with_i18next.md +80 -96
  53. package/blog/ko/intlayer_with_next-i18next.md +85 -287
  54. package/blog/ko/intlayer_with_next-intl.md +68 -327
  55. package/blog/ko/intlayer_with_react-i18next.md +68 -290
  56. package/blog/ko/intlayer_with_react-intl.md +64 -266
  57. package/blog/pl/intlayer_with_i18next.md +126 -0
  58. package/blog/pl/intlayer_with_next-i18next.md +142 -0
  59. package/blog/pl/intlayer_with_next-intl.md +111 -0
  60. package/blog/pl/intlayer_with_react-i18next.md +124 -0
  61. package/blog/pl/intlayer_with_react-intl.md +122 -0
  62. package/blog/pt/intlayer_with_i18next.md +67 -103
  63. package/blog/pt/intlayer_with_next-i18next.md +72 -293
  64. package/blog/pt/intlayer_with_next-intl.md +57 -256
  65. package/blog/pt/intlayer_with_react-i18next.md +104 -78
  66. package/blog/pt/intlayer_with_react-intl.md +62 -266
  67. package/blog/ru/intlayer_with_i18next.md +66 -104
  68. package/blog/ru/intlayer_with_next-i18next.md +71 -296
  69. package/blog/ru/intlayer_with_next-intl.md +58 -337
  70. package/blog/ru/intlayer_with_react-i18next.md +68 -290
  71. package/blog/ru/intlayer_with_react-intl.md +62 -265
  72. package/blog/tr/intlayer_with_i18next.md +71 -107
  73. package/blog/tr/intlayer_with_next-i18next.md +72 -297
  74. package/blog/tr/intlayer_with_next-intl.md +58 -339
  75. package/blog/tr/intlayer_with_react-i18next.md +69 -291
  76. package/blog/tr/intlayer_with_react-intl.md +63 -285
  77. package/blog/vi/intlayer_with_i18next.md +126 -0
  78. package/blog/vi/intlayer_with_next-i18next.md +142 -0
  79. package/blog/vi/intlayer_with_next-intl.md +111 -0
  80. package/blog/vi/intlayer_with_react-i18next.md +124 -0
  81. package/blog/vi/intlayer_with_react-intl.md +122 -0
  82. package/blog/zh/intlayer_with_i18next.md +67 -102
  83. package/blog/zh/intlayer_with_next-i18next.md +72 -296
  84. package/blog/zh/intlayer_with_next-intl.md +58 -336
  85. package/blog/zh/intlayer_with_react-i18next.md +68 -290
  86. package/blog/zh/intlayer_with_react-intl.md +63 -106
  87. package/dist/cjs/generated/blog.entry.cjs +13 -1
  88. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  89. package/dist/cjs/generated/docs.entry.cjs +13 -1
  90. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  91. package/dist/cjs/generated/frequentQuestions.entry.cjs +13 -1
  92. package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
  93. package/dist/cjs/generated/legal.entry.cjs +13 -1
  94. package/dist/cjs/generated/legal.entry.cjs.map +1 -1
  95. package/dist/esm/generated/blog.entry.mjs +13 -2
  96. package/dist/esm/generated/blog.entry.mjs.map +1 -1
  97. package/dist/esm/generated/docs.entry.mjs +13 -2
  98. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  99. package/dist/esm/generated/frequentQuestions.entry.mjs +13 -2
  100. package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
  101. package/dist/esm/generated/legal.entry.mjs +13 -2
  102. package/dist/esm/generated/legal.entry.mjs.map +1 -1
  103. package/dist/types/generated/blog.entry.d.ts.map +1 -1
  104. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  105. package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
  106. package/dist/types/generated/legal.entry.d.ts.map +1 -1
  107. package/docs/ar/plugins/sync-json.md +244 -0
  108. package/docs/de/plugins/sync-json.md +244 -0
  109. package/docs/de/releases/v7.md +1 -18
  110. package/docs/en/CI_CD.md +1 -1
  111. package/docs/en/configuration.md +1 -1
  112. package/docs/en/formatters.md +1 -1
  113. package/docs/en/how_works_intlayer.md +1 -1
  114. package/docs/en/intlayer_CMS.md +1 -1
  115. package/docs/en/intlayer_cli.md +26 -1
  116. package/docs/en/intlayer_with_nextjs_14.md +3 -1
  117. package/docs/en/intlayer_with_nextjs_15.md +3 -1
  118. package/docs/en/intlayer_with_nextjs_16.md +3 -1
  119. package/docs/en/intlayer_with_nextjs_page_router.md +1 -1
  120. package/docs/en/intlayer_with_nuxt.md +1 -1
  121. package/docs/en/intlayer_with_react_native+expo.md +1 -1
  122. package/docs/en/intlayer_with_react_router_v7.md +1 -1
  123. package/docs/en/intlayer_with_tanstack.md +1 -1
  124. package/docs/en/intlayer_with_vite+preact.md +1 -1
  125. package/docs/en/intlayer_with_vite+react.md +1 -1
  126. package/docs/en/intlayer_with_vite+solid.md +1 -1
  127. package/docs/en/intlayer_with_vite+svelte.md +1 -1
  128. package/docs/en/intlayer_with_vite+vue.md +1 -1
  129. package/docs/en/plugins/sync-json.md +1 -1
  130. package/docs/en/roadmap.md +1 -1
  131. package/docs/en-GB/plugins/sync-json.md +244 -0
  132. package/docs/es/plugins/sync-json.md +244 -0
  133. package/docs/es/releases/v7.md +1 -18
  134. package/docs/fr/intlayer_with_nextjs_16.md +2 -51
  135. package/docs/fr/plugins/sync-json.md +244 -0
  136. package/docs/fr/releases/v7.md +1 -18
  137. package/docs/hi/intlayer_with_nextjs_16.md +3 -2
  138. package/docs/hi/plugins/sync-json.md +244 -0
  139. package/docs/id/plugins/sync-json.md +244 -0
  140. package/docs/id/releases/v7.md +1 -18
  141. package/docs/it/plugins/sync-json.md +244 -0
  142. package/docs/it/releases/v7.md +1 -18
  143. package/docs/ja/intlayer_with_nextjs_16.md +44 -205
  144. package/docs/ja/plugins/sync-json.md +244 -0
  145. package/docs/ja/releases/v7.md +1 -18
  146. package/docs/ko/plugins/sync-json.md +244 -0
  147. package/docs/ko/releases/v7.md +1 -18
  148. package/docs/pl/plugins/sync-json.md +244 -0
  149. package/docs/pt/intlayer_with_nextjs_16.md +1 -52
  150. package/docs/pt/plugins/sync-json.md +244 -0
  151. package/docs/ru/plugins/sync-json.md +244 -0
  152. package/docs/tr/plugins/sync-json.md +245 -0
  153. package/docs/vi/plugins/sync-json.md +244 -0
  154. package/docs/zh/plugins/sync-json.md +244 -0
  155. package/package.json +14 -14
  156. package/src/generated/blog.entry.ts +26 -3
  157. package/src/generated/docs.entry.ts +26 -3
  158. package/src/generated/frequentQuestions.entry.ts +26 -3
  159. package/src/generated/legal.entry.ts +26 -3
@@ -1,367 +1,142 @@
1
1
  ---
2
2
  createdAt: 2025-08-23
3
- updatedAt: 2025-08-23
3
+ updatedAt: 2025-10-29
4
4
  title: Intlayer e next-i18next
5
- description: Integra Intlayer con next-i18next per un'app Next.js
5
+ description: Integra Intlayer con next-i18next per una soluzione completa di internazionalizzazione in Next.js
6
6
  keywords:
7
7
  - i18next
8
8
  - next-i18next
9
9
  - Intlayer
10
10
  - Internazionalizzazione
11
- - Blogumentazione
11
+ - Blog
12
12
  - Next.js
13
13
  - JavaScript
14
14
  - React
15
15
  slugs:
16
16
  - blog
17
17
  - intlayer-with-next-i18next
18
+ history:
19
+ - version: 7.0.0
20
+ date: 2025-10-29
21
+ changes: Cambio al plugin syncJSON e riscrittura completa
18
22
  ---
19
23
 
20
- # Next.js Internazionalizzazione (i18n) con next-i18next e Intlayer
24
+ # Internazionalizzazione (i18n) in Next.js con next-i18next e Intlayer
21
25
 
22
- Sia next-i18next che Intlayer sono framework di internazionalizzazione (i18n) open-source progettati per applicazioni Next.js. Sono ampiamente utilizzati per gestire traduzioni, localizzazione e cambio di lingua nei progetti software.
26
+ ## Indice
23
27
 
24
- Entrambe le soluzioni includono tre nozioni principali:
28
+ <TOC/>
25
29
 
26
- 1. **Dichiarazione dei Contenuti**: Il metodo per definire i contenuti traducibili della tua applicazione.
27
- - Chiamata `resource` nel caso di `i18next`, la dichiarazione dei contenuti è un oggetto JSON strutturato contenente coppie chiave-valore per traduzioni in una o più lingue. Vedi [documentazione di i18next](https://www.i18next.com/translation-function/essentials) per ulteriori informazioni.
28
- - Chiamata `file di dichiarazione dei contenuti` nel caso di `Intlayer`, la dichiarazione dei contenuti può essere un file JSON, JS o TS che esporta i dati strutturati. Vedi [documentazione di Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/doc/concept/content) per ulteriori informazioni.
30
+ ## Cos'è next-i18next?
29
31
 
30
- 2. **Utilities**: Strumenti per costruire e interpretare le dichiarazioni dei contenuti nell'applicazione, come `getI18n()`, `useCurrentLocale()`, o `useChangeLocale()` per next-i18next, e `useIntlayer()` o `useLocale()` per Intlayer.
32
+ **next-i18next** è uno dei framework di internazionalizzazione (i18n) più popolari per applicazioni Next.js. Costruito sopra il potente ecosistema **i18next**, offre una soluzione completa per la gestione delle traduzioni, della localizzazione e del cambio lingua nei progetti Next.js.
31
33
 
32
- 3. **Plugin e Middleware**: Funzionalità per gestire la reindirizzamento degli URL, ottimizzazione del bundle e altro, come `next-i18next/middleware` per next-i18next o `intlayerMiddleware` per Intlayer.
34
+ Tuttavia, next-i18next presenta alcune sfide:
33
35
 
34
- ## Intlayer vs. i18next: Principali Differenze
36
+ - **Configurazione complessa**: Configurare next-i18next richiede più file di configurazione e un'attenta impostazione delle istanze i18n sia lato server che lato client.
37
+ - **Traduzioni sparse**: I file di traduzione sono tipicamente archiviati in directory separate dai componenti, rendendo più difficile mantenere la coerenza.
38
+ - **Gestione manuale dei namespace**: Gli sviluppatori devono gestire manualmente i namespace e assicurarsi del corretto caricamento delle risorse di traduzione.
39
+ - **Sicurezza dei tipi limitata**: Il supporto a TypeScript richiede una configurazione aggiuntiva e non fornisce una generazione automatica dei tipi per le traduzioni.
35
40
 
36
- Per esplorare le differenze tra i18next e Intlayer, controlla il nostro post sul blog [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/it/i18next_vs_next-intl_vs_intlayer.md).
41
+ ## Cos'è Intlayer?
37
42
 
38
- ## Come Generare Dizionari next-i18next con Intlayer
43
+ **Intlayer** è una libreria di internazionalizzazione innovativa e open-source progettata per superare le limitazioni delle soluzioni i18n tradizionali. Offre un approccio moderno alla gestione dei contenuti nelle applicazioni Next.js.
39
44
 
40
- ### Perché Usare Intlayer con next-i18next?
45
+ Consulta un confronto concreto con next-intl nel nostro post sul blog [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/it/next-i18next_vs_next-intl_vs_intlayer.md).
41
46
 
42
- I file di dichiarazione dei contenuti di Intlayer offrono generalmente una migliore esperienza per gli sviluppatori. Sono più flessibili e manutenibili grazie a due principali vantaggi:
47
+ ## Perché combinare Intlayer con next-i18next?
43
48
 
44
- 1. **Posizionamento Flessibile**: Un file di dichiarazione dei contenuti di Intlayer può essere posizionato ovunque nell'albero dei file dell'applicazione, semplificando la gestione di componenti duplicati o eliminati senza lasciare dichiarazioni di contenuti non utilizzate.
49
+ Mentre Intlayer offre una soluzione i18n autonoma eccellente (consulta la nostra [guida all'integrazione con Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_with_nextjs_16.md)), potresti volerla combinare con next-i18next per diversi motivi:
45
50
 
46
- Esempi di strutture di file:
51
+ 1. **Codice esistente**: Hai un'implementazione consolidata di next-i18next e desideri migrare gradualmente verso la migliore esperienza sviluppatore offerta da Intlayer.
52
+ 2. **Requisiti legacy**: Il tuo progetto richiede compatibilità con plugin o flussi di lavoro i18next esistenti.
53
+ 3. **Familiarità del team**: Il tuo team è abituato a next-i18next ma desidera una migliore gestione dei contenuti.
47
54
 
48
- ```bash codeFormat="typescript"
49
- .
50
- └── src
51
- └── components
52
- └── MyComponent
53
- ├── index.content.ts # File di dichiarazione dei contenuti
54
- └── index.tsx
55
- ```
55
+ **Per questo, Intlayer può essere implementato come un adattatore per next-i18next per aiutarti ad automatizzare le tue traduzioni JSON in CLI o pipeline CI/CD, testare le tue traduzioni e altro ancora.**
56
56
 
57
- ```bash codeFormat="esm"
58
- .
59
- └── src
60
- └── components
61
- └── MyComponent
62
- ├── index.content.mjs # File di dichiarazione dei contenuti
63
- └── index.mjx
64
- ```
57
+ Questa guida ti mostra come sfruttare il sistema superiore di dichiarazione dei contenuti di Intlayer mantenendo la compatibilità con next-i18next.
65
58
 
66
- ```bash codeFormat="cjs"
67
- .
68
- └── src
69
- └── components
70
- └── MyComponent
71
- ├── index.content.cjs # File di dichiarazione dei contenuti
72
- └── index.cjx
73
- ```
59
+ ---
74
60
 
75
- ```bash codeFormat="json"
76
- .
77
- └── src
78
- └── components
79
- └── MyComponent
80
- ├── index.content.json # File di dichiarazione dei contenuti
81
- └── index.jsx
82
- ```
61
+ ## Guida passo-passo per configurare Intlayer con next-i18next
83
62
 
84
- 2. **Traduzioni Centralizzate**: Intlayer memorizza tutte le traduzioni in un unico file, garantendo che nessuna traduzione manchi. Quando si utilizza TypeScript, le traduzioni mancanti vengono automaticamente rilevate e segnalate come errori.
63
+ ### Passo 1: Installa le dipendenze
85
64
 
86
- ### Installazione
65
+ Installa i pacchetti necessari usando il tuo gestore di pacchetti preferito:
87
66
 
88
67
  ```bash packageManager="npm"
89
- npm install intlayer i18next next-i18next i18next-resources-to-backend
68
+ npm install intlayer @intlayer/sync-json-plugin
90
69
  ```
91
70
 
92
- ```bash packageManager="yarn"
93
- yarn add intlayer i18next next-i18next i18next-resources-to-backend
71
+ ```bash packageManager="pnpm"
72
+ pnpm add intlayer @intlayer/sync-json-plugin
94
73
  ```
95
74
 
96
- ```bash packageManager="pnpm"
97
- pnpm add intlayer i18next next-i18next i18next-resources-to-backend
75
+ ```bash packageManager="yarn"
76
+ yarn add intlayer @intlayer/sync-json-plugin
98
77
  ```
99
78
 
100
- ### Configurare Intlayer per Esportare Dizionari i18next
79
+ **Spiegazioni dei pacchetti:**
101
80
 
102
- > L'esportazione delle risorse di i18next non garantisce una compatibilità 1:1 con altri framework. Si consiglia di attenersi a una configurazione basata su Intlayer per minimizzare i problemi.
81
+ - **intlayer**: Libreria core per la dichiarazione e gestione dei contenuti
82
+ - **next-intlayer**: Layer di integrazione per Next.js con plugin di build
83
+ - **i18next**: Framework core per l'internazionalizzazione
84
+ - **next-i18next**: Wrapper Next.js per i18next
85
+ - **i18next-resources-to-backend**: Caricamento dinamico delle risorse per i18next
86
+ - **@intlayer/sync-json-plugin**: Plugin per sincronizzare le dichiarazioni di contenuto Intlayer nel formato JSON di i18next
103
87
 
104
- Per esportare le risorse di i18next, configura Intlayer in un file `intlayer.config.ts`. Esempi di configurazioni:
88
+ ### Passo 2: Implementare il plugin Intlayer per incapsulare il JSON
105
89
 
106
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
107
- import { Locales, type IntlayerConfig } from "intlayer";
108
-
109
- const config: IntlayerConfig = {
110
- internationalization: {
111
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
112
- defaultLocale: Locales.ENGLISH,
113
- },
114
- content: {
115
- dictionaryOutput: ["i18next"],
116
- i18nextResourcesDir: "./i18next/resources",
117
- },
118
- };
90
+ Crea un file di configurazione Intlayer per definire le tue localizzazioni supportate:
119
91
 
120
- export default config;
121
- ```
92
+ **Se vuoi anche esportare dizionari JSON per i18next**, aggiungi il plugin `syncJSON`:
122
93
 
123
- ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
124
- import { Locales } from "intlayer";
94
+ ```typescript fileName="intlayer.config.ts"
95
+ import { Locales, type IntlayerConfig } from "intlayer";
96
+ import { syncJSON } from "@intlayer/sync-json-plugin";
125
97
 
126
- /** @type {import('intlayer').IntlayerConfig} */
127
- const config = {
98
+ const config: IntlayerConfig = {
128
99
  internationalization: {
129
100
  locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
130
101
  defaultLocale: Locales.ENGLISH,
131
102
  },
132
- content: {
133
- dictionaryOutput: ["i18next"],
134
- i18nextResourcesDir: "./i18next/resources",
135
- },
103
+ plugins: [
104
+ syncJSON({
105
+ source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
106
+ }),
107
+ ],
136
108
  };
137
109
 
138
110
  export default config;
139
111
  ```
140
112
 
141
- ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
142
- const { Locales } = require("intlayer");
113
+ Il plugin `syncJSON` incapsulerà automaticamente il JSON. Leggerà e scriverà i file JSON senza modificare l'architettura del contenuto.
143
114
 
144
- /** @type {import('intlayer').IntlayerConfig} */
145
- const config = {
146
- internationalization: {
147
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
148
- defaultLocale: Locales.ENGLISH,
149
- },
150
- content: {
151
- dictionaryOutput: ["i18next"],
152
- i18nextResourcesDir: "./i18next/resources",
153
- },
154
- };
115
+ Se vuoi far coesistere quel JSON con i file di dichiarazione dei contenuti di intlayer (file `.content`), Intlayer procederà in questo modo:
155
116
 
156
- module.exports = config;
157
- ```
117
+ 1. caricherà sia i file JSON che i file di dichiarazione dei contenuti e li trasformerà in un dizionario intlayer.
118
+ 2. se ci sono conflitti tra i file JSON e i file di dichiarazione dei contenuti, Intlayer procederà alla fusione di tutti questi dizionari. A seconda della priorità dei plugin e di quella del file di dichiarazione dei contenuti (tutti configurabili).
158
119
 
159
- Ecco la continuazione e la correzione delle parti rimanenti del tuo documento:
120
+ Se vengono apportate modifiche utilizzando la CLI per tradurre il JSON, o utilizzando il CMS, Intlayer aggiornerà il file JSON con le nuove traduzioni.
160
121
 
161
122
  ---
162
123
 
163
- ### Importare Dizionari nella Tua Configurazione i18next
164
-
165
- Per importare le risorse generate nella tua configurazione i18next, utilizza `i18next-resources-to-backend`. Di seguito sono riportati esempi:
166
-
167
- ```typescript fileName="i18n/client.ts" codeFormat="typescript"
168
- import i18next from "i18next";
169
- import resourcesToBackend from "i18next-resources-to-backend";
170
-
171
- i18next.use(
172
- resourcesToBackend(
173
- (language: string, namespace: string) =>
174
- import(`../i18next/resources/${language}/${namespace}.json`)
175
- )
176
- );
177
- ```
178
-
179
- ```javascript fileName="i18n/client.mjs" codeFormat="esm"
180
- import i18next from "i18next";
181
- import resourcesToBackend from "i18next-resources-to-backend";
182
-
183
- i18next.use(
184
- resourcesToBackend(
185
- (language, namespace) =>
186
- import(`../i18next/resources/${language}/${namespace}.json`)
187
- )
188
- );
189
- ```
190
-
191
- ```javascript fileName="i18n/client.cjs" codeFormat="commonjs"
192
- const i18next = require("i18next");
193
- const resourcesToBackend = require("i18next-resources-to-backend");
194
-
195
- i18next.use(
196
- resourcesToBackend(
197
- (language, namespace) =>
198
- import(`../i18next/resources/${language}/${namespace}.json`)
199
- )
200
- );
201
- ```
202
-
203
- ### Dichiarazione dei Contenuti
204
-
205
- Esempi di file di dichiarazione dei contenuti in vari formati:
206
-
207
- ```typescript fileName="**/*.content.ts" contentDeclarationFormat="typescript"
208
- import { t, type Dictionary } from "intlayer";
209
-
210
- const content = {
211
- key: "my-content",
212
- content: {
213
- myTranslatedContent: t({
214
- en: "Hello World",
215
- es: "Hola Mundo",
216
- fr: "Bonjour le monde",
217
- }),
218
- },
219
- } satisfies Dictionary;
220
-
221
- export default content;
222
- ```
223
-
224
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
225
- import { t } from "intlayer";
226
-
227
- /** @type {import('intlayer').Dictionary} */
228
- const content = {
229
- key: "my-content",
230
- content: {
231
- myTranslatedContent: t({
232
- en: "Hello World",
233
- es: "Hola Mundo",
234
- fr: "Bonjour le monde",
235
- }),
236
- },
237
- };
238
- ```
239
-
240
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
241
- const { t } = require("intlayer");
242
-
243
- module.exports = {
244
- key: "my-content",
245
- content: {
246
- myTranslatedContent: t({
247
- en: "Hello World",
248
- es: "Hola Mundo",
249
- fr: "Bonjour le monde",
250
- }),
251
- },
252
- };
253
- ```
254
-
255
- ```json fileName="**/*.content.json" contentDeclarationFormat="json"
256
- {
257
- "$schema": "https://intlayer.org/schema.json",
258
- "key": "my-content",
259
- "content": {
260
- "myTranslatedContent": {
261
- "nodeType": "translation",
262
- "translation": {
263
- "en": "Hello World",
264
- "fr": "Bonjour le monde",
265
- "es": "Hola Mundo"
266
- }
267
- }
268
- }
269
- }
270
- ```
271
-
272
- ### Costruire le Risorse next-i18next
273
-
274
- Per costruire le risorse next-i18next, esegui il seguente comando:
275
-
276
- ```bash packageManager="npm"
277
- npx run intlayer build
278
- ```
279
-
280
- ```bash packageManager="yarn"
281
- yarn intlayer build
282
- ```
124
+ ## Configurazione Git
283
125
 
284
- ```bash packageManager="pnpm"
285
- pnpm intlayer build
286
- ```
287
-
288
- Questo genererà risorse nella directory `./i18next/resources`. L'output atteso:
289
-
290
- ```bash
291
- .
292
- └── i18next
293
- └── resources
294
- └── en
295
- └── my-content.json
296
- └── fr
297
- └── my-content.json
298
- └── es
299
- └── my-content.json
300
- ```
301
-
302
- Nota: Il namespace di i18next corrisponde alla chiave di dichiarazione di Intlayer.
303
-
304
- ### Implementare il Plugin Next.js
305
-
306
- Una volta configurato, implementa il plugin Next.js per ricostruire le tue risorse i18next ogni volta che i file di dichiarazione dei contenuti di Intlayer vengono aggiornati.
307
-
308
- ```typescript fileName="next.config.mjs"
309
- import { withIntlayer } from "next-intlayer/server";
310
-
311
- /** @type {import('next').NextConfig} */
312
- const nextConfig = {};
313
-
314
- export default withIntlayer(nextConfig);
315
- ```
126
+ Escludi i file generati dal controllo versione:
316
127
 
317
- ### Usare il Contenuto nei Componenti Next.js
318
-
319
- Dopo aver implementato il plugin Next.js, puoi utilizzare il contenuto nei tuoi componenti:
320
-
321
- ```typescript fileName="src/components/myComponent/index.tsx" codeFormat="typescript"
322
- import type { FC } from "react";
323
- import { useTranslation } from "react-i18next";
324
-
325
- const IndexPage: FC = () => {
326
- const { t } = useTranslation();
327
-
328
- return (
329
- <div>
330
- <h1>{t("my-content.title")}</h1>
331
- <p>{t("my-content.description")}</p>
332
- </div>
333
- );
334
- };
335
-
336
- export default IndexPage;
128
+ ```plaintext fileName=".gitignore"
129
+ # Ignora i file generati da Intlayer
130
+ .intlayer
131
+ intl
337
132
  ```
338
133
 
339
- ```jsx fileName="src/components/myComponent/index.mjx" codeFormat="esm"
340
- import { useTranslation } from "react-i18next";
134
+ Questi file vengono rigenerati automaticamente durante il processo di build e non devono essere inseriti nel tuo repository.
341
135
 
342
- const IndexPage = () => {
343
- const { t } = useTranslation();
136
+ ### Estensione VS Code
344
137
 
345
- return (
346
- <div>
347
- <h1>{t("my-content.title")}</h1>
348
- <p>{t("my-content.description")}</p>
349
- </div>
350
- );
351
- };
352
- ```
353
-
354
- ```jsx fileName="src/components/myComponent/index.cjx" codeFormat="commonjs"
355
- const { useTranslation } = require("react-i18next");
138
+ Per migliorare l'esperienza dello sviluppatore, installa la **Estensione ufficiale Intlayer per VS Code**:
356
139
 
357
- const IndexPage = () => {
358
- const { t } = useTranslation();
140
+ [Installa dal Marketplace di VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
359
141
 
360
- return (
361
- <div>
362
- <h1>{t("my-content.title")}</h1>
363
- <p>{t("my-content.description")}</p>
364
- </div>
365
- );
366
- };
367
- ```
142
+ [Installa dal Marketplace di VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)