@intlayer/docs 7.0.4-canary.0 → 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.
- package/blog/ar/intlayer_with_i18next.md +68 -106
- package/blog/ar/intlayer_with_next-i18next.md +84 -288
- package/blog/ar/intlayer_with_next-intl.md +58 -337
- package/blog/ar/intlayer_with_react-i18next.md +68 -290
- package/blog/ar/intlayer_with_react-intl.md +63 -266
- package/blog/de/intlayer_with_i18next.md +77 -97
- package/blog/de/intlayer_with_next-i18next.md +69 -296
- package/blog/de/intlayer_with_next-intl.md +59 -340
- package/blog/de/intlayer_with_react-i18next.md +68 -290
- package/blog/de/intlayer_with_react-intl.md +62 -264
- package/blog/en/intlayer_with_i18next.md +36 -1638
- package/blog/en/intlayer_with_next-i18next.md +22 -847
- package/blog/en/intlayer_with_next-intl.md +32 -1053
- package/blog/en/intlayer_with_react-i18next.md +38 -764
- package/blog/en/intlayer_with_react-intl.md +42 -1018
- package/blog/en-GB/intlayer_with_i18next.md +67 -103
- package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
- package/blog/en-GB/intlayer_with_next-intl.md +58 -337
- package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
- package/blog/en-GB/intlayer_with_react-intl.md +61 -264
- package/blog/es/intlayer_with_i18next.md +67 -103
- package/blog/es/intlayer_with_next-i18next.md +71 -296
- package/blog/es/intlayer_with_next-intl.md +57 -338
- package/blog/es/intlayer_with_react-i18next.md +68 -290
- package/blog/es/intlayer_with_react-intl.md +62 -265
- package/blog/fr/intlayer_with_i18next.md +66 -104
- package/blog/fr/intlayer_with_next-i18next.md +82 -285
- package/blog/fr/intlayer_with_next-intl.md +57 -338
- package/blog/fr/intlayer_with_react-i18next.md +67 -289
- package/blog/fr/intlayer_with_react-intl.md +61 -264
- package/blog/hi/intlayer_with_i18next.md +68 -104
- package/blog/hi/intlayer_with_next-i18next.md +74 -299
- package/blog/hi/intlayer_with_next-intl.md +57 -239
- package/blog/hi/intlayer_with_react-i18next.md +69 -291
- package/blog/hi/intlayer_with_react-intl.md +65 -268
- package/blog/id/intlayer_with_i18next.md +126 -0
- package/blog/id/intlayer_with_next-i18next.md +142 -0
- package/blog/id/intlayer_with_next-intl.md +113 -0
- package/blog/id/intlayer_with_react-i18next.md +124 -0
- package/blog/id/intlayer_with_react-intl.md +122 -0
- package/blog/it/intlayer_with_i18next.md +67 -103
- package/blog/it/intlayer_with_next-i18next.md +71 -296
- package/blog/it/intlayer_with_next-intl.md +57 -338
- package/blog/it/intlayer_with_react-i18next.md +68 -290
- package/blog/it/intlayer_with_react-intl.md +62 -265
- package/blog/ja/intlayer_with_i18next.md +68 -103
- package/blog/ja/intlayer_with_next-i18next.md +85 -283
- package/blog/ja/intlayer_with_next-intl.md +58 -336
- package/blog/ja/intlayer_with_react-i18next.md +68 -290
- package/blog/ja/intlayer_with_react-intl.md +62 -264
- package/blog/ko/intlayer_with_i18next.md +80 -96
- package/blog/ko/intlayer_with_next-i18next.md +85 -287
- package/blog/ko/intlayer_with_next-intl.md +68 -327
- package/blog/ko/intlayer_with_react-i18next.md +68 -290
- package/blog/ko/intlayer_with_react-intl.md +64 -266
- package/blog/pl/intlayer_with_i18next.md +126 -0
- package/blog/pl/intlayer_with_next-i18next.md +142 -0
- package/blog/pl/intlayer_with_next-intl.md +111 -0
- package/blog/pl/intlayer_with_react-i18next.md +124 -0
- package/blog/pl/intlayer_with_react-intl.md +122 -0
- package/blog/pt/intlayer_with_i18next.md +67 -103
- package/blog/pt/intlayer_with_next-i18next.md +72 -293
- package/blog/pt/intlayer_with_next-intl.md +57 -256
- package/blog/pt/intlayer_with_react-i18next.md +104 -78
- package/blog/pt/intlayer_with_react-intl.md +62 -266
- package/blog/ru/intlayer_with_i18next.md +66 -104
- package/blog/ru/intlayer_with_next-i18next.md +71 -296
- package/blog/ru/intlayer_with_next-intl.md +58 -337
- package/blog/ru/intlayer_with_react-i18next.md +68 -290
- package/blog/ru/intlayer_with_react-intl.md +62 -265
- package/blog/tr/intlayer_with_i18next.md +71 -107
- package/blog/tr/intlayer_with_next-i18next.md +72 -297
- package/blog/tr/intlayer_with_next-intl.md +58 -339
- package/blog/tr/intlayer_with_react-i18next.md +69 -291
- package/blog/tr/intlayer_with_react-intl.md +63 -285
- package/blog/vi/intlayer_with_i18next.md +126 -0
- package/blog/vi/intlayer_with_next-i18next.md +142 -0
- package/blog/vi/intlayer_with_next-intl.md +111 -0
- package/blog/vi/intlayer_with_react-i18next.md +124 -0
- package/blog/vi/intlayer_with_react-intl.md +122 -0
- package/blog/zh/intlayer_with_i18next.md +67 -102
- package/blog/zh/intlayer_with_next-i18next.md +72 -296
- package/blog/zh/intlayer_with_next-intl.md +58 -336
- package/blog/zh/intlayer_with_react-i18next.md +68 -290
- package/blog/zh/intlayer_with_react-intl.md +63 -106
- package/docs/ar/plugins/sync-json.md +244 -0
- package/docs/de/plugins/sync-json.md +244 -0
- package/docs/en/intlayer_cli.md +25 -0
- package/docs/en/intlayer_with_nextjs_14.md +2 -0
- package/docs/en/intlayer_with_nextjs_15.md +2 -0
- package/docs/en/intlayer_with_nextjs_16.md +2 -0
- package/docs/en/plugins/sync-json.md +1 -1
- package/docs/en-GB/plugins/sync-json.md +244 -0
- package/docs/es/plugins/sync-json.md +244 -0
- package/docs/fr/plugins/sync-json.md +244 -0
- package/docs/hi/plugins/sync-json.md +244 -0
- package/docs/id/plugins/sync-json.md +244 -0
- package/docs/it/plugins/sync-json.md +244 -0
- package/docs/ja/plugins/sync-json.md +244 -0
- package/docs/ko/plugins/sync-json.md +244 -0
- package/docs/pl/plugins/sync-json.md +244 -0
- package/docs/pt/plugins/sync-json.md +244 -0
- package/docs/ru/plugins/sync-json.md +244 -0
- package/docs/tr/plugins/sync-json.md +245 -0
- package/docs/vi/plugins/sync-json.md +244 -0
- package/docs/zh/plugins/sync-json.md +244 -0
- package/package.json +14 -14
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-03-13
|
|
3
|
+
updatedAt: 2025-10-05
|
|
4
|
+
title: مكون مزامنة JSON
|
|
5
|
+
description: مزامنة قواميس Intlayer مع ملفات JSON الخاصة بالتدويل من طرف ثالث (i18next، next-intl، react-intl، vue-i18n، والمزيد). احتفظ بنظام التدويل الحالي لديك أثناء استخدام Intlayer لإدارة وترجمة واختبار رسائلك.
|
|
6
|
+
keywords:
|
|
7
|
+
- Intlayer
|
|
8
|
+
- مزامنة 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
|
+
- الترجمات
|
|
21
|
+
slugs:
|
|
22
|
+
- doc
|
|
23
|
+
- plugin
|
|
24
|
+
- sync-json
|
|
25
|
+
history:
|
|
26
|
+
- version: 6.1.6
|
|
27
|
+
date: 2025-10-05
|
|
28
|
+
changes: الوثائق الأولية لمكون مزامنة JSON
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## مزامنة JSON (جسور التدويل)
|
|
32
|
+
|
|
33
|
+
استخدم Intlayer كمكون إضافي إلى نظام التدويل (i18n) الحالي لديك. يحافظ هذا المكون على مزامنة رسائل JSON الخاصة بك مع قواميس Intlayer بحيث يمكنك:
|
|
34
|
+
|
|
35
|
+
- الاحتفاظ بـ i18next، next-intl، react-intl، vue-i18n، next-translate، nuxt-i18n، Solid-i18next، svelte-i18n، وغيرها.
|
|
36
|
+
- إدارة وترجمة رسائلك باستخدام Intlayer (CLI، CI، المزودين، نظام إدارة المحتوى)، دون الحاجة لإعادة هيكلة تطبيقك.
|
|
37
|
+
- نشر الدروس ومحتوى تحسين محركات البحث (SEO) المستهدف لكل نظام بيئي، مع اقتراح Intlayer كطبقة لإدارة JSON.
|
|
38
|
+
|
|
39
|
+
ملاحظات ونطاق العمل الحالي:
|
|
40
|
+
|
|
41
|
+
- التصدير إلى نظام إدارة المحتوى يعمل للترجمات والنصوص التقليدية.
|
|
42
|
+
- لا يوجد دعم حتى الآن للإدخالات، الجمع/ICU، أو الميزات المتقدمة في وقت التشغيل لمكتبات أخرى.
|
|
43
|
+
- محرر الواجهة البصرية غير مدعوم حتى الآن لمخرجات التدويل من طرف ثالث.
|
|
44
|
+
|
|
45
|
+
### متى تستخدم هذا المكون
|
|
46
|
+
|
|
47
|
+
- أنت تستخدم بالفعل مكتبة i18n وتخزن الرسائل في ملفات JSON.
|
|
48
|
+
- تريد ملء بمساعدة الذكاء الاصطناعي، واختبار في CI، وعمليات المحتوى دون تغيير وقت تشغيل العرض الخاص بك.
|
|
49
|
+
|
|
50
|
+
## التثبيت
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm add -D @intlayer/sync-json-plugin
|
|
54
|
+
# أو
|
|
55
|
+
npm i -D @intlayer/sync-json-plugin
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## بداية سريعة
|
|
59
|
+
|
|
60
|
+
أضف المكون الإضافي إلى ملف `intlayer.config.ts` وأشر إلى هيكل 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
|
+
// حافظ على مزامنة ملفات JSON الحالية مع قواميس Intlayer
|
|
73
|
+
plugins: [
|
|
74
|
+
syncJSON({
|
|
75
|
+
// تخطيط لكل لغة ولكل مساحة أسماء (مثل next-intl، i18next مع مساحات الأسماء)
|
|
76
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
77
|
+
}),
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
البديل: ملف واحد لكل لغة (شائع مع إعدادات 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
|
+
### كيف يعمل
|
|
93
|
+
|
|
94
|
+
- القراءة: يكتشف المكون الإضافي ملفات JSON من منشئ `source` الخاص بك ويحمّلها كقواميس Intlayer.
|
|
95
|
+
- الكتابة: بعد عمليات البناء والملء، يكتب ملفات JSON المحلية مرة أخرى إلى نفس المسارات (مع سطر جديد نهائي لتجنب مشاكل التنسيق).
|
|
96
|
+
- الملء التلقائي: يعلن المكون الإضافي عن مسار `autoFill` لكل قاموس. تشغيل الأمر `intlayer fill` يقوم بتحديث الترجمات المفقودة فقط في ملفات JSON الخاصة بك بشكل افتراضي.
|
|
97
|
+
|
|
98
|
+
واجهة برمجة التطبيقات (API):
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
syncJSON({
|
|
102
|
+
source: ({ key, locale }) => string, // مطلوب
|
|
103
|
+
location?: string, // تسمية اختيارية، الافتراضي: "plugin"
|
|
104
|
+
priority?: number, // أولوية اختيارية لحل التعارضات، الافتراضي: 0
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## مصادر JSON متعددة والأولوية
|
|
109
|
+
|
|
110
|
+
يمكنك إضافة عدة مكونات إضافية `syncJSON` لمزامنة مصادر JSON مختلفة. هذا مفيد عندما يكون لديك مكتبات i18n متعددة أو هياكل JSON مختلفة في مشروعك.
|
|
111
|
+
|
|
112
|
+
### نظام الأولوية
|
|
113
|
+
|
|
114
|
+
عندما تستهدف عدة مكونات إضافية نفس مفتاح القاموس، يحدد معامل `priority` أي مكون إضافي له الأسبقية:
|
|
115
|
+
|
|
116
|
+
- الأرقام الأعلى في الأولوية تفوز على الأقل منها
|
|
117
|
+
- الأولوية الافتراضية لملفات `.content` هي `0`
|
|
118
|
+
- الأولوية الافتراضية لملفات محتوى المكونات الإضافية هي `-1`
|
|
119
|
+
- تتم معالجة المكونات الإضافية التي لها نفس الأولوية بالترتيب الذي تظهر به في التكوين
|
|
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
|
+
// المصدر الأساسي لملفات JSON (الأولوية الأعلى)
|
|
133
|
+
syncJSON({
|
|
134
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
135
|
+
location: "main-translations",
|
|
136
|
+
priority: 10,
|
|
137
|
+
}),
|
|
138
|
+
|
|
139
|
+
// المصدر الاحتياطي لملفات JSON (أولوية أقل)
|
|
140
|
+
syncJSON({
|
|
141
|
+
source: ({ locale }) => `./fallback-locales/${locale}.json`,
|
|
142
|
+
location: "fallback-translations",
|
|
143
|
+
priority: 5,
|
|
144
|
+
}),
|
|
145
|
+
|
|
146
|
+
// المصدر القديم لملفات JSON (الأولوية الأدنى)
|
|
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
|
+
### حل النزاعات
|
|
157
|
+
|
|
158
|
+
عندما يوجد نفس مفتاح الترجمة في مصادر JSON متعددة:
|
|
159
|
+
|
|
160
|
+
1. يحدد المكون الإضافي ذو الأولوية الأعلى القيمة النهائية
|
|
161
|
+
2. تُستخدم المصادر ذات الأولوية الأقل كاحتياطيات للمفاتيح المفقودة
|
|
162
|
+
3. يتيح لك هذا الحفاظ على الترجمات القديمة أثناء الترحيل التدريجي إلى الهياكل الجديدة
|
|
163
|
+
|
|
164
|
+
## التكاملات
|
|
165
|
+
|
|
166
|
+
فيما يلي الخرائط الشائعة. احتفظ ببيئة التشغيل الخاصة بك دون تغيير؛ فقط أضف المكون الإضافي.
|
|
167
|
+
|
|
168
|
+
### i18next
|
|
169
|
+
|
|
170
|
+
تخطيط الملف النموذجي: `./public/locales/{locale}/{namespace}.json` أو `./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
|
+
رسائل JSON لكل لغة (غالبًا `./messages/{locale}.json`) أو لكل مساحة أسماء.
|
|
187
|
+
|
|
188
|
+
```ts fileName="intlayer.config.ts"
|
|
189
|
+
plugins: [
|
|
190
|
+
syncJSON({
|
|
191
|
+
source: ({ locale, key }) => `./messages/${locale}/${key}.json`,
|
|
192
|
+
}),
|
|
193
|
+
];
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
انظر أيضًا: `docs/ar/intlayer_with_next-intl.md`.
|
|
197
|
+
|
|
198
|
+
### react-intl
|
|
199
|
+
|
|
200
|
+
عادةً ما يكون ملف JSON واحد لكل لغة:
|
|
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
|
+
إما ملف واحد لكل لغة أو لكل مساحة أسماء:
|
|
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
|
+
سيتم اعتبار ملفات JSON المتزامنة كملفات `.content` أخرى. هذا يعني أن جميع أوامر intlayer ستكون متاحة لملفات JSON المتزامنة. بما في ذلك:
|
|
225
|
+
|
|
226
|
+
- `intlayer content test` لاختبار ما إذا كانت هناك ترجمات مفقودة
|
|
227
|
+
- `intlayer content list` لعرض قائمة ملفات JSON المتزامنة
|
|
228
|
+
- `intlayer content fill` لملء الترجمات المفقودة
|
|
229
|
+
- `intlayer content push` لدفع ملفات JSON المتزامنة
|
|
230
|
+
- `intlayer content pull` لسحب ملفات JSON المتزامنة
|
|
231
|
+
|
|
232
|
+
راجع [Intlayer CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/intlayer_cli.md) لمزيد من التفاصيل.
|
|
233
|
+
|
|
234
|
+
## القيود (الحالية)
|
|
235
|
+
|
|
236
|
+
- لا توجد إدخالات أو دعم للجمع/ICU عند استهداف مكتبات الطرف الثالث.
|
|
237
|
+
- محرر بصري غير متوفر بعد لبيئات التشغيل غير الخاصة بـ Intlayer.
|
|
238
|
+
- مزامنة JSON فقط؛ تنسيقات الكتالوج غير JSON غير مدعومة.
|
|
239
|
+
|
|
240
|
+
## لماذا هذا مهم
|
|
241
|
+
|
|
242
|
+
- يمكننا التوصية بحلول i18n المعروفة ووضع Intlayer كإضافة.
|
|
243
|
+
- نستفيد من تحسين محركات البحث/الكلمات المفتاحية الخاصة بهم مع الدروس التي تنتهي باقتراح استخدام Intlayer لإدارة JSON.
|
|
244
|
+
- يوسع الجمهور المستهدف من "المشاريع الجديدة" إلى "أي فريق يستخدم i18n بالفعل".
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-03-13
|
|
3
|
+
updatedAt: 2025-10-05
|
|
4
|
+
title: Sync JSON Plugin
|
|
5
|
+
description: Synchronisieren Sie Intlayer-Wörterbücher mit Drittanbieter-i18n-JSON-Dateien (i18next, next-intl, react-intl, vue-i18n und mehr). Behalten Sie Ihr bestehendes i18n bei und verwenden Sie Intlayer, um Ihre Nachrichten zu verwalten, zu übersetzen und zu testen.
|
|
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
|
+
- Übersetzungen
|
|
21
|
+
slugs:
|
|
22
|
+
- doc
|
|
23
|
+
- plugin
|
|
24
|
+
- sync-json
|
|
25
|
+
history:
|
|
26
|
+
- version: 6.1.6
|
|
27
|
+
date: 2025-10-05
|
|
28
|
+
changes: Erste Dokumentation des Sync JSON Plugins
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# Sync JSON (i18n-Brücken)
|
|
32
|
+
|
|
33
|
+
Verwenden Sie Intlayer als Ergänzung zu Ihrem bestehenden i18n-Stack. Dieses Plugin hält Ihre JSON-Nachrichten mit den Intlayer-Wörterbüchern synchron, sodass Sie:
|
|
34
|
+
|
|
35
|
+
- i18next, next-intl, react-intl, vue-i18n, next-translate, nuxt-i18n, Solid-i18next, svelte-i18n usw. beibehalten können.
|
|
36
|
+
- Ihre Nachrichten mit Intlayer (CLI, CI, Anbieter, CMS) verwalten und übersetzen, ohne Ihre App umzustrukturieren.
|
|
37
|
+
- Tutorials und SEO-Inhalte für jedes Ökosystem bereitstellen und gleichzeitig Intlayer als JSON-Verwaltungsschicht vorschlagen.
|
|
38
|
+
|
|
39
|
+
Hinweise und aktueller Umfang:
|
|
40
|
+
|
|
41
|
+
- Die Externalisierung zum CMS funktioniert für Übersetzungen und klassischen Text.
|
|
42
|
+
- Noch keine Unterstützung für Einfügungen, Pluralformen/ICU oder erweiterte Laufzeitfunktionen anderer Bibliotheken.
|
|
43
|
+
- Der visuelle Editor wird für Ausgaben von Drittanbieter-i18n noch nicht unterstützt.
|
|
44
|
+
|
|
45
|
+
### Wann Sie dieses Plugin verwenden sollten
|
|
46
|
+
|
|
47
|
+
- Sie verwenden bereits eine i18n-Bibliothek und speichern Nachrichten in JSON-Dateien.
|
|
48
|
+
- Sie möchten KI-unterstütztes Ausfüllen, Tests in CI und Content-Operationen durchführen, ohne Ihre Rendering-Laufzeit zu ändern.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm add -D @intlayer/sync-json-plugin
|
|
54
|
+
# oder
|
|
55
|
+
npm i -D @intlayer/sync-json-plugin
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Schnellstart
|
|
59
|
+
|
|
60
|
+
Fügen Sie das Plugin zu Ihrer `intlayer.config.ts` hinzu und verweisen Sie auf Ihre bestehende JSON-Struktur.
|
|
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
|
+
// Halten Sie Ihre aktuellen JSON-Dateien mit den Intlayer-Wörterbüchern synchron
|
|
73
|
+
plugins: [
|
|
74
|
+
syncJSON({
|
|
75
|
+
// Pro-Locale, pro-Namespace Layout (z.B. next-intl, i18next mit Namespaces)
|
|
76
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
77
|
+
}),
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Alternative: Einzelne Datei pro Locale (häufig bei i18next/react-intl Setups):
|
|
83
|
+
|
|
84
|
+
```ts fileName="intlayer.config.ts"
|
|
85
|
+
plugins: [
|
|
86
|
+
syncJSON({
|
|
87
|
+
source: ({ locale }) => `./locales/${locale}.json`,
|
|
88
|
+
}),
|
|
89
|
+
];
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Funktionsweise
|
|
93
|
+
|
|
94
|
+
- Lesen: Das Plugin entdeckt JSON-Dateien über Ihren `source`-Builder und lädt sie als Intlayer-Wörterbücher.
|
|
95
|
+
- Schreiben: Nach dem Build und Ausfüllen schreibt es die lokalisierten JSON-Dateien zurück an dieselben Pfade (mit einer abschließenden neuen Zeile, um Formatierungsprobleme zu vermeiden).
|
|
96
|
+
- Auto-Fill: Das Plugin deklariert einen `autoFill`-Pfad für jedes Wörterbuch. Das Ausführen von `intlayer fill` aktualisiert standardmäßig nur fehlende Übersetzungen in Ihren JSON-Dateien.
|
|
97
|
+
|
|
98
|
+
API:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
syncJSON({
|
|
102
|
+
source: ({ key, locale }) => string, // erforderlich
|
|
103
|
+
location?: string, // optionales Label, Standard: "plugin"
|
|
104
|
+
priority?: number, // optionale Priorität zur Konfliktlösung, Standard: 0
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Mehrere JSON-Quellen und Priorität
|
|
109
|
+
|
|
110
|
+
Sie können mehrere `syncJSON`-Plugins hinzufügen, um verschiedene JSON-Quellen zu synchronisieren. Dies ist nützlich, wenn Sie mehrere i18n-Bibliotheken oder unterschiedliche JSON-Strukturen in Ihrem Projekt haben.
|
|
111
|
+
|
|
112
|
+
### Prioritätssystem
|
|
113
|
+
|
|
114
|
+
Wenn mehrere Plugins denselben Wörterbuchschlüssel ansprechen, bestimmt der Parameter `priority`, welches Plugin Vorrang hat:
|
|
115
|
+
|
|
116
|
+
- Höhere Prioritätszahlen haben Vorrang vor niedrigeren
|
|
117
|
+
- Die Standardpriorität von `.content`-Dateien ist `0`
|
|
118
|
+
- Die Standardpriorität von Plugin-Content-Dateien ist `-1`
|
|
119
|
+
- Plugins mit derselben Priorität werden in der Reihenfolge verarbeitet, in der sie in der Konfiguration erscheinen
|
|
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
|
+
// Primäre JSON-Quelle (höchste Priorität)
|
|
133
|
+
syncJSON({
|
|
134
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
135
|
+
location: "main-translations",
|
|
136
|
+
priority: 10,
|
|
137
|
+
}),
|
|
138
|
+
|
|
139
|
+
// Fallback-JSON-Quelle (niedrigere Priorität)
|
|
140
|
+
syncJSON({
|
|
141
|
+
source: ({ locale }) => `./fallback-locales/${locale}.json`,
|
|
142
|
+
location: "fallback-translations",
|
|
143
|
+
priority: 5,
|
|
144
|
+
}),
|
|
145
|
+
|
|
146
|
+
// Legacy-JSON-Quelle (niedrigste Priorität)
|
|
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
|
+
### Konfliktlösung
|
|
157
|
+
|
|
158
|
+
Wenn derselbe Übersetzungsschlüssel in mehreren JSON-Quellen vorhanden ist:
|
|
159
|
+
|
|
160
|
+
1. Bestimmt das Plugin mit der höchsten Priorität den endgültigen Wert
|
|
161
|
+
2. Werden Quellen mit niedrigerer Priorität als Fallbacks für fehlende Schlüssel verwendet
|
|
162
|
+
3. Ermöglicht es Ihnen, Legacy-Übersetzungen beizubehalten und gleichzeitig schrittweise auf neue Strukturen umzusteigen
|
|
163
|
+
|
|
164
|
+
## Integrationen
|
|
165
|
+
|
|
166
|
+
Nachfolgend sind gängige Zuordnungen aufgeführt. Belassen Sie Ihre Laufzeit unverändert; fügen Sie nur das Plugin hinzu.
|
|
167
|
+
|
|
168
|
+
### i18next
|
|
169
|
+
|
|
170
|
+
Typische Dateistruktur: `./public/locales/{locale}/{namespace}.json` oder `./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
|
+
JSON-Nachrichten pro Locale (oft `./messages/{locale}.json`) oder pro 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
|
+
Siehe auch: `docs/de/intlayer_with_next-intl.md`.
|
|
197
|
+
|
|
198
|
+
### react-intl
|
|
199
|
+
|
|
200
|
+
Einzelne JSON-Datei pro Locale ist üblich:
|
|
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
|
+
Entweder eine einzelne Datei pro Locale oder pro 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
|
+
Die synchronisierten JSON-Dateien werden wie andere `.content`-Dateien behandelt. Das bedeutet, dass alle intlayer-Befehle für die synchronisierten JSON-Dateien verfügbar sind. Einschließlich:
|
|
225
|
+
|
|
226
|
+
- `intlayer content test`, um zu testen, ob Übersetzungen fehlen
|
|
227
|
+
- `intlayer content list`, um die synchronisierten JSON-Dateien aufzulisten
|
|
228
|
+
- `intlayer content fill`, um fehlende Übersetzungen zu ergänzen
|
|
229
|
+
- `intlayer content push`, um die synchronisierten JSON-Dateien zu pushen
|
|
230
|
+
- `intlayer content pull`, um die synchronisierten JSON-Dateien zu pullen
|
|
231
|
+
|
|
232
|
+
Siehe [Intlayer CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/intlayer_cli.md) für weitere Details.
|
|
233
|
+
|
|
234
|
+
## Einschränkungen (aktuell)
|
|
235
|
+
|
|
236
|
+
- Keine Unterstützung für Einfügungen oder Pluralformen/ICU bei der Verwendung von Drittanbieter-Bibliotheken.
|
|
237
|
+
- Visueller Editor ist für Nicht-Intlayer-Laufzeiten noch nicht verfügbar.
|
|
238
|
+
- Nur JSON-Synchronisierung; Nicht-JSON-Katalogformate werden nicht unterstützt.
|
|
239
|
+
|
|
240
|
+
## Warum das wichtig ist
|
|
241
|
+
|
|
242
|
+
- Wir können etablierte i18n-Lösungen empfehlen und Intlayer als Zusatzmodul positionieren.
|
|
243
|
+
- Wir nutzen deren SEO/Schlüsselwörter mit Tutorials, die abschließend vorschlagen, Intlayer zur Verwaltung von JSON einzusetzen.
|
|
244
|
+
- Erweitert die ansprechbare Zielgruppe von „neuen Projekten“ auf „jedes Team, das bereits i18n verwendet“.
|
package/docs/en/intlayer_cli.md
CHANGED
|
@@ -150,6 +150,10 @@ This command will find your declaration content files as default as `./src/**/*.
|
|
|
150
150
|
|
|
151
151
|
> Example: `npx intlayer build --skip-prepare`
|
|
152
152
|
|
|
153
|
+
- **`--no-cache`**: Disable the cache.
|
|
154
|
+
|
|
155
|
+
> Example: `npx intlayer build --no-cache`
|
|
156
|
+
|
|
153
157
|
### Watch dictionaries
|
|
154
158
|
|
|
155
159
|
```bash
|
|
@@ -203,6 +207,10 @@ If [intlayer editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/
|
|
|
203
207
|
|
|
204
208
|
> Example: `npx intlayer dictionary push --env-file .env.production.local`
|
|
205
209
|
|
|
210
|
+
- **`--no-cache`**: Disable the cache.
|
|
211
|
+
|
|
212
|
+
> Example: `npx intlayer build --no-cache`
|
|
213
|
+
|
|
206
214
|
**Environment variables options:**
|
|
207
215
|
|
|
208
216
|
- **`--env`**: Specify the environment (e.g., `development`, `production`). Useful in the case you use environment variables in your intlayer configuration file.
|
|
@@ -279,6 +287,10 @@ If [intlayer editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/
|
|
|
279
287
|
|
|
280
288
|
> Example: `npx intlayer dictionary push --env-file .env.production.local`
|
|
281
289
|
|
|
290
|
+
- **`--no-cache`**: Disable the cache.
|
|
291
|
+
|
|
292
|
+
> Example: `npx intlayer build --no-cache`
|
|
293
|
+
|
|
282
294
|
**Environment variables options:**
|
|
283
295
|
|
|
284
296
|
- **`--env`**: Specify the environment (e.g., `development`, `production`).
|
|
@@ -392,6 +404,10 @@ This command analyzes your content declaration files for potential issues such a
|
|
|
392
404
|
|
|
393
405
|
> Example: `npx intlayer fill --base-dir ./src`
|
|
394
406
|
|
|
407
|
+
- **`--no-cache`**: Disable the cache.
|
|
408
|
+
|
|
409
|
+
> Example: `npx intlayer build --no-cache`
|
|
410
|
+
|
|
395
411
|
**Preparation options:**
|
|
396
412
|
|
|
397
413
|
- **`--build`**: Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build.
|
|
@@ -448,6 +464,10 @@ Total missing required locales: 0
|
|
|
448
464
|
|
|
449
465
|
> Example: `npx intlayer content test --base-dir ./src --env-file .env.production.local`
|
|
450
466
|
|
|
467
|
+
- **`--no-cache`**: Disable the cache.
|
|
468
|
+
|
|
469
|
+
> Example: `npx intlayer build --no-cache`
|
|
470
|
+
|
|
451
471
|
**Preparation options:**
|
|
452
472
|
|
|
453
473
|
- **`--build`**: Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build.
|
|
@@ -530,6 +550,7 @@ npx intlayer configuration get
|
|
|
530
550
|
- **`--env-file`**: Provide a custom environment file to load variables from.
|
|
531
551
|
- **`--base-dir`**: Specify the base directory for the project.
|
|
532
552
|
- **`--verbose`**: Enable verbose logging for debugging. (default to true using CLI)
|
|
553
|
+
- **`--no-cache`**: Disable the cache.
|
|
533
554
|
|
|
534
555
|
#### Push Configuration
|
|
535
556
|
|
|
@@ -550,6 +571,7 @@ npx intlayer configuration push
|
|
|
550
571
|
- **`--env-file`**: Provide a custom environment file to load variables from.
|
|
551
572
|
- **`--base-dir`**: Specify the base directory for the project.
|
|
552
573
|
- **`--verbose`**: Enable verbose logging for debugging. (default to true using CLI)
|
|
574
|
+
- **`--no-cache`**: Disable the cache.
|
|
553
575
|
|
|
554
576
|
By pushing the configuration, your project is fully integrated with the Intlayer CMS, enabling seamless dictionary management across teams.
|
|
555
577
|
|
|
@@ -623,6 +645,7 @@ npx intlayer doc translate
|
|
|
623
645
|
- **`--env`**: Specify the environment (e.g., `development`, `production`).
|
|
624
646
|
- **`--env-file [envFile]`**: Provide a custom environment file to load variables from.
|
|
625
647
|
- **`--base-dir`**: Specify the base directory for the project.
|
|
648
|
+
- **`--no-cache`**: Disable the cache.
|
|
626
649
|
|
|
627
650
|
> Example: `npx intlayer doc translate --base-dir ./docs --env-file .env.production.local`
|
|
628
651
|
|
|
@@ -738,6 +761,8 @@ Live Sync lets your app reflect CMS content changes at runtime. No rebuild or re
|
|
|
738
761
|
|
|
739
762
|
- **`--base-dir`**: Specify the base directory for the project. To retrieve the intlayer configuration, the command will look for the `intlayer.config.{ts,js,json,cjs,mjs}` file in the base directory.
|
|
740
763
|
|
|
764
|
+
- **`--no-cache`**: Disable the cache.
|
|
765
|
+
|
|
741
766
|
> Example: `npx intlayer dictionary push --env-file .env.production.local`
|
|
742
767
|
|
|
743
768
|
**Log options:**
|
|
@@ -1488,6 +1488,8 @@ yarn add @intlayer/swc --save-dev
|
|
|
1488
1488
|
|
|
1489
1489
|
> Note: This package is not installed by default because SWC plugins are still experimental on Next.js. It may change in the future.
|
|
1490
1490
|
|
|
1491
|
+
> Note: If you set the option as `importMode: 'dynamic'` or `importMode: 'live'`, it will rely on Suspense, so you will have to wrap your `useIntlayer` calls in a `Suspense` boundary. That means, you will not be able to use the `useIntlayer` directly at the top level of your Page / Layout component.
|
|
1492
|
+
|
|
1491
1493
|
### Configure TypeScript
|
|
1492
1494
|
|
|
1493
1495
|
Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.
|
|
@@ -1550,6 +1550,8 @@ yarn add @intlayer/swc --save-dev
|
|
|
1550
1550
|
|
|
1551
1551
|
> Note: This package is not installed by default because SWC plugins are still experimental on Next.js. It may change in the future.
|
|
1552
1552
|
|
|
1553
|
+
> Note: If you set the option as `importMode: 'dynamic'` or `importMode: 'live'`, it will rely on Suspense, so you will have to wrap your `useIntlayer` calls in a `Suspense` boundary. That means, you will not be able to use the `useIntlayer` directly at the top level of your Page / Layout component.
|
|
1554
|
+
|
|
1553
1555
|
### Watch dictionaries changes on Turbopack
|
|
1554
1556
|
|
|
1555
1557
|
When using Turbopack as your development server with the `next dev --turbopack` command, dictionary changes will not be automatically detected by default.
|
|
@@ -1525,6 +1525,8 @@ yarn add @intlayer/swc --save-dev
|
|
|
1525
1525
|
|
|
1526
1526
|
> Note: This package is not installed by default because SWC plugins are still experimental on Next.js. It may change in the future.
|
|
1527
1527
|
|
|
1528
|
+
> Note: If you set the option as `importMode: 'dynamic'` or `importMode: 'live'`, it will rely on Suspense, so you will have to wrap your `useIntlayer` calls in a `Suspense` boundary. That means, you will not be able to use the `useIntlayer` directly at the top level of your Page / Layout component.
|
|
1529
|
+
|
|
1528
1530
|
### Watch dictionaries changes on Turbopack
|
|
1529
1531
|
|
|
1530
1532
|
When using Turbopack as your development server with the `next dev` command, dictionary changes will not be automatically detected by default.
|
|
@@ -28,7 +28,7 @@ history:
|
|
|
28
28
|
changes: Initial Sync JSON plugin documentation
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
# Sync JSON (i18n bridges)
|
|
32
32
|
|
|
33
33
|
Use Intlayer as an add‑on to your existing i18n stack. This plugin keeps your JSON messages in sync with Intlayer dictionaries so you can:
|
|
34
34
|
|