@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
@@ -0,0 +1,244 @@
1
+ ---
2
+ createdAt: 2025-03-13
3
+ updatedAt: 2025-10-05
4
+ title: Plugin Sinkronisasi JSON
5
+ description: Sinkronkan kamus Intlayer dengan file JSON i18n pihak ketiga (i18next, next-intl, react-intl, vue-i18n, dan lainnya). Pertahankan i18n Anda yang sudah ada sambil menggunakan Intlayer untuk mengelola, menerjemahkan, dan menguji pesan Anda.
6
+ keywords:
7
+ - Intlayer
8
+ - Sinkronisasi JSON
9
+ - i18next
10
+ - next-intl
11
+ - react-intl
12
+ - vue-i18n
13
+ - next-translate
14
+ - nuxt-i18n
15
+ - LinguiJS
16
+ - Polyglot.js
17
+ - Solid-i18next
18
+ - svelte-i18n
19
+ - i18n
20
+ - terjemahan
21
+ slugs:
22
+ - doc
23
+ - plugin
24
+ - sync-json
25
+ history:
26
+ - version: 6.1.6
27
+ date: 2025-10-05
28
+ changes: Dokumentasi awal plugin Sinkronisasi JSON
29
+ ---
30
+
31
+ # Sinkronisasi JSON (jembatan i18n)
32
+
33
+ Gunakan Intlayer sebagai tambahan pada tumpukan i18n Anda yang sudah ada. Plugin ini menjaga pesan JSON Anda tetap sinkron dengan kamus Intlayer sehingga Anda dapat:
34
+
35
+ - Mempertahankan i18next, next-intl, react-intl, vue-i18n, next-translate, nuxt-i18n, Solid-i18next, svelte-i18n, dll.
36
+ - Mengelola dan menerjemahkan pesan Anda dengan Intlayer (CLI, CI, penyedia, CMS), tanpa perlu merombak aplikasi Anda.
37
+ - Mengirimkan tutorial dan konten SEO yang menargetkan setiap ekosistem, sambil menyarankan Intlayer sebagai lapisan pengelolaan JSON.
38
+
39
+ Catatan dan cakupan saat ini:
40
+
41
+ - Eksternalisasi ke CMS berfungsi untuk terjemahan dan teks klasik.
42
+ - Belum mendukung penyisipan, bentuk jamak/ICU, atau fitur runtime lanjutan dari pustaka lain.
43
+ - Editor visual belum didukung untuk output i18n pihak ketiga.
44
+
45
+ ### Kapan menggunakan plugin ini
46
+
47
+ - Anda sudah menggunakan perpustakaan i18n dan menyimpan pesan dalam file JSON.
48
+ - Anda menginginkan pengisian berbantuan AI, pengujian di CI, dan operasi konten tanpa mengubah runtime rendering Anda.
49
+
50
+ ## Instalasi
51
+
52
+ ```bash
53
+ pnpm add -D @intlayer/sync-json-plugin
54
+ # atau
55
+ npm i -D @intlayer/sync-json-plugin
56
+ ```
57
+
58
+ ## Mulai cepat
59
+
60
+ Tambahkan plugin ke `intlayer.config.ts` Anda dan arahkan ke struktur JSON yang sudah ada.
61
+
62
+ ```ts fileName="intlayer.config.ts"
63
+ import { defineConfig, Locales } from "intlayer";
64
+ import { syncJSON } from "@intlayer/sync-json-plugin";
65
+
66
+ export default defineConfig({
67
+ internationalization: {
68
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
69
+ defaultLocale: Locales.ENGLISH,
70
+ },
71
+
72
+ // Jaga file JSON Anda saat ini tetap sinkron dengan kamus Intlayer
73
+ plugins: [
74
+ syncJSON({
75
+ // Tata letak per-locale, per-namespace (misalnya, next-intl, i18next dengan namespaces)
76
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
77
+ }),
78
+ ],
79
+ });
80
+ ```
81
+
82
+ Alternatif: satu file per locale (umum dengan pengaturan i18next/react-intl):
83
+
84
+ ```ts fileName="intlayer.config.ts"
85
+ plugins: [
86
+ syncJSON({
87
+ source: ({ locale }) => `./locales/${locale}.json`,
88
+ }),
89
+ ];
90
+ ```
91
+
92
+ ### Cara kerjanya
93
+
94
+ - Baca: plugin menemukan file JSON dari pembangun `source` Anda dan memuatnya sebagai kamus Intlayer.
95
+ - Tulis: setelah proses build dan pengisian, plugin menulis kembali JSON yang sudah dilokalkan ke jalur yang sama (dengan newline akhir untuk menghindari masalah format).
96
+ - Auto‑fill: plugin mendeklarasikan jalur `autoFill` untuk setiap kamus. Menjalankan `intlayer fill` secara default hanya memperbarui terjemahan yang hilang dalam file JSON Anda.
97
+
98
+ API:
99
+
100
+ ```ts
101
+ syncJSON({
102
+ source: ({ key, locale }) => string, // wajib
103
+ location?: string, // label opsional, default: "plugin"
104
+ priority?: number, // prioritas opsional untuk resolusi konflik, default: 0
105
+ });
106
+ ```
107
+
108
+ ## Beberapa sumber JSON dan prioritas
109
+
110
+ Anda dapat menambahkan beberapa plugin `syncJSON` untuk menyinkronkan berbagai sumber JSON. Ini berguna ketika Anda memiliki beberapa pustaka i18n atau struktur JSON yang berbeda dalam proyek Anda.
111
+
112
+ ### Sistem prioritas
113
+
114
+ Ketika beberapa plugin menargetkan kunci kamus yang sama, parameter `priority` menentukan plugin mana yang diutamakan:
115
+
116
+ - Angka prioritas yang lebih tinggi menang atas yang lebih rendah
117
+ - Prioritas default untuk file `.content` adalah `0`
118
+ - Prioritas default untuk file konten plugin adalah `-1`
119
+ - Plugin dengan prioritas yang sama diproses sesuai urutan kemunculannya dalam konfigurasi
120
+
121
+ ```ts fileName="intlayer.config.ts"
122
+ import { defineConfig, Locales } from "intlayer";
123
+ import { syncJSON } from "@intlayer/sync-json-plugin";
124
+
125
+ export default defineConfig({
126
+ internationalization: {
127
+ locales: [Locales.ENGLISH, Locales.FRENCH],
128
+ defaultLocale: Locales.ENGLISH,
129
+ },
130
+
131
+ plugins: [
132
+ // Sumber JSON utama (prioritas tertinggi)
133
+ syncJSON({
134
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
135
+ location: "main-translations",
136
+ priority: 10,
137
+ }),
138
+
139
+ // Sumber JSON cadangan (prioritas lebih rendah)
140
+ syncJSON({
141
+ source: ({ locale }) => `./fallback-locales/${locale}.json`,
142
+ location: "fallback-translations",
143
+ priority: 5,
144
+ }),
145
+
146
+ // Sumber JSON Legacy (prioritas terendah)
147
+ syncJSON({
148
+ source: ({ locale }) => `/my/other/app/legacy/${locale}/messages.json`,
149
+ location: "legacy-translations",
150
+ priority: 1,
151
+ }),
152
+ ],
153
+ });
154
+ ```
155
+
156
+ ### Penyelesaian konflik
157
+
158
+ Ketika kunci terjemahan yang sama ada di beberapa sumber JSON:
159
+
160
+ 1. Plugin dengan prioritas tertinggi menentukan nilai akhir
161
+ 2. Sumber dengan prioritas lebih rendah digunakan sebagai cadangan untuk kunci yang hilang
162
+ 3. Ini memungkinkan Anda mempertahankan terjemahan legacy sambil secara bertahap bermigrasi ke struktur baru
163
+
164
+ ## Integrasi
165
+
166
+ Berikut adalah pemetaan umum. Biarkan runtime Anda tetap tidak berubah; hanya tambahkan plugin.
167
+
168
+ ### i18next
169
+
170
+ Tata letak file tipikal: `./public/locales/{locale}/{namespace}.json` atau `./locales/{locale}/{namespace}.json`.
171
+
172
+ ```ts fileName="intlayer.config.ts"
173
+ import { syncJSON } from "@intlayer/sync-json-plugin";
174
+
175
+ export default {
176
+ plugins: [
177
+ syncJSON({
178
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
179
+ }),
180
+ ],
181
+ };
182
+ ```
183
+
184
+ ### next-intl
185
+
186
+ Pesan JSON per-locale (sering `./messages/{locale}.json`) atau per-namespace.
187
+
188
+ ```ts fileName="intlayer.config.ts"
189
+ plugins: [
190
+ syncJSON({
191
+ source: ({ locale, key }) => `./messages/${locale}/${key}.json`,
192
+ }),
193
+ ];
194
+ ```
195
+
196
+ Lihat juga: `docs/id/intlayer_with_next-intl.md`.
197
+
198
+ ### react-intl
199
+
200
+ JSON tunggal per locale adalah umum:
201
+
202
+ ```ts fileName="intlayer.config.ts"
203
+ plugins: [
204
+ syncJSON({
205
+ source: ({ locale }) => `./locales/${locale}.json`,
206
+ }),
207
+ ];
208
+ ```
209
+
210
+ ### vue-i18n
211
+
212
+ Baik satu file per locale atau per-namespace:
213
+
214
+ ```ts fileName="intlayer.config.ts"
215
+ plugins: [
216
+ syncJSON({
217
+ source: ({ key, locale }) => `./src/locales/${locale}/${key}.json`,
218
+ }),
219
+ ];
220
+ ```
221
+
222
+ ## CLI
223
+
224
+ File JSON yang disinkronkan akan dianggap sebagai file `.content` lainnya. Artinya, semua perintah intlayer akan tersedia untuk file JSON yang disinkronkan. Termasuk:
225
+
226
+ - `intlayer content test` untuk menguji apakah ada terjemahan yang hilang
227
+ - `intlayer content list` untuk mendaftar file JSON yang disinkronkan
228
+ - `intlayer content fill` untuk mengisi terjemahan yang hilang
229
+ - `intlayer content push` untuk mengirim file JSON yang disinkronkan
230
+ - `intlayer content pull` untuk menarik file JSON yang disinkronkan
231
+
232
+ Lihat [Intlayer CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_cli.md) untuk detail lebih lanjut.
233
+
234
+ ## Keterbatasan (saat ini)
235
+
236
+ - Tidak ada dukungan penyisipan atau bentuk jamak/ICU saat menargetkan pustaka pihak ketiga.
237
+ - Editor visual belum tersedia untuk runtime non-Intlayer.
238
+ - Sinkronisasi hanya untuk JSON; format katalog non-JSON tidak didukung.
239
+
240
+ ## Mengapa ini penting
241
+
242
+ - Kami dapat merekomendasikan solusi i18n yang sudah mapan dan memposisikan Intlayer sebagai tambahan.
243
+ - Kami memanfaatkan SEO/kata kunci mereka dengan tutorial yang berakhir dengan menyarankan Intlayer untuk mengelola JSON.
244
+ - Memperluas audiens yang dapat dijangkau dari “proyek baru” menjadi “tim mana pun yang sudah menggunakan i18n”.
@@ -411,23 +411,6 @@ Sistem secara otomatis:
411
411
 
412
412
  **Sebelum (v6):**
413
413
 
414
- ````typescript
415
- export default {
416
- #### Pemetaan konfigurasi
417
-
418
- | Konfigurasi v6 | Konfigurasi v7 |
419
- | ------------------------- | -------------------------------------------------- |
420
- | `autoFill: xxx` | `fill: xxx` |
421
- | `prefixDefault: false` | `mode: 'prefix-no-default'` |
422
- | `prefixDefault: true` | `mode: 'prefix-all'` |
423
- | `noPrefix: true` | `mode: 'no-prefix'` |
424
- | `cookieName: 'my-locale'` | `storage: { type: 'cookie', name: 'my-locale' }` |
425
- | `serverSetCookie: 'never'`| `storage: false` atau hapus cookie dari array storage` |
426
-
427
- #### Contoh migrasi
428
-
429
- **Sebelum (v6):**
430
-
431
414
  ```typescript
432
415
  export default {
433
416
  middleware: {
@@ -439,7 +422,7 @@ export default {
439
422
  noPrefix: false,
440
423
  },
441
424
  };
442
- ````
425
+ ```
443
426
 
444
427
  **Sesudah (v7):**
445
428
 
@@ -0,0 +1,244 @@
1
+ ---
2
+ createdAt: 2025-03-13
3
+ updatedAt: 2025-10-05
4
+ title: Plugin Sync JSON
5
+ description: Sincronizza i dizionari Intlayer con file JSON i18n di terze parti (i18next, next-intl, react-intl, vue-i18n e altri). Mantieni il tuo i18n esistente mentre usi Intlayer per gestire, tradurre e testare i tuoi messaggi.
6
+ keywords:
7
+ - Intlayer
8
+ - Sync JSON
9
+ - i18next
10
+ - next-intl
11
+ - react-intl
12
+ - vue-i18n
13
+ - next-translate
14
+ - nuxt-i18n
15
+ - LinguiJS
16
+ - Polyglot.js
17
+ - Solid-i18next
18
+ - svelte-i18n
19
+ - i18n
20
+ - traduzioni
21
+ slugs:
22
+ - doc
23
+ - plugin
24
+ - sync-json
25
+ history:
26
+ - version: 6.1.6
27
+ date: 2025-10-05
28
+ changes: Documentazione iniziale del plugin Sync JSON
29
+ ---
30
+
31
+ # Sync JSON (ponti i18n)
32
+
33
+ Usa Intlayer come componente aggiuntivo al tuo stack i18n esistente. Questo plugin mantiene i tuoi messaggi JSON sincronizzati con i dizionari Intlayer così puoi:
34
+
35
+ - Mantenere i18next, next-intl, react-intl, vue-i18n, next-translate, nuxt-i18n, Solid-i18next, svelte-i18n, ecc.
36
+ - Gestire e tradurre i tuoi messaggi con Intlayer (CLI, CI, provider, CMS), senza rifattorizzare la tua app.
37
+ - Pubblicare tutorial e contenuti SEO mirati a ogni ecosistema, suggerendo Intlayer come livello di gestione JSON.
38
+
39
+ Note e ambito attuale:
40
+
41
+ - L’esternalizzazione verso il CMS funziona per traduzioni e testo classico.
42
+ - Non è ancora supportato l’uso di inserimenti, plurali/ICU o funzionalità runtime avanzate di altre librerie.
43
+ - L’editor visuale non è ancora supportato per output i18n di terze parti.
44
+
45
+ ### Quando usare questo plugin
46
+
47
+ - Usi già una libreria i18n e memorizzi i messaggi in file JSON.
48
+ - Vuoi un completamento assistito da AI, test in CI e operazioni sui contenuti senza modificare il runtime di rendering.
49
+
50
+ ## Installazione
51
+
52
+ ```bash
53
+ pnpm add -D @intlayer/sync-json-plugin
54
+ # oppure
55
+ npm i -D @intlayer/sync-json-plugin
56
+ ```
57
+
58
+ ## Avvio rapido
59
+
60
+ Aggiungi il plugin al tuo `intlayer.config.ts` e indirizzalo alla tua struttura JSON esistente.
61
+
62
+ ```ts fileName="intlayer.config.ts"
63
+ import { defineConfig, Locales } from "intlayer";
64
+ import { syncJSON } from "@intlayer/sync-json-plugin";
65
+
66
+ export default defineConfig({
67
+ internationalization: {
68
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
69
+ defaultLocale: Locales.ENGLISH,
70
+ },
71
+
72
+ // Mantieni i tuoi file JSON attuali sincronizzati con i dizionari Intlayer
73
+ plugins: [
74
+ syncJSON({
75
+ // Layout per locale, per namespace (es. next-intl, i18next con namespaces)
76
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
77
+ }),
78
+ ],
79
+ });
80
+ ```
81
+
82
+ Alternativa: file singolo per locale (comune con configurazioni i18next/react-intl):
83
+
84
+ ```ts fileName="intlayer.config.ts"
85
+ plugins: [
86
+ syncJSON({
87
+ source: ({ locale }) => `./locales/${locale}.json`,
88
+ }),
89
+ ];
90
+ ```
91
+
92
+ ### Come funziona
93
+
94
+ - Lettura: il plugin individua i file JSON dal tuo builder `source` e li carica come dizionari Intlayer.
95
+ - Scrittura: dopo le build e i riempimenti, scrive i JSON localizzati negli stessi percorsi (con una newline finale per evitare problemi di formattazione).
96
+ - Auto‑fill: il plugin dichiara un percorso `autoFill` per ogni dizionario. Eseguendo `intlayer fill` aggiorna solo le traduzioni mancanti nei tuoi file JSON per impostazione predefinita.
97
+
98
+ API:
99
+
100
+ ```ts
101
+ syncJSON({
102
+ source: ({ key, locale }) => string, // richiesto
103
+ location?: string, // etichetta opzionale, predefinito: "plugin"
104
+ priority?: number, // priorità opzionale per la risoluzione dei conflitti, predefinito: 0
105
+ });
106
+ ```
107
+
108
+ ## Più sorgenti JSON e priorità
109
+
110
+ Puoi aggiungere più plugin `syncJSON` per sincronizzare diverse sorgenti JSON. Questo è utile quando hai più librerie i18n o diverse strutture JSON nel tuo progetto.
111
+
112
+ ### Sistema di priorità
113
+
114
+ Quando più plugin puntano alla stessa chiave del dizionario, il parametro `priority` determina quale plugin ha la precedenza:
115
+
116
+ - I numeri di priorità più alti prevalgono su quelli più bassi
117
+ - La priorità predefinita dei file `.content` è `0`
118
+ - La priorità predefinita dei file di contenuto dei plugin è `-1`
119
+ - I plugin con la stessa priorità vengono elaborati nell'ordine in cui appaiono nella configurazione
120
+
121
+ ```ts fileName="intlayer.config.ts"
122
+ import { defineConfig, Locales } from "intlayer";
123
+ import { syncJSON } from "@intlayer/sync-json-plugin";
124
+
125
+ export default defineConfig({
126
+ internationalization: {
127
+ locales: [Locales.ENGLISH, Locales.FRENCH],
128
+ defaultLocale: Locales.ENGLISH,
129
+ },
130
+
131
+ plugins: [
132
+ // Sorgente JSON primaria (priorità più alta)
133
+ syncJSON({
134
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
135
+ location: "main-translations",
136
+ priority: 10,
137
+ }),
138
+
139
+ // Sorgente JSON di fallback (priorità più bassa)
140
+ syncJSON({
141
+ source: ({ locale }) => `./fallback-locales/${locale}.json`,
142
+ location: "fallback-translations",
143
+ priority: 5,
144
+ }),
145
+
146
+ // Sorgente JSON legacy (priorità più bassa)
147
+ syncJSON({
148
+ source: ({ locale }) => `/my/other/app/legacy/${locale}/messages.json`,
149
+ location: "legacy-translations",
150
+ priority: 1,
151
+ }),
152
+ ],
153
+ });
154
+ ```
155
+
156
+ ### Risoluzione dei conflitti
157
+
158
+ Quando la stessa chiave di traduzione esiste in più sorgenti JSON:
159
+
160
+ 1. Il plugin con la priorità più alta determina il valore finale
161
+ 2. Le sorgenti con priorità inferiore vengono usate come fallback per le chiavi mancanti
162
+ 3. Questo permette di mantenere le traduzioni legacy mentre si migra gradualmente verso nuove strutture
163
+
164
+ ## Integrazioni
165
+
166
+ Di seguito sono riportate le mappature comuni. Mantieni il tuo runtime intatto; aggiungi solo il plugin.
167
+
168
+ ### i18next
169
+
170
+ Layout tipico dei file: `./public/locales/{locale}/{namespace}.json` o `./locales/{locale}/{namespace}.json`.
171
+
172
+ ```ts fileName="intlayer.config.ts"
173
+ import { syncJSON } from "@intlayer/sync-json-plugin";
174
+
175
+ export default {
176
+ plugins: [
177
+ syncJSON({
178
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
179
+ }),
180
+ ],
181
+ };
182
+ ```
183
+
184
+ ### next-intl
185
+
186
+ Messaggi JSON per locale (spesso `./messages/{locale}.json`) o per namespace.
187
+
188
+ ```ts fileName="intlayer.config.ts"
189
+ plugins: [
190
+ syncJSON({
191
+ source: ({ locale, key }) => `./messages/${locale}/${key}.json`,
192
+ }),
193
+ ];
194
+ ```
195
+
196
+ Vedi anche: `docs/it/intlayer_with_next-intl.md`.
197
+
198
+ ### react-intl
199
+
200
+ È comune un singolo JSON per locale:
201
+
202
+ ```ts fileName="intlayer.config.ts"
203
+ plugins: [
204
+ syncJSON({
205
+ source: ({ locale }) => `./locales/${locale}.json`,
206
+ }),
207
+ ];
208
+ ```
209
+
210
+ ### vue-i18n
211
+
212
+ Può essere un singolo file per locale o per namespace:
213
+
214
+ ```ts fileName="intlayer.config.ts"
215
+ plugins: [
216
+ syncJSON({
217
+ source: ({ key, locale }) => `./src/locales/${locale}/${key}.json`,
218
+ }),
219
+ ];
220
+ ```
221
+
222
+ ## CLI
223
+
224
+ I file JSON sincronizzati saranno considerati come altri file `.content`. Ciò significa che tutti i comandi di intlayer saranno disponibili per i file JSON sincronizzati. Inclusi:
225
+
226
+ - `intlayer content test` per verificare se ci sono traduzioni mancanti
227
+ - `intlayer content list` per elencare i file JSON sincronizzati
228
+ - `intlayer content fill` per completare le traduzioni mancanti
229
+ - `intlayer content push` per inviare i file JSON sincronizzati
230
+ - `intlayer content pull` per scaricare i file JSON sincronizzati
231
+
232
+ Vedi [Intlayer CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_cli.md) per maggiori dettagli.
233
+
234
+ ## Limitazioni (attuali)
235
+
236
+ - Nessun supporto per inserimenti o plurali/ICU quando si utilizzano librerie di terze parti.
237
+ - L'editor visuale non è ancora disponibile per runtime non Intlayer.
238
+ - Sincronizzazione solo di file JSON; i formati di catalogo non JSON non sono supportati.
239
+
240
+ ## Perché è importante
241
+
242
+ - Possiamo raccomandare soluzioni i18n consolidate e posizionare Intlayer come un componente aggiuntivo.
243
+ - Sfruttiamo la loro SEO/parole chiave con tutorial che terminano suggerendo Intlayer per gestire JSON.
244
+ - Espande il pubblico indirizzabile da “nuovi progetti” a “qualsiasi team che utilizza già i18n”.
@@ -413,23 +413,6 @@ Il sistema automaticamente:
413
413
 
414
414
  **Prima (v6):**
415
415
 
416
- ````typescript
417
- export default {
418
- #### Mappatura della configurazione
419
-
420
- | Configurazione v6 | Configurazione v7 |
421
- | ------------------------ | --------------------------------------------------- |
422
- | `autoFill: xxx` | `fill: xxx` |
423
- | `prefixDefault: false` | `mode: 'prefix-no-default'` |
424
- | `prefixDefault: true` | `mode: 'prefix-all'` |
425
- | `noPrefix: true` | `mode: 'no-prefix'` |
426
- | `cookieName: 'my-locale'`| `storage: { type: 'cookie', name: 'my-locale' }` |
427
- | `serverSetCookie: 'never'`| `storage: false` o rimuovere il cookie dall'array di storage |
428
-
429
- #### Esempio di migrazione
430
-
431
- **Prima (v6):**
432
-
433
416
  ```typescript
434
417
  export default {
435
418
  middleware: {
@@ -441,7 +424,7 @@ export default {
441
424
  noPrefix: false,
442
425
  },
443
426
  };
444
- ````
427
+ ```
445
428
 
446
429
  **Dopo (v7):**
447
430