@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: Wtyczka Sync JSON
5
+ description: Synchronizuj słowniki Intlayer z zewnętrznymi plikami JSON i18n (i18next, next-intl, react-intl, vue-i18n i inne). Zachowaj istniejące i18n, korzystając z Intlayer do zarządzania, tłumaczenia i testowania swoich komunikatów.
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
+ - tłumaczenia
21
+ slugs:
22
+ - doc
23
+ - plugin
24
+ - sync-json
25
+ history:
26
+ - version: 6.1.6
27
+ date: 2025-10-05
28
+ changes: Pierwsza dokumentacja wtyczki Sync JSON
29
+ ---
30
+
31
+ # Sync JSON (mosty i18n)
32
+
33
+ Użyj Intlayer jako dodatku do istniejącego stosu i18n. Ta wtyczka utrzymuje synchronizację Twoich komunikatów JSON ze słownikami Intlayer, dzięki czemu możesz:
34
+
35
+ - Zachować i18next, next-intl, react-intl, vue-i18n, next-translate, nuxt-i18n, Solid-i18next, svelte-i18n itp.
36
+ - Zarządzać i tłumaczyć swoje komunikaty za pomocą Intlayer (CLI, CI, dostawcy, CMS), bez konieczności refaktoryzacji aplikacji.
37
+ - Dostarczać samouczki i treści SEO skierowane do każdego ekosystemu, jednocześnie sugerując Intlayer jako warstwę zarządzania JSON.
38
+
39
+ Uwagi i obecny zakres:
40
+
41
+ - Eksport do CMS działa dla tłumaczeń i klasycznego tekstu.
42
+ - Brak jeszcze wsparcia dla wstawek, liczby mnogiej/ICU lub zaawansowanych funkcji czasu wykonywania innych bibliotek.
43
+ - Edytor wizualny nie jest jeszcze obsługiwany dla wyjść i18n zewnętrznych bibliotek.
44
+
45
+ ### Kiedy używać tej wtyczki
46
+
47
+ - Już korzystasz z biblioteki i18n i przechowujesz komunikaty w plikach JSON.
48
+ - Chcesz korzystać z wypełniania wspomaganego przez AI, testów w CI oraz operacji na treściach bez zmiany środowiska renderowania.
49
+
50
+ ## Instalacja
51
+
52
+ ```bash
53
+ pnpm add -D @intlayer/sync-json-plugin
54
+ # lub
55
+ npm i -D @intlayer/sync-json-plugin
56
+ ```
57
+
58
+ ## Szybki start
59
+
60
+ Dodaj wtyczkę do swojego pliku `intlayer.config.ts` i wskaż ją na istniejącą strukturę JSON.
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
+ // Synchronizuj swoje obecne pliki JSON ze słownikami Intlayer
73
+ plugins: [
74
+ syncJSON({
75
+ // Układ per-locale, per-namespace (np. next-intl, i18next z przestrzeniami nazw)
76
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
77
+ }),
78
+ ],
79
+ });
80
+ ```
81
+
82
+ Alternatywa: pojedynczy plik na locale (częste w konfiguracjach 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
+ ### Jak to działa
93
+
94
+ - Odczyt: wtyczka wykrywa pliki JSON zdefiniowane przez twój builder `source` i ładuje je jako słowniki Intlayer.
95
+ - Zapis: po budowaniu i wypełnianiu, zapisuje zlokalizowane pliki JSON z powrotem pod te same ścieżki (z końcowym znakiem nowej linii, aby uniknąć problemów z formatowaniem).
96
+ - Auto‑uzupełnianie: wtyczka deklaruje ścieżkę `autoFill` dla każdego słownika. Uruchomienie `intlayer fill` domyślnie aktualizuje tylko brakujące tłumaczenia w twoich plikach JSON.
97
+
98
+ API:
99
+
100
+ ```ts
101
+ syncJSON({
102
+ source: ({ key, locale }) => string, // wymagane
103
+ location?: string, // opcjonalna etykieta, domyślnie: "plugin"
104
+ priority?: number, // opcjonalny priorytet do rozstrzygania konfliktów, domyślnie: 0
105
+ });
106
+ ```
107
+
108
+ ## Wiele źródeł JSON i priorytet
109
+
110
+ Możesz dodać wiele wtyczek `syncJSON`, aby synchronizować różne źródła JSON. Jest to przydatne, gdy masz wiele bibliotek i18n lub różne struktury JSON w swoim projekcie.
111
+
112
+ ### System priorytetów
113
+
114
+ Gdy wiele wtyczek celuje w ten sam klucz słownika, parametr `priority` decyduje, która wtyczka ma pierwszeństwo:
115
+
116
+ - Wyższe liczby priorytetu mają przewagę nad niższymi
117
+ - Domyślny priorytet plików `.content` to `0`
118
+ - Domyślny priorytet plików zawartości wtyczek to `-1`
119
+ - Wtyczki o tym samym priorytecie są przetwarzane w kolejności, w jakiej pojawiają się w konfiguracji
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
+ // Główne źródło JSON (najwyższy priorytet)
133
+ syncJSON({
134
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
135
+ location: "main-translations",
136
+ priority: 10,
137
+ }),
138
+
139
+ // Zapasowe źródło JSON (niższy priorytet)
140
+ syncJSON({
141
+ source: ({ locale }) => `./fallback-locales/${locale}.json`,
142
+ location: "fallback-translations",
143
+ priority: 5,
144
+ }),
145
+
146
+ // Źródło JSON dziedziczone (najniższy priorytet)
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
+ ### Rozwiązywanie konfliktów
157
+
158
+ Gdy ten sam klucz tłumaczenia występuje w wielu źródłach JSON:
159
+
160
+ 1. Wtyczka o najwyższym priorytecie decyduje o ostatecznej wartości
161
+ 2. Źródła o niższym priorytecie są używane jako zapasowe dla brakujących kluczy
162
+ 3. Pozwala to na utrzymanie tłumaczeń dziedziczonych podczas stopniowej migracji do nowych struktur
163
+
164
+ ## Integracje
165
+
166
+ Poniżej znajdują się typowe mapowania. Zachowaj swój runtime bez zmian; dodaj tylko wtyczkę.
167
+
168
+ ### i18next
169
+
170
+ Typowy układ plików: `./public/locales/{locale}/{namespace}.json` lub `./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
+ Wiadomości JSON na locale (często `./messages/{locale}.json`) lub na 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
+ Zobacz także: `docs/pl/intlayer_with_next-intl.md`.
197
+
198
+ ### react-intl
199
+
200
+ Pojedynczy JSON na locale jest powszechny:
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
+ Może to być pojedynczy plik na locale lub na 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
+ Synchronizowane pliki JSON będą traktowane jak inne pliki `.content`. Oznacza to, że wszystkie polecenia intlayer będą dostępne dla synchronizowanych plików JSON. W tym:
225
+
226
+ - `intlayer content test` do testowania, czy brakuje tłumaczeń
227
+ - `intlayer content list` do wyświetlania listy synchronizowanych plików JSON
228
+ - `intlayer content fill` do uzupełniania brakujących tłumaczeń
229
+ - `intlayer content push` do wysyłania synchronizowanych plików JSON
230
+ - `intlayer content pull` do pobierania synchronizowanych plików JSON
231
+
232
+ Zobacz [Intlayer CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_cli.md) po więcej szczegółów.
233
+
234
+ ## Ograniczenia (aktualne)
235
+
236
+ - Brak wsparcia dla wstawek lub liczby mnogiej/ICU przy celowaniu w biblioteki firm trzecich.
237
+ - Edytor wizualny nie jest jeszcze dostępny dla środowisk uruchomieniowych innych niż Intlayer.
238
+ - Synchronizacja tylko plików JSON; formaty katalogów inne niż JSON nie są obsługiwane.
239
+
240
+ ## Dlaczego to ma znaczenie
241
+
242
+ - Możemy polecać sprawdzone rozwiązania i18n i pozycjonować Intlayer jako dodatek.
243
+ - Wykorzystujemy ich SEO/słowa kluczowe z tutorialami, które kończą się sugestią użycia Intlayer do zarządzania JSON.
244
+ - Rozszerza docelową grupę odbiorców z „nowych projektów” na „każdy zespół już korzystający z i18n”.
@@ -735,37 +735,6 @@ export default metadataContent;
735
735
  ```javascript fileName="src/app/[locale]/metadata.content.cjs" contentDeclarationFormat="commonjs"
736
736
  const { t } = require("intlayer");
737
737
 
738
- /** @type {import('intlayer').Dictionary<import('next').Metadata>} */
739
- const metadataContent = {
740
- key: "page-metadata",
741
- content: {
742
- title: t({
743
- en: "Create Next App",
744
- fr: "Créer une application Next.js",
745
- es: "Crear una aplicación Next.js",
746
- }),
747
- description: t({
748
- en: "Generated by create next app",
749
- fr: "Généré par create next app",
750
- es: "Generado por create next app",
751
- }),
752
- },
753
- };
754
-
755
- module.exports = metadataContent;
756
- fr: "Généré par create next app",
757
- es: "Generado por create next app",
758
- pt: "Gerado por create next app",
759
- }),
760
- },
761
- };
762
-
763
- export default metadataContent;
764
- ```
765
-
766
- ```javascript fileName="src/app/[locale]/metadata.content.cjs" contentDeclarationFormat="commonjs"
767
- const { t } = require("intlayer");
768
-
769
738
  /** @type {import('intlayer').Dictionary<import('next').Metadata>} */
770
739
  const metadataContent = {
771
740
  key: "page-metadata",
@@ -948,26 +917,6 @@ module.exports = { generateMetadata };
948
917
 
949
918
  Alternativamente, você pode usar a função `getTranslation` para declarar seus metadados. No entanto, é recomendável usar arquivos de declaração de conteúdo para automatizar a tradução dos seus metadados e externalizar o conteúdo em algum momento.
950
919
 
951
- ````typescript fileName="src/app/[locale]/layout.tsx or src/app/[locale]/page.tsx" codeFormat="typescript"
952
- import {
953
- type IConfigLocales,
954
- getTranslation,
955
- getMultilingualUrls,
956
- } from "intlayer";
957
- import type { Metadata } from "next";
958
- import type { LocalPromiseParams } from "next-intlayer";
959
-
960
- export const generateMetadata = async ({
961
- params,
962
- }: LocalPromiseParams): Promise<Metadata> => {
963
- const { locale } = await params;
964
- const t = <T>(content: IConfigLocales<T>) => getTranslation(content, locale);
965
-
966
- return {
967
- title: t<string>({
968
- en: "My title",
969
- Alternativamente, você pode usar a função `getTranslation` para declarar seus metadados. No entanto, é recomendado usar arquivos de declaração de conteúdo para automatizar a tradução dos seus metadados e externalizar o conteúdo em algum momento.
970
-
971
920
  ```typescript fileName="src/app/[locale]/layout.tsx or src/app/[locale]/page.tsx" codeFormat="typescript"
972
921
  import {
973
922
  type IConfigLocales,
@@ -998,7 +947,7 @@ export const generateMetadata = async ({
998
947
  };
999
948
 
1000
949
  // ... Resto do código
1001
- ````
950
+ ```
1002
951
 
1003
952
  ```javascript fileName="src/app/[locale]/layout.mjs or src/app/[locale]/page.mjs" codeFormat="esm"
1004
953
  import { getTranslation, getMultilingualUrls } from "intlayer";
@@ -0,0 +1,244 @@
1
+ ---
2
+ createdAt: 2025-03-13
3
+ updatedAt: 2025-10-05
4
+ title: Plugin Sync JSON
5
+ description: Sincronize os dicionários Intlayer com arquivos JSON i18n de terceiros (i18next, next-intl, react-intl, vue-i18n e mais). Mantenha seu i18n existente enquanto usa o Intlayer para gerenciar, traduzir e testar suas mensagens.
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
+ - traduções
21
+ slugs:
22
+ - doc
23
+ - plugin
24
+ - sync-json
25
+ history:
26
+ - version: 6.1.6
27
+ date: 2025-10-05
28
+ changes: Documentação inicial do plugin Sync JSON
29
+ ---
30
+
31
+ ## Sync JSON (pontes i18n)
32
+
33
+ Use o Intlayer como um complemento para sua pilha i18n existente. Este plugin mantém suas mensagens JSON sincronizadas com os dicionários Intlayer para que você possa:
34
+
35
+ - Manter i18next, next-intl, react-intl, vue-i18n, next-translate, nuxt-i18n, Solid-i18next, svelte-i18n, etc.
36
+ - Gerenciar e traduzir suas mensagens com o Intlayer (CLI, CI, provedores, CMS), sem precisar refatorar seu aplicativo.
37
+ - Publicar tutoriais e conteúdo SEO direcionado a cada ecossistema, enquanto sugere o Intlayer como a camada de gerenciamento JSON.
38
+
39
+ Notas e escopo atual:
40
+
41
+ - A externalização para o CMS funciona para traduções e texto clássico.
42
+ - Ainda não há suporte para inserções, plurais/ICU ou recursos avançados de tempo de execução de outras bibliotecas.
43
+ - O editor visual ainda não é suportado para saídas i18n de terceiros.
44
+
45
+ ### Quando usar este plugin
46
+
47
+ - Você já usa uma biblioteca i18n e armazena mensagens em arquivos JSON.
48
+ - Você deseja preenchimento assistido por IA, testes em CI e operações de conteúdo sem alterar seu tempo de execução de renderização.
49
+
50
+ ## Instalação
51
+
52
+ ```bash
53
+ pnpm add -D @intlayer/sync-json-plugin
54
+ # ou
55
+ npm i -D @intlayer/sync-json-plugin
56
+ ```
57
+
58
+ ## Início rápido
59
+
60
+ Adicione o plugin ao seu `intlayer.config.ts` e aponte para sua estrutura JSON existente.
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
+ // Mantenha seus arquivos JSON atuais sincronizados com os dicionários Intlayer
73
+ plugins: [
74
+ syncJSON({
75
+ // Layout por localidade, por namespace (por exemplo, next-intl, i18next com namespaces)
76
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
77
+ }),
78
+ ],
79
+ });
80
+ ```
81
+
82
+ Alternativa: arquivo único por localidade (comum em configurações 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
+ ### Como funciona
93
+
94
+ - Leitura: o plugin descobre arquivos JSON a partir do seu construtor `source` e os carrega como dicionários Intlayer.
95
+ - Escrita: após builds e preenchimentos, ele grava o JSON localizado de volta nos mesmos caminhos (com uma nova linha final para evitar problemas de formatação).
96
+ - Auto-preenchimento: o plugin declara um caminho `autoFill` para cada dicionário. Executar `intlayer fill` atualiza apenas as traduções ausentes nos seus arquivos JSON por padrão.
97
+
98
+ API:
99
+
100
+ ```ts
101
+ syncJSON({
102
+ source: ({ key, locale }) => string, // obrigatório
103
+ location?: string, // rótulo opcional, padrão: "plugin"
104
+ priority?: number, // prioridade opcional para resolução de conflitos, padrão: 0
105
+ });
106
+ ```
107
+
108
+ ## Múltiplas fontes JSON e prioridade
109
+
110
+ Você pode adicionar múltiplos plugins `syncJSON` para sincronizar diferentes fontes JSON. Isso é útil quando você tem múltiplas bibliotecas i18n ou diferentes estruturas JSON no seu projeto.
111
+
112
+ ### Sistema de prioridade
113
+
114
+ Quando múltiplos plugins têm como alvo a mesma chave de dicionário, o parâmetro `priority` determina qual plugin tem precedência:
115
+
116
+ - Números de prioridade mais altos ganham sobre os mais baixos
117
+ - Prioridade padrão dos arquivos `.content` é `0`
118
+ - Prioridade padrão dos arquivos de conteúdo dos plugins é `-1`
119
+ - Plugins com a mesma prioridade são processados na ordem em que aparecem na configuração
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
+ // Fonte JSON principal (maior prioridade)
133
+ syncJSON({
134
+ source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
135
+ location: "main-translations",
136
+ priority: 10,
137
+ }),
138
+
139
+ // Fonte JSON de fallback (prioridade menor)
140
+ syncJSON({
141
+ source: ({ locale }) => `./fallback-locales/${locale}.json`,
142
+ location: "fallback-translations",
143
+ priority: 5,
144
+ }),
145
+
146
+ // Fonte JSON legado (prioridade mais baixa)
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
+ ### Resolução de conflitos
157
+
158
+ Quando a mesma chave de tradução existe em múltiplas fontes JSON:
159
+
160
+ 1. O plugin com a maior prioridade determina o valor final
161
+ 2. Fontes com prioridade menor são usadas como fallback para chaves ausentes
162
+ 3. Isso permite manter traduções legadas enquanto migra gradualmente para novas estruturas
163
+
164
+ ## Integrações
165
+
166
+ Abaixo estão mapeamentos comuns. Mantenha seu runtime intacto; apenas adicione o plugin.
167
+
168
+ ### i18next
169
+
170
+ Layout típico de arquivo: `./public/locales/{locale}/{namespace}.json` ou `./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
+ Mensagens JSON por localidade (frequentemente `./messages/{locale}.json`) ou por 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
+ Veja também: `docs/pt/intlayer_with_next-intl.md`.
197
+
198
+ ### react-intl
199
+
200
+ JSON único por localidade é comum:
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
+ Pode ser um único arquivo por localidade ou por 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
+ Os arquivos JSON sincronizados serão considerados como outros arquivos `.content`. Isso significa que todos os comandos do intlayer estarão disponíveis para os arquivos JSON sincronizados. Incluindo:
225
+
226
+ - `intlayer content test` para testar se há traduções faltando
227
+ - `intlayer content list` para listar os arquivos JSON sincronizados
228
+ - `intlayer content fill` para preencher as traduções faltantes
229
+ - `intlayer content push` para enviar os arquivos JSON sincronizados
230
+ - `intlayer content pull` para puxar os arquivos JSON sincronizados
231
+
232
+ Veja [Intlayer CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_cli.md) para mais detalhes.
233
+
234
+ ## Limitações (atuais)
235
+
236
+ - Sem suporte para inserções ou plurais/ICU ao direcionar bibliotecas de terceiros.
237
+ - Editor visual ainda não disponível para runtimes que não sejam Intlayer.
238
+ - Sincronização apenas de JSON; formatos de catálogo não JSON não são suportados.
239
+
240
+ ## Por que isso importa
241
+
242
+ - Podemos recomendar soluções i18n consolidadas e posicionar o Intlayer como um complemento.
243
+ - Aproveitamos o SEO/palavras-chave delas com tutoriais que terminam sugerindo o Intlayer para gerenciar JSON.
244
+ - Expande o público-alvo de “novos projetos” para “qualquer equipe que já usa i18n”.