@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.
- 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 +67 -103
- package/blog/en/intlayer_with_next-i18next.md +69 -294
- package/blog/en/intlayer_with_next-intl.md +48 -300
- package/blog/en/intlayer_with_react-i18next.md +61 -289
- package/blog/en/intlayer_with_react-intl.md +61 -284
- package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +1 -1
- 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/dist/cjs/generated/blog.entry.cjs +13 -1
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +13 -1
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +13 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +13 -1
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +13 -2
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +13 -2
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/esm/generated/frequentQuestions.entry.mjs +13 -2
- package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
- package/dist/esm/generated/legal.entry.mjs +13 -2
- package/dist/esm/generated/legal.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
- package/dist/types/generated/legal.entry.d.ts.map +1 -1
- package/docs/ar/plugins/sync-json.md +244 -0
- package/docs/de/plugins/sync-json.md +244 -0
- package/docs/de/releases/v7.md +1 -18
- package/docs/en/CI_CD.md +1 -1
- package/docs/en/configuration.md +1 -1
- package/docs/en/formatters.md +1 -1
- package/docs/en/how_works_intlayer.md +1 -1
- package/docs/en/intlayer_CMS.md +1 -1
- package/docs/en/intlayer_cli.md +26 -1
- package/docs/en/intlayer_with_nextjs_14.md +3 -1
- package/docs/en/intlayer_with_nextjs_15.md +3 -1
- package/docs/en/intlayer_with_nextjs_16.md +3 -1
- package/docs/en/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/en/intlayer_with_nuxt.md +1 -1
- package/docs/en/intlayer_with_react_native+expo.md +1 -1
- package/docs/en/intlayer_with_react_router_v7.md +1 -1
- package/docs/en/intlayer_with_tanstack.md +1 -1
- package/docs/en/intlayer_with_vite+preact.md +1 -1
- package/docs/en/intlayer_with_vite+react.md +1 -1
- package/docs/en/intlayer_with_vite+solid.md +1 -1
- package/docs/en/intlayer_with_vite+svelte.md +1 -1
- package/docs/en/intlayer_with_vite+vue.md +1 -1
- package/docs/en/plugins/sync-json.md +1 -1
- package/docs/en/roadmap.md +1 -1
- package/docs/en-GB/plugins/sync-json.md +244 -0
- package/docs/es/plugins/sync-json.md +244 -0
- package/docs/es/releases/v7.md +1 -18
- package/docs/fr/intlayer_with_nextjs_16.md +2 -51
- package/docs/fr/plugins/sync-json.md +244 -0
- package/docs/fr/releases/v7.md +1 -18
- package/docs/hi/intlayer_with_nextjs_16.md +3 -2
- package/docs/hi/plugins/sync-json.md +244 -0
- package/docs/id/plugins/sync-json.md +244 -0
- package/docs/id/releases/v7.md +1 -18
- package/docs/it/plugins/sync-json.md +244 -0
- package/docs/it/releases/v7.md +1 -18
- package/docs/ja/intlayer_with_nextjs_16.md +44 -205
- package/docs/ja/plugins/sync-json.md +244 -0
- package/docs/ja/releases/v7.md +1 -18
- package/docs/ko/plugins/sync-json.md +244 -0
- package/docs/ko/releases/v7.md +1 -18
- package/docs/pl/plugins/sync-json.md +244 -0
- package/docs/pt/intlayer_with_nextjs_16.md +1 -52
- 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
- package/src/generated/blog.entry.ts +26 -3
- package/src/generated/docs.entry.ts +26 -3
- package/src/generated/frequentQuestions.entry.ts +26 -3
- package/src/generated/legal.entry.ts +26 -3
|
@@ -1,325 +1,122 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-01-02
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title:
|
|
5
|
-
description:
|
|
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
|
-
-
|
|
12
|
-
-
|
|
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
|
-
#
|
|
24
|
+
# كيفية أتمتة ترجمات JSON الخاصة بـ react-intl باستخدام Intlayer
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
## ما هو Intlayer؟
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
**Intlayer** هي مكتبة تدويل مبتكرة ومفتوحة المصدر مصممة لمعالجة أوجه القصور في حلول i18n التقليدية. تقدم نهجًا حديثًا لإدارة المحتوى في تطبيقات React.
|
|
24
29
|
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
+
1. **قاعدة الشيفرة الحالية**: لديك تنفيذ قائم لـ react-intl وترغب في الترحيل التدريجي إلى تجربة المطور المحسنة التي يوفرها Intlayer.
|
|
37
|
+
2. **متطلبات النظام القديم**: يتطلب مشروعك التوافق مع الإضافات أو سير العمل الحالي لـ react-intl.
|
|
38
|
+
3. **ألفة الفريق**: فريقك معتاد على react-intl لكنه يرغب في إدارة محتوى أفضل.
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
يمكن أن تعيش ملفات إعلان محتوى Intlayer بجانب مكونات React الخاصة بك، مما يمنع "ترجمات يتيمة" إذا تم نقل المكونات أو إزالتها. على سبيل المثال:
|
|
40
|
+
**لهذا، يمكن تنفيذ Intlayer كمحول لـ react-intl للمساعدة في أتمتة ترجمات JSON الخاصة بك في واجهة الأوامر أو خطوط أنابيب CI/CD، اختبار ترجماتك، والمزيد.**
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
└── src
|
|
40
|
-
└── components
|
|
41
|
-
└── MyComponent
|
|
42
|
-
├── index.content.ts # إعلان محتوى Intlayer
|
|
43
|
-
└── index.tsx # مكون React
|
|
44
|
-
```
|
|
42
|
+
يوضح هذا الدليل كيفية الاستفادة من نظام إعلان المحتوى المتفوق في Intlayer مع الحفاظ على التوافق مع react-intl.
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
كل ملف إعلان محتوى يجمع جميع الترجمات التي يحتاجها مكون. هذا مفيد بشكل خاص في مشاريع TypeScript: يمكن اكتشاف الترجمات المفقودة في **وقت التجميع**.
|
|
44
|
+
## جدول المحتويات
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
كلما قمت بإضافة أو تحديث الترجمات، يقوم Intlayer بتجديد ملفات JSON للرسائل. يمكنك بعد ذلك تمرير هذه إلى `<IntlProvider>` لـ react-intl.
|
|
46
|
+
<TOC/>
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
## دليل خطوة بخطوة لإعداد Intlayer مع react-intl
|
|
53
49
|
|
|
54
|
-
|
|
50
|
+
### الخطوة 1: تثبيت التبعيات
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
قم بتثبيت الحزم اللازمة:
|
|
57
53
|
|
|
58
|
-
```bash
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
```bash packageManager="npm"
|
|
55
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
56
|
+
```
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
```bash packageManager="pnpm"
|
|
59
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
60
|
+
```
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
```bash packageManager="yarn"
|
|
63
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
67
64
|
```
|
|
68
65
|
|
|
69
|
-
|
|
66
|
+
**وصف الحزم:**
|
|
70
67
|
|
|
71
|
-
- **intlayer**:
|
|
72
|
-
-
|
|
68
|
+
- **intlayer**: المكتبة الأساسية لإدارة التدويل، إعلان المحتوى، والبناء
|
|
69
|
+
- **@intlayer/sync-json-plugin**: إضافة لتصدير إعلانات محتوى Intlayer إلى صيغة JSON متوافقة مع react-intl
|
|
73
70
|
|
|
74
|
-
|
|
71
|
+
### الخطوة 2: تنفيذ إضافة Intlayer لتغليف JSON
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
قم بإنشاء ملف تكوين Intlayer لتعريف اللغات المدعومة لديك:
|
|
77
74
|
|
|
78
|
-
|
|
75
|
+
**إذا كنت تريد أيضًا تصدير قواميس JSON لـ react-intl**، أضف إضافة `syncJSON`:
|
|
79
76
|
|
|
80
|
-
```typescript
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
291
|
-
2.
|
|
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
|
-
|
|
105
|
+
للاطلاع على مزيد من التفاصيل حول إضافة `syncJSON`، يرجى الرجوع إلى [توثيق إضافة syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/plugins/sync-json.md).
|
|
297
106
|
|
|
298
|
-
|
|
107
|
+
## إعدادات Git
|
|
299
108
|
|
|
300
|
-
|
|
109
|
+
يوصى بتجاهل ملفات Intlayer التي يتم إنشاؤها تلقائيًا:
|
|
301
110
|
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
// ...
|
|
306
|
-
},
|
|
307
|
-
"include": ["src", "types"],
|
|
308
|
-
}
|
|
111
|
+
```plaintext fileName=".gitignore"
|
|
112
|
+
# تجاهل الملفات التي تم إنشاؤها بواسطة Intlayer
|
|
113
|
+
.intlayer
|
|
309
114
|
```
|
|
310
115
|
|
|
311
|
-
يمكن
|
|
116
|
+
يمكن إعادة إنشاء هذه الملفات أثناء عملية البناء الخاصة بك ولا تحتاج إلى الالتزام بها في نظام التحكم في الإصدارات.
|
|
312
117
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
## تكوين Git
|
|
316
|
-
|
|
317
|
-
من الشائع **استبعاد** العناصر الناتجة الداخلية لـ Intlayer من التحكم في الإصدارات. في ملف `.gitignore` الخاص بك، أضف:
|
|
118
|
+
### إضافة VS Code
|
|
318
119
|
|
|
319
|
-
|
|
320
|
-
# تجاهل العناصر الناتجة من بناء intlayer
|
|
321
|
-
.intlayer
|
|
322
|
-
react-intl
|
|
323
|
-
```
|
|
120
|
+
لتحسين تجربة المطور، قم بتثبيت **إضافة Intlayer الرسمية لـ VS Code**:
|
|
324
121
|
|
|
325
|
-
|
|
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-
|
|
4
|
-
title:
|
|
5
|
-
description:
|
|
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
|
-
#
|
|
28
|
+
# Wie Sie Ihre i18next JSON-Übersetzungen mit Intlayer automatisieren
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
## Was ist Intlayer?
|
|
25
31
|
|
|
26
|
-
Intlayer ist
|
|
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
|
-
|
|
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
|
-
|
|
36
|
+
## Warum Intlayer mit i18next kombinieren?
|
|
31
37
|
|
|
32
|
-
|
|
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
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
48
|
+
## Inhaltsverzeichnis
|
|
42
49
|
|
|
43
|
-
|
|
50
|
+
<TOC/>
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
## Schritt-für-Schritt-Anleitung zur Einrichtung von Intlayer mit i18next
|
|
46
53
|
|
|
47
|
-
|
|
54
|
+
### Schritt 1: Abhängigkeiten installieren
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
Installieren Sie die notwendigen Pakete:
|
|
50
57
|
|
|
51
|
-
|
|
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
|
-
|
|
70
|
+
**Paketbeschreibungen:**
|
|
54
71
|
|
|
55
|
-
|
|
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
|
-
|
|
75
|
+
### Schritt 2: Implementieren Sie das Intlayer-Plugin zum Verpacken des JSON
|
|
58
76
|
|
|
59
|
-
|
|
77
|
+
Erstellen Sie eine Intlayer-Konfigurationsdatei, um Ihre unterstützten Sprachen zu definieren:
|
|
60
78
|
|
|
61
|
-
|
|
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"
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92
|
-
```
|
|
104
|
+
1. Lädt sowohl JSON- als auch Content-Deklarationsdateien und transformiert sie in ein Intlayer-Wörterbuch.
|
|
93
105
|
|
|
94
|
-
|
|
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
|
-
|
|
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
|
-
|
|
108
|
-
```
|
|
110
|
+
## Git-Konfiguration
|
|
109
111
|
|
|
110
|
-
|
|
112
|
+
Es wird empfohlen, automatisch generierte Intlayer-Dateien zu ignorieren:
|
|
111
113
|
|
|
112
|
-
|
|
114
|
+
```plaintext fileName=".gitignore"
|
|
115
|
+
# Dateien, die von Intlayer generiert werden, ignorieren
|
|
116
|
+
.intlayer
|
|
117
|
+
```
|
|
113
118
|
|
|
114
|
-
|
|
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
|
-
|
|
117
|
-
// i18n/client.ts
|
|
121
|
+
### VS Code Erweiterung
|
|
118
122
|
|
|
119
|
-
|
|
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
|
-
|
|
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
|
-
|
|
133
|
-
// i18n/client.mjs
|
|
127
|
+
## Git-Konfiguration
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
129
|
+
Es wird empfohlen, automatisch generierte Intlayer-Dateien zu ignorieren:
|
|
137
130
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
|
|
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
|
-
|
|
152
|
-
const resourcesToBackend = require("i18next-resources-to-backend");
|
|
138
|
+
### VS Code Erweiterung
|
|
153
139
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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)
|