@intlayer/docs 7.0.4-canary.0 → 7.0.5

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 (107) 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 +36 -1638
  12. package/blog/en/intlayer_with_next-i18next.md +22 -847
  13. package/blog/en/intlayer_with_next-intl.md +32 -1053
  14. package/blog/en/intlayer_with_react-i18next.md +38 -764
  15. package/blog/en/intlayer_with_react-intl.md +42 -1018
  16. package/blog/en-GB/intlayer_with_i18next.md +67 -103
  17. package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
  18. package/blog/en-GB/intlayer_with_next-intl.md +58 -337
  19. package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
  20. package/blog/en-GB/intlayer_with_react-intl.md +61 -264
  21. package/blog/es/intlayer_with_i18next.md +67 -103
  22. package/blog/es/intlayer_with_next-i18next.md +71 -296
  23. package/blog/es/intlayer_with_next-intl.md +57 -338
  24. package/blog/es/intlayer_with_react-i18next.md +68 -290
  25. package/blog/es/intlayer_with_react-intl.md +62 -265
  26. package/blog/fr/intlayer_with_i18next.md +66 -104
  27. package/blog/fr/intlayer_with_next-i18next.md +82 -285
  28. package/blog/fr/intlayer_with_next-intl.md +57 -338
  29. package/blog/fr/intlayer_with_react-i18next.md +67 -289
  30. package/blog/fr/intlayer_with_react-intl.md +61 -264
  31. package/blog/hi/intlayer_with_i18next.md +68 -104
  32. package/blog/hi/intlayer_with_next-i18next.md +74 -299
  33. package/blog/hi/intlayer_with_next-intl.md +57 -239
  34. package/blog/hi/intlayer_with_react-i18next.md +69 -291
  35. package/blog/hi/intlayer_with_react-intl.md +65 -268
  36. package/blog/id/intlayer_with_i18next.md +126 -0
  37. package/blog/id/intlayer_with_next-i18next.md +142 -0
  38. package/blog/id/intlayer_with_next-intl.md +113 -0
  39. package/blog/id/intlayer_with_react-i18next.md +124 -0
  40. package/blog/id/intlayer_with_react-intl.md +122 -0
  41. package/blog/it/intlayer_with_i18next.md +67 -103
  42. package/blog/it/intlayer_with_next-i18next.md +71 -296
  43. package/blog/it/intlayer_with_next-intl.md +57 -338
  44. package/blog/it/intlayer_with_react-i18next.md +68 -290
  45. package/blog/it/intlayer_with_react-intl.md +62 -265
  46. package/blog/ja/intlayer_with_i18next.md +68 -103
  47. package/blog/ja/intlayer_with_next-i18next.md +85 -283
  48. package/blog/ja/intlayer_with_next-intl.md +58 -336
  49. package/blog/ja/intlayer_with_react-i18next.md +68 -290
  50. package/blog/ja/intlayer_with_react-intl.md +62 -264
  51. package/blog/ko/intlayer_with_i18next.md +80 -96
  52. package/blog/ko/intlayer_with_next-i18next.md +85 -287
  53. package/blog/ko/intlayer_with_next-intl.md +68 -327
  54. package/blog/ko/intlayer_with_react-i18next.md +68 -290
  55. package/blog/ko/intlayer_with_react-intl.md +64 -266
  56. package/blog/pl/intlayer_with_i18next.md +126 -0
  57. package/blog/pl/intlayer_with_next-i18next.md +142 -0
  58. package/blog/pl/intlayer_with_next-intl.md +111 -0
  59. package/blog/pl/intlayer_with_react-i18next.md +124 -0
  60. package/blog/pl/intlayer_with_react-intl.md +122 -0
  61. package/blog/pt/intlayer_with_i18next.md +67 -103
  62. package/blog/pt/intlayer_with_next-i18next.md +72 -293
  63. package/blog/pt/intlayer_with_next-intl.md +57 -256
  64. package/blog/pt/intlayer_with_react-i18next.md +104 -78
  65. package/blog/pt/intlayer_with_react-intl.md +62 -266
  66. package/blog/ru/intlayer_with_i18next.md +66 -104
  67. package/blog/ru/intlayer_with_next-i18next.md +71 -296
  68. package/blog/ru/intlayer_with_next-intl.md +58 -337
  69. package/blog/ru/intlayer_with_react-i18next.md +68 -290
  70. package/blog/ru/intlayer_with_react-intl.md +62 -265
  71. package/blog/tr/intlayer_with_i18next.md +71 -107
  72. package/blog/tr/intlayer_with_next-i18next.md +72 -297
  73. package/blog/tr/intlayer_with_next-intl.md +58 -339
  74. package/blog/tr/intlayer_with_react-i18next.md +69 -291
  75. package/blog/tr/intlayer_with_react-intl.md +63 -285
  76. package/blog/vi/intlayer_with_i18next.md +126 -0
  77. package/blog/vi/intlayer_with_next-i18next.md +142 -0
  78. package/blog/vi/intlayer_with_next-intl.md +111 -0
  79. package/blog/vi/intlayer_with_react-i18next.md +124 -0
  80. package/blog/vi/intlayer_with_react-intl.md +122 -0
  81. package/blog/zh/intlayer_with_i18next.md +67 -102
  82. package/blog/zh/intlayer_with_next-i18next.md +72 -296
  83. package/blog/zh/intlayer_with_next-intl.md +58 -336
  84. package/blog/zh/intlayer_with_react-i18next.md +68 -290
  85. package/blog/zh/intlayer_with_react-intl.md +63 -106
  86. package/docs/ar/plugins/sync-json.md +244 -0
  87. package/docs/de/plugins/sync-json.md +244 -0
  88. package/docs/en/intlayer_cli.md +25 -0
  89. package/docs/en/intlayer_with_nextjs_14.md +2 -0
  90. package/docs/en/intlayer_with_nextjs_15.md +2 -0
  91. package/docs/en/intlayer_with_nextjs_16.md +2 -0
  92. package/docs/en/plugins/sync-json.md +1 -1
  93. package/docs/en-GB/plugins/sync-json.md +244 -0
  94. package/docs/es/plugins/sync-json.md +244 -0
  95. package/docs/fr/plugins/sync-json.md +244 -0
  96. package/docs/hi/plugins/sync-json.md +244 -0
  97. package/docs/id/plugins/sync-json.md +244 -0
  98. package/docs/it/plugins/sync-json.md +244 -0
  99. package/docs/ja/plugins/sync-json.md +244 -0
  100. package/docs/ko/plugins/sync-json.md +244 -0
  101. package/docs/pl/plugins/sync-json.md +244 -0
  102. package/docs/pt/plugins/sync-json.md +244 -0
  103. package/docs/ru/plugins/sync-json.md +244 -0
  104. package/docs/tr/plugins/sync-json.md +245 -0
  105. package/docs/vi/plugins/sync-json.md +244 -0
  106. package/docs/zh/plugins/sync-json.md +244 -0
  107. package/package.json +14 -14
@@ -1,325 +1,122 @@
1
1
  ---
2
2
  createdAt: 2025-01-02
3
- updatedAt: 2025-06-29
4
- title: Intlayer وreact-intl
5
- description: دمج Intlayer مع react-intl لتطبيق React
3
+ updatedAt: 2025-10-29
4
+ title: كيفية أتمتة ترجمات JSON الخاصة بـ react-intl باستخدام Intlayer
5
+ description: أتمتة ترجمات JSON الخاصة بك باستخدام Intlayer و react-intl لتعزيز التدويل في تطبيقات React.
6
6
  keywords:
7
7
  - react-intl
8
8
  - Intlayer
9
9
  - التدويل
10
- - التوثيق
11
- - Next.js
12
- - JavaScript
10
+ - مدونة
11
+ - i18n
12
+ - جافا سكريبت
13
13
  - React
14
+ - FormatJS
14
15
  slugs:
15
16
  - blog
16
17
  - intlayer-with-react-intl
18
+ history:
19
+ - version: 7.0.0
20
+ date: 2025-10-29
21
+ changes: التغيير إلى مكون syncJSON
17
22
  ---
18
23
 
19
- # React Internationalization (i18n) مع **react-intl** و Intlayer
24
+ # كيفية أتمتة ترجمات JSON الخاصة بـ react-intl باستخدام Intlayer
20
25
 
21
- هذا الدليل يوضح كيفية دمج **Intlayer** مع **react-intl** لإدارة الترجمات في تطبيق React. ستقوم بإعلان المحتوى القابل للترجمة الخاص بك باستخدام Intlayer ثم استهلاك تلك الرسائل مع **react-intl**، وهي مكتبة شهيرة من نظام [FormatJS](https://formatjs.io/docs/react-intl) البيئي.
26
+ ## ما هو Intlayer؟
22
27
 
23
- ## نظرة عامة
28
+ **Intlayer** هي مكتبة تدويل مبتكرة ومفتوحة المصدر مصممة لمعالجة أوجه القصور في حلول i18n التقليدية. تقدم نهجًا حديثًا لإدارة المحتوى في تطبيقات React.
24
29
 
25
- - **Intlayer** يسمح لك بتخزين الترجمات في ملفات إعلان المحتوى على مستوى المكون (JSON، JS، TS، إلخ) داخل مشروعك.
26
- - **react-intl** يوفر مكونات React وhooks (مثل `<FormattedMessage>` و `useIntl()`) لعرض السلاسل المحلية.
30
+ اطلع على مقارنة ملموسة مع react-intl في منشور مدونتنا [react-i18next مقابل react-intl مقابل Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/ar/react-i18next_vs_react-intl_vs_intlayer.md).
27
31
 
28
- من خلال تكوين Intlayer لـ **تصدير** الترجمات بتنسيق متوافق مع **react-intl**، يمكنك تلقائيًا **توليد** و **تحديث** ملفات الرسائل التي يتطلبها `<IntlProvider>` (من react-intl).
32
+ ## لماذا الجمع بين Intlayer و react-intl؟
29
33
 
30
- ---
34
+ بينما يوفر Intlayer حلاً ممتازًا مستقلاً لـ i18n (راجع دليل التكامل مع React الخاص بنا [React integration guide](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/intlayer_with_vite+react.md))، قد ترغب في دمجه مع react-intl لأسباب عدة:
31
35
 
32
- ## لماذا استخدام Intlayer مع react-intl؟
36
+ 1. **قاعدة الشيفرة الحالية**: لديك تنفيذ قائم لـ react-intl وترغب في الترحيل التدريجي إلى تجربة المطور المحسنة التي يوفرها Intlayer.
37
+ 2. **متطلبات النظام القديم**: يتطلب مشروعك التوافق مع الإضافات أو سير العمل الحالي لـ react-intl.
38
+ 3. **ألفة الفريق**: فريقك معتاد على react-intl لكنه يرغب في إدارة محتوى أفضل.
33
39
 
34
- 1. **إعلانات محتوى لكل مكون**
35
- يمكن أن تعيش ملفات إعلان محتوى Intlayer بجانب مكونات React الخاصة بك، مما يمنع "ترجمات يتيمة" إذا تم نقل المكونات أو إزالتها. على سبيل المثال:
40
+ **لهذا، يمكن تنفيذ Intlayer كمحول لـ react-intl للمساعدة في أتمتة ترجمات JSON الخاصة بك في واجهة الأوامر أو خطوط أنابيب CI/CD، اختبار ترجماتك، والمزيد.**
36
41
 
37
- ```bash
38
- .
39
- └── src
40
- └── components
41
- └── MyComponent
42
- ├── index.content.ts # إعلان محتوى Intlayer
43
- └── index.tsx # مكون React
44
- ```
42
+ يوضح هذا الدليل كيفية الاستفادة من نظام إعلان المحتوى المتفوق في Intlayer مع الحفاظ على التوافق مع react-intl.
45
43
 
46
- 2. **ترجمات مركزية**
47
- كل ملف إعلان محتوى يجمع جميع الترجمات التي يحتاجها مكون. هذا مفيد بشكل خاص في مشاريع TypeScript: يمكن اكتشاف الترجمات المفقودة في **وقت التجميع**.
44
+ ## جدول المحتويات
48
45
 
49
- 3. **بناء تلقائي وتجديد**
50
- كلما قمت بإضافة أو تحديث الترجمات، يقوم Intlayer بتجديد ملفات JSON للرسائل. يمكنك بعد ذلك تمرير هذه إلى `<IntlProvider>` لـ react-intl.
46
+ <TOC/>
51
47
 
52
- ---
48
+ ## دليل خطوة بخطوة لإعداد Intlayer مع react-intl
53
49
 
54
- ## التثبيت
50
+ ### الخطوة 1: تثبيت التبعيات
55
51
 
56
- في مشروع React النموذجي، قم بتثبيت ما يلي:
52
+ قم بتثبيت الحزم اللازمة:
57
53
 
58
- ```bash
59
- # مع npm
60
- npm install intlayer react-intl
54
+ ```bash packageManager="npm"
55
+ npm install intlayer @intlayer/sync-json-plugin
56
+ ```
61
57
 
62
- # مع yarn
63
- yarn add intlayer react-intl
58
+ ```bash packageManager="pnpm"
59
+ pnpm add intlayer @intlayer/sync-json-plugin
60
+ ```
64
61
 
65
- # مع pnpm
66
- pnpm add intlayer react-intl
62
+ ```bash packageManager="yarn"
63
+ yarn add intlayer @intlayer/sync-json-plugin
67
64
  ```
68
65
 
69
- ### لماذا هذه الحزم؟
66
+ **وصف الحزم:**
70
67
 
71
- - **intlayer**: CLI و مكتبة أساسية تفحص إعلانات المحتوى، تدمجها، وتبني المخرجات القاموس.
72
- - **react-intl**: المكتبة الرئيسية من FormatJS التي توفر `<IntlProvider>`، `<FormattedMessage>`، `useIntl()` وغيرها من العناصر الأساسية في التدويل.
68
+ - **intlayer**: المكتبة الأساسية لإدارة التدويل، إعلان المحتوى، والبناء
69
+ - **@intlayer/sync-json-plugin**: إضافة لتصدير إعلانات محتوى Intlayer إلى صيغة JSON متوافقة مع react-intl
73
70
 
74
- > إذا لم يكن لديك React مثبتًا بالفعل، ستحتاج إلى ذلك أيضًا (`react` و `react-dom`).
71
+ ### الخطوة 2: تنفيذ إضافة Intlayer لتغليف JSON
75
72
 
76
- ## تكوين Intlayer لتصدير رسائل react-intl
73
+ قم بإنشاء ملف تكوين Intlayer لتعريف اللغات المدعومة لديك:
77
74
 
78
- في جذر مشروعك، أنشئ **`intlayer.config.ts`** (أو `.js`، `.mjs`، `.cjs`) كما يلي:
75
+ **إذا كنت تريد أيضًا تصدير قواميس JSON لـ react-intl**، أضف إضافة `syncJSON`:
79
76
 
80
- ```typescript title="intlayer.config.ts"
77
+ ```typescript fileName="intlayer.config.ts"
81
78
  import { Locales, type IntlayerConfig } from "intlayer";
79
+ import { syncJSON } from "@intlayer/sync-json-plugin";
82
80
 
83
81
  const config: IntlayerConfig = {
84
82
  internationalization: {
85
- // أضف العديد من اللغات كما ترغب
86
83
  locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
87
84
  defaultLocale: Locales.ENGLISH,
88
85
  },
89
- content: {
90
- // يخبر Intlayer بتوليد ملفات الرسائل لـ react-intl
91
- dictionaryOutput: ["react-intl"],
92
-
93
- // الدليل الذي سيكتب فيه Intlayer ملفات JSON للرسائل الخاصة بك
94
- reactIntlMessagesDir: "./react-intl/messages",
95
- },
96
- };
97
-
98
- export default config;
99
- ```
100
-
101
- > **ملاحظة**: للحصول على امتدادات ملفات أخرى (`.mjs`، `.cjs`، `.js`) ، راجع [وثائق Intlayer](https://intlayer.org/ar/doc/concept/configuration) للحصول على تفاصيل الاستخدام.
102
-
103
- ---
104
-
105
- ## إنشاء إعلانات محتوى Intlayer الخاصة بك
106
-
107
- يقوم Intlayer بفحص قاعدة الشيفرة الخاصة بك (بشكل افتراضي، تحت `./src`) للملفات المطابقة لـ `*.content.{ts,tsx,js,jsx,mjs,mjx,cjs,cjx,json}`.
108
- إليك مثال **TypeScript**:
109
-
110
- ```typescript title="src/components/MyComponent/index.content.ts"
111
- import { t, type Dictionary } from "intlayer";
112
-
113
- const content = {
114
- // "key" يصبح المفتاح الرئيسي للرسالة في ملف JSON الخاص بك react-intl
115
- key: "my-component",
116
-
117
- content: {
118
- // كل استدعاء لـ t() يعلن عن حقل قابل للترجمة
119
- helloWorld: t({
120
- en: "Hello World",
121
- es: "Hola Mundo",
122
- fr: "Bonjour le monde",
86
+ plugins: [
87
+ syncJSON({
88
+ source: ({ key, locale }) => `./intl/messages/${locale}/${key}.json`,
123
89
  }),
124
- description: t({
125
- en: "This is a description",
126
- fr: "Ceci est une description",
127
- es: "Esta es una descripción",
128
- }),
129
- },
130
- } satisfies Dictionary;
131
-
132
- export default content;
133
- ```
134
-
135
- إذا كنت تفضل JSON أو نكهات JS مختلفة (`.cjs`، `.mjs`)، فإن الهيكل مشابه إلى حد كبير - راجع [وثائق Intlayer حول إعلان المحتوى](https://intlayer.org/ar/doc/concept/content).
136
-
137
- ---
138
-
139
- ## بناء رسائل react-intl
140
-
141
- لتوليد ملفات JSON الفعلية للرسائل لـ **react-intl**، قم بتشغيل:
142
-
143
- ```bash
144
- # مع npm
145
- npx intlayer dictionaries build
146
-
147
- # مع yarn
148
- yarn intlayer build
149
-
150
- # مع pnpm
151
- pnpm intlayer build
152
- ```
153
-
154
- هذا يقوم بمسح جميع ملفات `*.content.*`، وتجميعها، وكتابة النتائج إلى الدليل المحدد في **`intlayer.config.ts`** - في هذا المثال، `./react-intl/messages`.
155
- يمكن أن يبدو المخرجات النموذجية كما يلي:
156
-
157
- ```bash
158
- .
159
- └── react-intl
160
- └── messages
161
- ├── en.json
162
- ├── fr.json
163
- └── es.json
164
- ```
165
-
166
- كل ملف هو كائن JSON تُطابق **المفاتيح العليا** الخاصة به كل **`content.key`** من إعلاناتك. تعكس **المفاتيح الفرعية** (مثل `helloWorld`) الترجمات المعلنة داخل تلك العنصر المحتوى.
167
-
168
- على سبيل المثال، قد يبدو **en.json** كما يلي:
169
-
170
- ```json fileName="react-intl/messages/en/my-component.json"
171
- {
172
- "helloWorld": "Hello World",
173
- "description": "This is a description"
174
- }
175
- ```
176
-
177
- ---
178
-
179
- ## تهيئة react-intl في تطبيق React الخاص بك
180
-
181
- ### 1. تحميل الرسائل التي تم إنشاؤها
182
-
183
- حيث تقوم بتكوين مكون الجذر لتطبيقك (مثل `src/main.tsx` أو `src/index.tsx`)، ستحتاج إلى:
184
-
185
- 1. **استيراد** ملفات الرسالة المولدة (إما بشكل ثابت أو ديناميكي).
186
- 2. **تقديم**ها إلى `<IntlProvider>` من `react-intl`.
187
-
188
- طريقة بسيطة هي استيرادها **ثابتًا**:
189
-
190
- ```typescript title="src/index.tsx"
191
- import React from "react";
192
- import ReactDOM from "react-dom/client";
193
- import { IntlProvider } from "react-intl";
194
- import App from "./App";
195
-
196
- // استيراد ملفات JSON من المخرجات التي تم بنائها.
197
- // بدلاً من ذلك، يمكنك الاستيراد ديناميكيًا بناءً على لغة المستخدم المختارة.
198
- import en from "../react-intl/messages/en.json";
199
- import fr from "../react-intl/messages/fr.json";
200
- import es from "../react-intl/messages/es.json";
201
-
202
- // إذا كان لديك آلية لاكتشاف لغة المستخدم، قم بتعيينها هنا.
203
- // للبساطة، دعنا نختار الإنجليزية.
204
- const locale = "en";
205
-
206
- // جمع الرسائل في كائن (أو اختيارها ديناميكيًا)
207
- const messagesRecord: Record<string, Record<string, any>> = {
208
- en,
209
- fr,
210
- es,
90
+ ],
211
91
  };
212
92
 
213
- ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
214
- <React.StrictMode>
215
- <IntlProvider locale={locale} messages={messagesRecord[locale]}>
216
- <App />
217
- </IntlProvider>
218
- </React.StrictMode>
219
- );
220
- ```
221
-
222
- > **نصيحة**: لمشاريع حقيقية، قد ترغب في:
223
- >
224
- > - تحميل الرسائل JSON بشكل ديناميكي وقت التشغيل.
225
- > - استخدام الكشف عن اللغة المبني على البيئة أو على المتصفح أو على حساب المستخدم.
226
-
227
- ### 2. استخدام `<FormattedMessage>` أو `useIntl()`
228
-
229
- بمجرد تحميل رسائلك في `<IntlProvider>`, يمكن لأي مكون طفل استخدام react-intl للوصول إلى السلاسل المحلية. هناك طريقتان رئيسيتان:
230
-
231
- - **مكون `<FormattedMessage>`**
232
- - **خطاف `useIntl()`**
233
-
234
- ---
235
-
236
- ## استخدام الترجمات في مكونات React
237
-
238
- ### النهج A: `<FormattedMessage>`
239
-
240
- للاستخدام السريع في السطر:
241
-
242
- ```tsx title="src/components/MyComponent/index.tsx"
243
- import React from "react";
244
- import { FormattedMessage } from "react-intl";
245
-
246
- export default function MyComponent() {
247
- return (
248
- <div>
249
- <h1>
250
- {/* "my-component.helloWorld" يشير إلى المفتاح من en.json، fr.json، إلخ. */}
251
- <FormattedMessage id="my-component.helloWorld" />
252
- </h1>
253
-
254
- <p>
255
- <FormattedMessage id="my-component.description" />
256
- </p>
257
- </div>
258
- );
259
- }
260
- ```
261
-
262
- > يجب أن تطابق خاصية **`id`** في `<FormattedMessage>` **المفتاح الرئيسي** (`my-component`) بالإضافة إلى أي مفاتيح فرعية (`helloWorld`).
263
-
264
- ### النهج B: `useIntl()`
265
-
266
- للاستخدام الأكثر ديناميكية:
267
-
268
- ```tsx title="src/components/MyComponent/index.tsx"
269
- import React from "react";
270
- import { useIntl } from "react-intl";
271
-
272
- export default function MyComponent() {
273
- const intl = useIntl();
274
-
275
- return (
276
- <div>
277
- <h1>{intl.formatMessage({ id: "my-component.helloWorld" })}</h1>
278
- <p>{intl.formatMessage({ id: "my-component.description" })}</p>
279
- </div>
280
- );
281
- }
93
+ export default config;
282
94
  ```
283
95
 
284
- كلا النهجين صالحة - اختر النمط الذي يناسب تطبيقك.
96
+ ستقوم إضافة `syncJSON` تلقائيًا بتغليف JSON. ستقوم بقراءة وكتابة ملفات JSON دون تغيير بنية المحتوى.
285
97
 
286
- ---
287
-
288
- ## تحديث أو إضافة ترجمات جديدة
98
+ إذا كنت تريد جعل JSON يتعايش مع ملفات إعلان محتوى intlayer (`.content` files)، فسيقوم Intlayer بالإجراء التالي:
289
99
 
290
- 1. **أضف أو عدل** المحتوى في أي ملف `*.content.*`.
291
- 2. أعد تشغيل `intlayer build` لتجديد ملفات JSON تحت `./react-intl/messages`.
292
- 3. سوف يلتقط React (و react-intl) التحديثات في المرة القادمة التي تعيد فيها بناء أو تحميل تطبيقك.
100
+ 1. تحميل كل من ملفات JSON وملفات إعلان المحتوى وتحويلها إلى قاموس intlayer.
101
+ 2. إذا كانت هناك تعارضات بين ملفات JSON وملفات إعلان المحتوى، فسيقوم Intlayer بدمج جميع القواميس. وذلك يعتمد على أولوية الإضافات، وأولوية ملف إعلان المحتوى (كلها قابلة للتكوين).
293
102
 
294
- ---
103
+ إذا تم إجراء تغييرات باستخدام واجهة الأوامر CLI لترجمة JSON، أو باستخدام نظام إدارة المحتوى CMS، فسيقوم Intlayer بتحديث ملف JSON بالترجمات الجديدة.
295
104
 
296
- ## تكامل TypeScript (اختياري)
105
+ للاطلاع على مزيد من التفاصيل حول إضافة `syncJSON`، يرجى الرجوع إلى [توثيق إضافة syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/plugins/sync-json.md).
297
106
 
298
- إذا كنت تستخدم TypeScript، يمكن أن يقوم Intlayer **بتوليد تعريفات الأنواع** لترجماتك.
107
+ ## إعدادات Git
299
108
 
300
- - تأكد من أن `tsconfig.json` يتضمن مجلد `types` الخاص بك (أو أي مجلد ناتج ينشئه Intlayer) في مصفوفة `"include"`.
109
+ يوصى بتجاهل ملفات Intlayer التي يتم إنشاؤها تلقائيًا:
301
110
 
302
- ```json5
303
- {
304
- "compilerOptions": {
305
- // ...
306
- },
307
- "include": ["src", "types"],
308
- }
111
+ ```plaintext fileName=".gitignore"
112
+ # تجاهل الملفات التي تم إنشاؤها بواسطة Intlayer
113
+ .intlayer
309
114
  ```
310
115
 
311
- يمكن أن تساعد الأنواع المولدة في الكشف عن الترجمات المفقودة أو المفاتيح غير الصالحة في مكونات React الخاصة بك في وقت التجميع.
116
+ يمكن إعادة إنشاء هذه الملفات أثناء عملية البناء الخاصة بك ولا تحتاج إلى الالتزام بها في نظام التحكم في الإصدارات.
312
117
 
313
- ---
314
-
315
- ## تكوين Git
316
-
317
- من الشائع **استبعاد** العناصر الناتجة الداخلية لـ Intlayer من التحكم في الإصدارات. في ملف `.gitignore` الخاص بك، أضف:
118
+ ### إضافة VS Code
318
119
 
319
- ```plaintext
320
- # تجاهل العناصر الناتجة من بناء intlayer
321
- .intlayer
322
- react-intl
323
- ```
120
+ لتحسين تجربة المطور، قم بتثبيت **إضافة Intlayer الرسمية لـ VS Code**:
324
121
 
325
- اعتمادًا على سير عملك، قد ترغب أيضًا في تجاهل أو الالتزام بالقواميس النهائية في `./react-intl/messages`. إذا كان خط أنابيب CI/CD لديك يجددها، يمكنك تجاهلها بأمان؛ وإلا، التزم بها إذا كنت بحاجة إليها لعمليات نشر الإنتاج.
122
+ [التثبيت من سوق VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  createdAt: 2024-12-24
3
- updatedAt: 2025-06-29
4
- title: Intlayer und i18next
5
- description: Integrieren Sie Intlayer mit i18next für optimale Internationalisierung. Vergleichen Sie die beiden Frameworks und lernen Sie, wie Sie sie zusammen konfigurieren.
3
+ updatedAt: 2025-10-29
4
+ title: Wie Sie Ihre i18next JSON-Übersetzungen mit Intlayer automatisieren
5
+ description: Automatisieren Sie Ihre JSON-Übersetzungen mit Intlayer und i18next für eine verbesserte Internationalisierung in JavaScript-Anwendungen.
6
6
  keywords:
7
7
  - Intlayer
8
8
  - i18next
@@ -14,149 +14,129 @@ keywords:
14
14
  - Next.js
15
15
  - JavaScript
16
16
  - TypeScript
17
+ - Migration
18
+ - Integration
17
19
  slugs:
18
20
  - blog
19
21
  - intlayer-with-i18next
22
+ history:
23
+ - version: 7.0.0
24
+ date: 2025-10-29
25
+ changes: Wechsel zum syncJSON-Plugin
20
26
  ---
21
27
 
22
- # Internationalisierung mit Intlayer und i18next
28
+ # Wie Sie Ihre i18next JSON-Übersetzungen mit Intlayer automatisieren
23
29
 
24
- i18next ist ein Open-Source-Internationalisierungs (i18n) Framework, das für JavaScript-Anwendungen entwickelt wurde. Es wird häufig für die Verwaltung von Übersetzungen, Lokalisierung und Sprachwechsel in Softwareprojekten verwendet. Es hat jedoch einige Einschränkungen, die die Skalierbarkeit und die Entwicklung erschweren können.
30
+ ## Was ist Intlayer?
25
31
 
26
- Intlayer ist ein weiteres Internationalisierungsframework, das diese Einschränkungen behebt und einen flexibleren Ansatz zur Inhaltsdeklaration und -verwaltung bietet. Lassen Sie uns einige wichtige Unterschiede zwischen i18next und Intlayer sowie deren Konfiguration für optimierte Internationalisierung erkunden.
32
+ **Intlayer** ist eine innovative, Open-Source-Internationalisierungsbibliothek, die entwickelt wurde, um die Schwächen traditioneller i18n-Lösungen zu beheben. Sie bietet einen modernen Ansatz für das Content-Management in JavaScript-Anwendungen.
27
33
 
28
- ## Intlayer vs. i18next: Hauptunterschiede
34
+ Sehen Sie einen konkreten Vergleich mit i18next in unserem Blogbeitrag [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/de/next-i18next_vs_next-intl_vs_intlayer.md).
29
35
 
30
- ### 1. Inhaltsdeklaration
36
+ ## Warum Intlayer mit i18next kombinieren?
31
37
 
32
- Bei i18next müssen Übersetzungswörterbücher in einem bestimmten Ordner deklariert werden, was die Skalierbarkeit der Anwendung erschweren kann. Im Gegensatz dazu ermöglicht Intlayer die Deklaration von Inhalten im selben Verzeichnis wie Ihre Komponente. Dies hat mehrere Vorteile:
38
+ Während Intlayer eine ausgezeichnete eigenständige i18n-Lösung bietet (siehe unseren [Next.js-Integrationsleitfaden](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/intlayer_with_nextjs_16.md)), möchten Sie es möglicherweise aus mehreren Gründen mit i18next kombinieren:
33
39
 
34
- - **Vereinfachte Inhaltsbearbeitung**: Benutzer müssen nicht nach dem richtigen Wörterbuch suchen, um Änderungen vorzunehmen, wodurch die Fehlerquote verringert wird.
35
- - **Automatische Anpassung**: Wenn sich der Standort einer Komponente ändert oder sie entfernt wird, erkennt Intlayer dies und passt sich automatisch an.
40
+ 1. **Bestehender Codebestand**: Sie haben eine etablierte i18next-Implementierung und möchten schrittweise auf die verbesserte Entwicklererfahrung von Intlayer migrieren.
41
+ 2. **Altsystem-Anforderungen**: Ihr Projekt erfordert Kompatibilität mit bestehenden i18next-Plugins oder Workflows.
42
+ 3. **Teamvertrautheit**: Ihr Team ist mit i18next vertraut, möchte jedoch ein besseres Content-Management.
36
43
 
37
- ### 2. Komplexität der Konfiguration
44
+ **Dafür kann Intlayer als Adapter für i18next implementiert werden, um Ihre JSON-Übersetzungen in CLI- oder CI/CD-Pipelines zu automatisieren, Ihre Übersetzungen zu testen und mehr.**
38
45
 
39
- Die Konfiguration von i18next kann komplex sein, insbesondere bei der Integration mit serverseitigen Komponenten oder der Konfiguration von Middleware für Frameworks wie Next.js. Intlayer vereinfacht diesen Prozess und bietet eine unkompliziertere Konfiguration.
46
+ Dieser Leitfaden zeigt Ihnen, wie Sie das überlegene Content-Deklarationssystem von Intlayer nutzen und gleichzeitig die Kompatibilität mit i18next beibehalten.
40
47
 
41
- ### 3. Konsistenz der Übersetzungswörterbücher
48
+ ## Inhaltsverzeichnis
42
49
 
43
- Die Gewährleistung, dass Übersetzungswörterbücher in verschiedenen Sprachen konsistent sind, kann mit i18next herausfordernd sein. Diese Inkonsistenz kann zu Anwendungsabstürzen führen, wenn sie nicht ordnungsgemäß behandelt wird. Intlayer behebt dies, indem es Einschränkungen für übersetzte Inhalte durchsetzt, um sicherzustellen, dass keine Übersetzung ausgelassen wird und dass der übersetzte Inhalt genau ist.
50
+ <TOC/>
44
51
 
45
- ### 4. TypeScript-Integration
52
+ ## Schritt-für-Schritt-Anleitung zur Einrichtung von Intlayer mit i18next
46
53
 
47
- Intlayer bietet eine bessere Integration mit TypeScript, die automatische Vorschläge für Inhalte in Ihrem Code ermöglicht, wodurch die Effizienz der Entwicklung verbessert wird.
54
+ ### Schritt 1: Abhängigkeiten installieren
48
55
 
49
- ### 5. Teilen von Inhalten über Anwendungen hinaus
56
+ Installieren Sie die notwendigen Pakete:
50
57
 
51
- Intlayer erleichtert das Teilen von Inhaltsdeklarationsdateien über mehrere Anwendungen und gemeinsame Bibliotheken. Diese Funktion erleichtert die Pflege konsistenter Übersetzungen über einen größeren Codebase.
58
+ ```bash packageManager="npm"
59
+ npm install intlayer @intlayer/sync-json-plugin
60
+ ```
61
+
62
+ ```bash packageManager="pnpm"
63
+ pnpm add intlayer @intlayer/sync-json-plugin
64
+ ```
65
+
66
+ ```bash packageManager="yarn"
67
+ yarn add intlayer @intlayer/sync-json-plugin
68
+ ```
52
69
 
53
- ## Wie man i18next-Wörterbücher mit Intlayer generiert
70
+ **Paketbeschreibungen:**
54
71
 
55
- ### Konfiguration von Intlayer zum Export von i18next-Wörterbüchern
72
+ - **intlayer**: Kernbibliothek für Internationalisierungsmanagement, Content-Deklaration und Build-Prozesse
73
+ - **@intlayer/sync-json-plugin**: Plugin zum Exportieren von Intlayer-Content-Deklarationen in ein i18next-kompatibles JSON-Format
56
74
 
57
- > Wichtige Hinweise
75
+ ### Schritt 2: Implementieren Sie das Intlayer-Plugin zum Verpacken des JSON
58
76
 
59
- > Der Export von i18next-Wörterbüchern befindet sich derzeit in der Beta-Phase und gewährleistet keine 1:1-Kompatibilität mit anderen Frameworks. Es wird empfohlen, eine auf Intlayer basierende Konfiguration zu verwenden, um Probleme zu minimieren.
77
+ Erstellen Sie eine Intlayer-Konfigurationsdatei, um Ihre unterstützten Sprachen zu definieren:
60
78
 
61
- Um i18next-Wörterbücher zu exportieren, müssen Sie Intlayer entsprechend konfigurieren. Im Folgenden finden Sie ein Beispiel dafür, wie Sie Intlayer so einrichten, dass sowohl Intlayer- als auch i18next-Wörterbücher exportiert werden.
79
+ **Wenn Sie auch JSON-Wörterbücher für i18next exportieren möchten**, fügen Sie das `syncJSON`-Plugin hinzu:
62
80
 
63
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
81
+ ```typescript fileName="intlayer.config.ts"
64
82
  import { Locales, type IntlayerConfig } from "intlayer";
83
+ import { syncJSON } from "@intlayer/sync-json-plugin";
65
84
 
66
85
  const config: IntlayerConfig = {
67
- content: {
68
- // Geben Sie an, dass Intlayer sowohl Intlayer- als auch i18next-Wörterbücher exportieren wird
69
- dictionaryOutput: ["intlayer", "i18next"],
70
- // Relativer Pfad vom Projektstammverzeichnis zum Verzeichnis, in das die i18n-Wörterbücher exportiert werden
71
- i18nextResourcesDir: "./i18next/dictionaries",
86
+ internationalization: {
87
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
88
+ defaultLocale: Locales.ENGLISH,
72
89
  },
90
+ plugins: [
91
+ syncJSON({
92
+ source: ({ key, locale }) => `./intl/messages/${locale}/${key}.json`,
93
+ }),
94
+ ],
73
95
  };
74
96
 
75
97
  export default config;
76
98
  ```
77
99
 
78
- ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
79
- import { Locales } from "intlayer";
100
+ Das `syncJSON`-Plugin wird das JSON automatisch umschließen. Es liest und schreibt die JSON-Dateien, ohne die Inhaltsarchitektur zu verändern.
80
101
 
81
- /** @type {import('intlayer').IntlayerConfig} */
82
- const config = {
83
- content: {
84
- // Geben Sie an, dass Intlayer sowohl Intlayer- als auch i18next-Wörterbücher exportieren wird
85
- dictionaryOutput: ["intlayer", "i18next"],
86
- // Relativer Pfad vom Projektstammverzeichnis zum Verzeichnis, in das die i18n-Wörterbücher exportiert werden
87
- i18nextResourcesDir: "./i18next/dictionaries",
88
- },
89
- };
102
+ Wenn Sie möchten, dass dieses JSON zusammen mit Intlayer-Content-Deklarationsdateien (`.content`-Dateien) koexistiert, geht Intlayer wie folgt vor:
90
103
 
91
- export default config;
92
- ```
104
+ 1. Lädt sowohl JSON- als auch Content-Deklarationsdateien und transformiert sie in ein Intlayer-Wörterbuch.
93
105
 
94
- ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
95
- const { Locales } = require("intlayer");
106
+ 2. Wenn es Konflikte zwischen den JSON- und den Inhaltsdeklarationsdateien gibt, wird Intlayer alle Wörterbücher zusammenführen. Dies geschieht abhängig von der Priorität der Plugins und der der Inhaltsdeklarationsdatei (alle sind konfigurierbar).
96
107
 
97
- /** @type {import('intlayer').IntlayerConfig} */
98
- const config = {
99
- content: {
100
- // Geben Sie an, dass Intlayer sowohl Intlayer- als auch i18next-Wörterbücher exportieren wird
101
- dictionaryOutput: ["intlayer", "i18next"],
102
- // Relativer Pfad vom Projektstammverzeichnis zum Verzeichnis, in das die i18n-Wörterbücher exportiert werden
103
- i18nextResourcesDir: "./i18next/dictionaries",
104
- },
105
- };
108
+ Wenn Änderungen über die CLI zur Übersetzung des JSON oder über das CMS vorgenommen werden, aktualisiert Intlayer die JSON-Datei mit den neuen Übersetzungen.
106
109
 
107
- module.exports = config;
108
- ```
110
+ ## Git-Konfiguration
109
111
 
110
- Durch das Hinzufügen von 'i18next' zur Konfiguration generiert Intlayer spezielle i18next-Wörterbücher zusätzlich zu den Intlayer-Wörterbüchern. Beachten Sie, dass das Entfernen von 'intlayer' aus der Konfiguration die Kompatibilität mit React-Intlayer oder Next-Intlayer beeinträchtigen kann.
112
+ Es wird empfohlen, automatisch generierte Intlayer-Dateien zu ignorieren:
111
113
 
112
- ### Importieren von Wörterbüchern in Ihre i18next-Konfiguration
114
+ ```plaintext fileName=".gitignore"
115
+ # Dateien, die von Intlayer generiert werden, ignorieren
116
+ .intlayer
117
+ ```
113
118
 
114
- Um die generierten Wörterbücher in Ihre i18next-Konfiguration zu importieren, können Sie 'i18next-resources-to-backend' verwenden. Hier ist ein Beispiel dafür, wie Sie Ihre i18next-Wörterbücher importieren können:
119
+ Diese Dateien können während Ihres Build-Prozesses neu generiert werden und müssen nicht in die Versionskontrolle aufgenommen werden.
115
120
 
116
- ```typescript fileName="i18n/client.ts" codeFormat="typescript"
117
- // i18n/client.ts
121
+ ### VS Code Erweiterung
118
122
 
119
- import i18next from "i18next";
120
- import resourcesToBackend from "i18next-resources-to-backend";
123
+ Für eine verbesserte Entwicklererfahrung installieren Sie die offizielle **Intlayer VS Code Erweiterung**:
121
124
 
122
- i18next
123
- // Ihre i18next-Konfiguration
124
- .use(
125
- resourcesToBackend(
126
- (language: string, namespace: string) =>
127
- import(`../i18next/dictionaries/${language}/${namespace}.json`)
128
- )
129
- );
130
- ```
125
+ [Installieren Sie sie aus dem VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
131
126
 
132
- ```javascript fileName="i18n/client.mjs" codeFormat="esm"
133
- // i18n/client.mjs
127
+ ## Git-Konfiguration
134
128
 
135
- import i18next from "i18next";
136
- import resourcesToBackend from "i18next-resources-to-backend";
129
+ Es wird empfohlen, automatisch generierte Intlayer-Dateien zu ignorieren:
137
130
 
138
- i18next
139
- // Ihre i18next-Konfiguration
140
- .use(
141
- resourcesToBackend(
142
- (language, namespace) =>
143
- import(`../i18next/dictionaries/${language}/${namespace}.json`)
144
- )
145
- );
131
+ ```plaintext fileName=".gitignore"
132
+ # Dateien, die von Intlayer generiert werden, ignorieren
133
+ .intlayer
146
134
  ```
147
135
 
148
- ```javascript fileName="i18n/client.cjs" codeFormat="commonjs"
149
- // i18n/client.cjs
136
+ Diese Dateien können während Ihres Build-Prozesses neu generiert werden und müssen nicht in die Versionskontrolle aufgenommen werden.
150
137
 
151
- const i18next = require("i18next");
152
- const resourcesToBackend = require("i18next-resources-to-backend");
138
+ ### VS Code Erweiterung
153
139
 
154
- i18next
155
- // Ihre i18next-Konfiguration
156
- .use(
157
- resourcesToBackend(
158
- (language, namespace) =>
159
- import(`../i18next/dictionaries/${language}/${namespace}.json`)
160
- )
161
- );
162
- ```
140
+ Für eine verbesserte Entwicklererfahrung installieren Sie die offizielle **Intlayer VS Code Erweiterung**:
141
+
142
+ [Installation aus dem VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)