@intlayer/docs 7.3.13 → 7.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/blog/ar/intlayer_with_i18next.md +3 -0
  2. package/blog/ar/intlayer_with_next-i18next.md +3 -0
  3. package/blog/ar/intlayer_with_next-intl.md +3 -0
  4. package/blog/ar/intlayer_with_react-i18next.md +3 -0
  5. package/blog/ar/intlayer_with_react-intl.md +3 -0
  6. package/blog/ar/intlayer_with_vue-i18n.md +3 -0
  7. package/blog/de/intlayer_with_i18next.md +3 -0
  8. package/blog/de/intlayer_with_next-i18next.md +3 -0
  9. package/blog/de/intlayer_with_next-intl.md +3 -0
  10. package/blog/de/intlayer_with_react-i18next.md +3 -0
  11. package/blog/de/intlayer_with_react-intl.md +3 -0
  12. package/blog/de/intlayer_with_vue-i18n.md +3 -0
  13. package/blog/en/intlayer_with_i18next.md +7 -0
  14. package/blog/en/intlayer_with_next-i18next.md +3 -0
  15. package/blog/en/intlayer_with_next-intl.md +7 -0
  16. package/blog/en/intlayer_with_react-i18next.md +3 -0
  17. package/blog/en/intlayer_with_react-intl.md +3 -0
  18. package/blog/en/intlayer_with_vue-i18n.md +3 -0
  19. package/blog/en-GB/intlayer_with_i18next.md +3 -0
  20. package/blog/en-GB/intlayer_with_next-i18next.md +3 -0
  21. package/blog/en-GB/intlayer_with_next-intl.md +3 -0
  22. package/blog/en-GB/intlayer_with_react-i18next.md +3 -0
  23. package/blog/en-GB/intlayer_with_react-intl.md +3 -0
  24. package/blog/en-GB/intlayer_with_vue-i18n.md +3 -0
  25. package/blog/es/intlayer_with_i18next.md +3 -0
  26. package/blog/es/intlayer_with_next-i18next.md +3 -0
  27. package/blog/es/intlayer_with_next-intl.md +3 -0
  28. package/blog/es/intlayer_with_react-i18next.md +3 -0
  29. package/blog/es/intlayer_with_react-intl.md +3 -0
  30. package/blog/es/intlayer_with_vue-i18n.md +3 -0
  31. package/blog/fr/intlayer_with_i18next.md +3 -0
  32. package/blog/fr/intlayer_with_next-i18next.md +3 -0
  33. package/blog/fr/intlayer_with_next-intl.md +3 -0
  34. package/blog/fr/intlayer_with_react-i18next.md +3 -0
  35. package/blog/fr/intlayer_with_react-intl.md +3 -0
  36. package/blog/fr/intlayer_with_vue-i18n.md +3 -0
  37. package/blog/hi/intlayer_with_i18next.md +3 -0
  38. package/blog/hi/intlayer_with_next-i18next.md +3 -0
  39. package/blog/hi/intlayer_with_next-intl.md +3 -0
  40. package/blog/hi/intlayer_with_react-i18next.md +3 -0
  41. package/blog/hi/intlayer_with_react-intl.md +3 -0
  42. package/blog/hi/intlayer_with_vue-i18n.md +3 -0
  43. package/blog/id/intlayer_with_i18next.md +3 -0
  44. package/blog/id/intlayer_with_next-i18next.md +3 -0
  45. package/blog/id/intlayer_with_next-intl.md +3 -0
  46. package/blog/id/intlayer_with_react-i18next.md +3 -0
  47. package/blog/id/intlayer_with_react-intl.md +3 -0
  48. package/blog/id/intlayer_with_vue-i18n.md +3 -0
  49. package/blog/it/intlayer_with_i18next.md +3 -0
  50. package/blog/it/intlayer_with_next-i18next.md +3 -0
  51. package/blog/it/intlayer_with_next-intl.md +3 -0
  52. package/blog/it/intlayer_with_react-i18next.md +3 -0
  53. package/blog/it/intlayer_with_react-intl.md +3 -0
  54. package/blog/it/intlayer_with_vue-i18n.md +3 -0
  55. package/blog/ja/intlayer_with_i18next.md +3 -0
  56. package/blog/ja/intlayer_with_next-i18next.md +3 -0
  57. package/blog/ja/intlayer_with_next-intl.md +3 -0
  58. package/blog/ja/intlayer_with_react-i18next.md +3 -0
  59. package/blog/ja/intlayer_with_react-intl.md +3 -0
  60. package/blog/ja/intlayer_with_vue-i18n.md +3 -0
  61. package/blog/ko/intlayer_with_i18next.md +3 -0
  62. package/blog/ko/intlayer_with_next-i18next.md +3 -0
  63. package/blog/ko/intlayer_with_next-intl.md +3 -0
  64. package/blog/ko/intlayer_with_react-i18next.md +3 -0
  65. package/blog/ko/intlayer_with_react-intl.md +3 -0
  66. package/blog/ko/intlayer_with_vue-i18n.md +3 -0
  67. package/blog/pl/intlayer_with_i18next.md +3 -0
  68. package/blog/pl/intlayer_with_next-i18next.md +3 -0
  69. package/blog/pl/intlayer_with_next-intl.md +3 -0
  70. package/blog/pl/intlayer_with_react-i18next.md +3 -0
  71. package/blog/pl/intlayer_with_react-intl.md +3 -0
  72. package/blog/pl/intlayer_with_vue-i18n.md +3 -0
  73. package/blog/pt/intlayer_with_i18next.md +3 -0
  74. package/blog/pt/intlayer_with_next-i18next.md +3 -0
  75. package/blog/pt/intlayer_with_next-intl.md +3 -0
  76. package/blog/pt/intlayer_with_react-i18next.md +3 -0
  77. package/blog/pt/intlayer_with_react-intl.md +3 -0
  78. package/blog/pt/intlayer_with_vue-i18n.md +3 -0
  79. package/blog/ru/intlayer_with_i18next.md +3 -0
  80. package/blog/ru/intlayer_with_next-i18next.md +3 -0
  81. package/blog/ru/intlayer_with_next-intl.md +3 -0
  82. package/blog/ru/intlayer_with_react-i18next.md +3 -0
  83. package/blog/ru/intlayer_with_react-intl.md +3 -0
  84. package/blog/ru/intlayer_with_vue-i18n.md +3 -0
  85. package/blog/tr/intlayer_with_i18next.md +3 -0
  86. package/blog/tr/intlayer_with_next-i18next.md +3 -0
  87. package/blog/tr/intlayer_with_next-intl.md +3 -0
  88. package/blog/tr/intlayer_with_react-i18next.md +3 -0
  89. package/blog/tr/intlayer_with_vue-i18n.md +3 -0
  90. package/blog/vi/intlayer_with_i18next.md +3 -0
  91. package/blog/vi/intlayer_with_next-i18next.md +3 -0
  92. package/blog/vi/intlayer_with_next-intl.md +3 -0
  93. package/blog/vi/intlayer_with_react-i18next.md +3 -0
  94. package/blog/vi/intlayer_with_react-intl.md +3 -0
  95. package/blog/vi/intlayer_with_vue-i18n.md +3 -0
  96. package/blog/zh/intlayer_with_i18next.md +3 -0
  97. package/blog/zh/intlayer_with_next-i18next.md +3 -0
  98. package/blog/zh/intlayer_with_next-intl.md +3 -0
  99. package/blog/zh/intlayer_with_react-i18next.md +3 -0
  100. package/blog/zh/intlayer_with_react-intl.md +3 -0
  101. package/blog/zh/intlayer_with_vue-i18n.md +3 -0
  102. package/docs/ar/intlayer_with_lynx+react.md +1 -1
  103. package/docs/ar/intlayer_with_vite+react.md +99 -331
  104. package/docs/ar/plugins/sync-json.md +3 -0
  105. package/docs/de/intlayer_with_lynx+react.md +1 -1
  106. package/docs/de/intlayer_with_vite+react.md +116 -380
  107. package/docs/de/plugins/sync-json.md +3 -0
  108. package/docs/en/intlayer_with_vite+react.md +6 -10
  109. package/docs/en/plugins/sync-json.md +3 -0
  110. package/docs/en-GB/intlayer_with_vite+react.md +62 -74
  111. package/docs/en-GB/plugins/sync-json.md +3 -0
  112. package/docs/es/intlayer_with_vite+react.md +101 -333
  113. package/docs/es/plugins/sync-json.md +3 -0
  114. package/docs/fr/intlayer_with_vite+react.md +101 -357
  115. package/docs/fr/plugins/sync-json.md +3 -0
  116. package/docs/hi/intlayer_with_vite+react.md +120 -333
  117. package/docs/hi/plugins/sync-json.md +3 -0
  118. package/docs/id/intlayer_with_vite+react.md +7 -13
  119. package/docs/id/plugins/sync-json.md +3 -0
  120. package/docs/it/intlayer_with_lynx+react.md +1 -1
  121. package/docs/it/intlayer_with_vite+react.md +121 -393
  122. package/docs/it/plugins/sync-json.md +3 -0
  123. package/docs/ja/intlayer_with_vite+react.md +106 -378
  124. package/docs/ja/plugins/sync-json.md +3 -0
  125. package/docs/ko/intlayer_with_lynx+react.md +1 -1
  126. package/docs/ko/intlayer_with_vite+react.md +90 -322
  127. package/docs/ko/plugins/sync-json.md +3 -0
  128. package/docs/pl/intlayer_with_vite+react.md +25 -21
  129. package/docs/pl/plugins/sync-json.md +3 -0
  130. package/docs/pt/intlayer_with_vite+react.md +96 -328
  131. package/docs/pt/plugins/sync-json.md +3 -0
  132. package/docs/ru/intlayer_with_lynx+react.md +1 -1
  133. package/docs/ru/intlayer_with_vite+react.md +109 -362
  134. package/docs/ru/plugins/sync-json.md +3 -0
  135. package/docs/tr/intlayer_with_vite+react.md +132 -366
  136. package/docs/tr/plugins/sync-json.md +3 -0
  137. package/docs/vi/intlayer_with_vite+react.md +16 -19
  138. package/docs/vi/plugins/sync-json.md +3 -0
  139. package/docs/zh/intlayer_with_tanstack.md +1 -1
  140. package/docs/zh/intlayer_with_vite+react.md +91 -374
  141. package/docs/zh/plugins/sync-json.md +3 -0
  142. package/frequent_questions/ar/customized_locale_list.md +1 -1
  143. package/frequent_questions/de/customized_locale_list.md +1 -1
  144. package/frequent_questions/en/customized_locale_list.md +1 -1
  145. package/frequent_questions/en-GB/customized_locale_list.md +1 -1
  146. package/frequent_questions/es/customized_locale_list.md +1 -1
  147. package/frequent_questions/fr/customized_locale_list.md +1 -1
  148. package/frequent_questions/hi/customized_locale_list.md +1 -1
  149. package/frequent_questions/id/customized_locale_list.md +1 -1
  150. package/frequent_questions/it/customized_locale_list.md +1 -1
  151. package/frequent_questions/ja/customized_locale_list.md +1 -1
  152. package/frequent_questions/ko/customized_locale_list.md +1 -1
  153. package/frequent_questions/pl/customized_locale_list.md +1 -1
  154. package/frequent_questions/pt/customized_locale_list.md +1 -1
  155. package/frequent_questions/ru/customized_locale_list.md +1 -1
  156. package/frequent_questions/tr/customized_locale_list.md +1 -1
  157. package/frequent_questions/vi/customized_locale_list.md +1 -1
  158. package/frequent_questions/zh/customized_locale_list.md +1 -1
  159. package/package.json +10 -9
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  createdAt: 2024-03-07
3
- updatedAt: 2024-03-07
4
- title: كيفية ترجمة تطبيق Vite and React – دليل i18n 2025
3
+ updatedAt: 2025-12-10
4
+ title: كيفية ترجمة تطبيق Vite و React – دليل i18n 2025
5
5
  description: تعلّم كيفية إضافة التدويل (i18n) إلى تطبيق Vite و React الخاص بك باستخدام Intlayer. اتبع هذا الدليل لجعل تطبيقك متعدد اللغات.
6
6
  keywords:
7
7
  - التدويل
@@ -16,23 +16,19 @@ slugs:
16
16
  - environment
17
17
  - vite-and-react
18
18
  applicationTemplate: https://github.com/aymericzip/intlayer-vite-react-template
19
- youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4---
19
+ youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
20
20
  history:
21
21
  - version: 5.5.10
22
22
  date: 2025-06-29
23
23
  changes: بداية السجل
24
24
  ---
25
25
 
26
- # البدء في التدويل (i18n) باستخدام Intlayer و Vite و React
26
+ # ترجمة موقعك الإلكتروني المبني بـ Vite و React باستخدام Intlayer | التدويل (i18n)
27
27
 
28
28
  ## جدول المحتويات
29
29
 
30
30
  <TOC/>
31
31
 
32
- <iframe title="The best i18n solution for Vite and React? Discover Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/dS9L7uJeak4?si=VaKmrYMmXjo3xpk2"/>
33
-
34
- راجع [نموذج التطبيق](https://github.com/aymericzip/intlayer-vite-react-template) على GitHub.
35
-
36
32
  ## ما هو Intlayer؟
37
33
 
38
34
  **Intlayer** هي مكتبة تدويل (i18n) مبتكرة ومفتوحة المصدر مصممة لتبسيط دعم اللغات المتعددة في تطبيقات الويب الحديثة.
@@ -48,6 +44,27 @@ history:
48
44
 
49
45
  ## دليل خطوة بخطوة لإعداد Intlayer في تطبيق Vite و React
50
46
 
47
+ <Tab defaultTab="video">
48
+ <TabItem label="فيديو" value="video">
49
+
50
+ <iframe title="أفضل حل للترجمة الدولية لـ Vite و React؟ اكتشف Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/dS9L7uJeak4?si=VaKmrYMmXjo3xpk2"/>
51
+
52
+ </TabItem>
53
+ <TabItem label="الرمز" value="code">
54
+
55
+ <iframe
56
+ src="https://stackblitz.com/github/aymericzip/intlayer-vite-react-template?embed=1&ctl=1&file=intlayer.config.ts"
57
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
58
+ title="مثال على CodeSandbox - كيفية تعريب تطبيقك باستخدام Intlayer"
59
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
60
+ loading="lazy"
61
+ />
62
+
63
+ </TabItem>
64
+ </Tab>
65
+
66
+ انظر [نموذج التطبيق](https://github.com/aymericzip/intlayer-vite-react-template) على GitHub.
67
+
51
68
  ### الخطوة 1: تثبيت التبعيات
52
69
 
53
70
  قم بتثبيت الحزم اللازمة باستخدام npm:
@@ -68,8 +85,7 @@ yarn add vite-intlayer --save-dev
68
85
  ```
69
86
 
70
87
  - **intlayer**
71
-
72
- الحزمة الأساسية التي توفر أدوات التدويل لإدارة التكوين، والترجمة، و[إعلان المحتوى](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/dictionary/get_started.md)، والترجمة البرمجية، و[أوامر CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/intlayer_cli.md).
88
+ الحزمة الأساسية التي توفر أدوات التدويل لإدارة التكوين، والترجمة، و[إعلان المحتوى](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md)، والترجمة البرمجية، و[أوامر CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/cli/index.md).
73
89
 
74
90
  - **react-intlayer**
75
91
  الحزمة التي تدمج Intlayer مع تطبيق React. توفر مزودي السياق (context providers) وخطافات (hooks) لتدويل React.
@@ -137,7 +153,7 @@ const config = {
137
153
  module.exports = config;
138
154
  ```
139
155
 
140
- > من خلال ملف التهيئة هذا، يمكنك إعداد عناوين URL محلية، وإعادة توجيه الوسيط، وأسماء ملفات تعريف الارتباط، وموقع وامتداد إعلانات المحتوى الخاصة بك، وتعطيل سجلات Intlayer في وحدة التحكم، والمزيد. للحصول على قائمة كاملة بالمعلمات المتاحة، راجع [توثيق التهيئة](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/configuration.md).
156
+ > من خلال ملف التهيئة هذا، يمكنك إعداد عناوين URL محلية، وإعادة توجيه الوسيط، وأسماء ملفات تعريف الارتباط، وموقع وامتداد إعلانات المحتوى الخاصة بك، وتعطيل سجلات Intlayer في وحدة التحكم، والمزيد. للحصول على قائمة كاملة بالمعلمات المتاحة، راجع [توثيق التهيئة](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md).
141
157
 
142
158
  ### الخطوة 3: دمج Intlayer في تهيئة Vite الخاصة بك
143
159
 
@@ -176,7 +192,7 @@ module.exports = defineConfig({
176
192
  });
177
193
  ```
178
194
 
179
- > يتم استخدام مكون Vite الإضافي `intlayer()` لدمج Intlayer مع Vite. يضمن بناء ملفات إعلان المحتوى ويراقبها في وضع التطوير. كما يعرّف متغيرات بيئة Intlayer داخل تطبيق Vite. بالإضافة إلى ذلك، يوفر أسماء مستعارة لتحسين الأداء.
195
+ يتم استخدام مكون Vite الإضافي `intlayer()` لدمج Intlayer مع Vite. يضمن بناء ملفات إعلان المحتوى ويراقبها في وضع التطوير. كما يعرّف متغيرات بيئة Intlayer داخل تطبيق Vite. بالإضافة إلى ذلك، يوفر أسماء مستعارة لتحسين الأداء.
180
196
 
181
197
  ### الخطوة 4: إعلان المحتوى الخاص بك
182
198
 
@@ -419,7 +435,7 @@ module.exports = appContent;
419
435
 
420
436
  > يمكن تعريف إعلانات المحتوى الخاصة بك في أي مكان في تطبيقك بمجرد تضمينها في دليل `contentDir` (افتراضيًا، `./src`). ويجب أن تطابق امتداد ملف إعلان المحتوى (افتراضيًا، `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
421
437
 
422
- > لمزيد من التفاصيل، راجع [توثيق إعلان المحتوى](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/dictionary/get_started.md).
438
+ > لمزيد من التفاصيل، راجع [توثيق إعلان المحتوى](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/dictionary/content_file.md).
423
439
 
424
440
  > إذا كان ملف المحتوى الخاص بك يتضمن كود TSX، يجب أن تفكر في استيراد `import React from "react";` في ملف المحتوى الخاص بك.
425
441
 
@@ -574,7 +590,7 @@ module.exports = App;
574
590
  > <img src={content.image.src.value} alt={content.image.value} />
575
591
  > ```
576
592
 
577
- > لمعرفة المزيد عن الخطاف `useIntlayer`، راجع [التوثيق](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/react-intlayer/useIntlayer.md).
593
+ > لمعرفة المزيد عن الخطاف `useIntlayer`، راجع [التوثيق](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/react-intlayer/useIntlayer.md).
578
594
 
579
595
  ### (اختياري) الخطوة 6: تغيير لغة المحتوى الخاص بك
580
596
 
@@ -626,7 +642,7 @@ const LocaleSwitcher = () => {
626
642
  };
627
643
  ```
628
644
 
629
- > لمعرفة المزيد عن الخطاف `useLocale`، راجع [التوثيق](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/react-intlayer/useLocale.md).
645
+ > لمعرفة المزيد عن الخطاف `useLocale`، راجع [التوثيق](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/react-intlayer/useLocale.md).
630
646
 
631
647
  ### (اختياري) الخطوة 7: إضافة التوجيه المحلي إلى تطبيقك
632
648
 
@@ -639,87 +655,15 @@ const LocaleSwitcher = () => {
639
655
  - https://example.com/fr/about
640
656
  ```
641
657
 
642
- > بشكل افتراضي، لا يتم إضافة بادئة للمسارات للغة الافتراضية. إذا كنت ترغب في إضافة بادئة للغة الافتراضية، يمكنك تعيين الخيار `middleware.prefixDefault` إلى `true` في إعداداتك. راجع [توثيق الإعدادات](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/configuration.md) لمزيد من المعلومات.
658
+ > بشكل افتراضي، لا يتم إضافة بادئة للمسارات للغة الافتراضية. إذا كنت ترغب في إضافة بادئة للغة الافتراضية، يمكنك تعيين الخيار `middleware.prefixDefault` إلى `true` في إعداداتك. راجع [توثيق الإعدادات](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md) لمزيد من المعلومات.
643
659
 
644
660
  لإضافة التوجيه المحلي إلى تطبيقك، يمكنك إنشاء مكون `LocaleRouter` الذي يلف مسارات تطبيقك ويتعامل مع التوجيه بناءً على اللغة. إليك مثالًا باستخدام [React Router](https://reactrouter.com/home):
645
661
 
646
662
  ```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
647
- // استيراد التبعيات والوظائف اللازمة
648
- import { type Locales, configuration, getPathWithoutLocale } from "intlayer"; // دوال مساعدة وأنواع من 'intlayer'
663
+ import { localeMap } from "intlayer"; // دوال مساعدة وأنواع من 'intlayer'
649
664
  import type { FC, PropsWithChildren } from "react"; // أنواع React للمكونات الوظيفية والخصائص
650
665
  import { IntlayerProvider } from "react-intlayer"; // مزود سياق التدويل
651
- import {
652
- BrowserRouter,
653
- Routes,
654
- Route,
655
- Navigate,
656
- useLocation,
657
- } from "react-router-dom"; // مكونات الموجه لإدارة التنقل
658
-
659
- // تفكيك التكوين من Intlayer
660
- const { internationalization, middleware } = configuration;
661
- const { locales, defaultLocale } = internationalization;
662
-
663
- /**
664
- * مكون يتعامل مع التدويل ويغلف الأطفال بسياق اللغة المناسب.
665
- * يدير اكتشاف اللغة بناءً على عنوان URL والتحقق منها.
666
- */
667
- const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
668
- children,
669
- locale,
670
- }) => {
671
- const { pathname, search } = useLocation(); // الحصول على مسار URL الحالي
672
-
673
- // تحديد اللغة الحالية، والرجوع إلى اللغة الافتراضية إذا لم يتم توفيرها
674
- const currentLocale = locale ?? defaultLocale;
675
-
676
- // إزالة بادئة اللغة من المسار لبناء مسار أساسي
677
- const pathWithoutLocale = getPathWithoutLocale(
678
- pathname // مسار URL الحالي
679
- );
680
-
681
- /**
682
- * إذا كانت middleware.prefixDefault صحيحة، يجب دائمًا إضافة بادئة اللغة الافتراضية.
683
- */
684
- if (middleware.prefixDefault) {
685
- // التحقق من صحة اللغة
686
- if (!locale || !locales.includes(locale)) {
687
- // إعادة التوجيه إلى اللغة الافتراضية مع المسار المحدث
688
- return (
689
- <Navigate
690
- to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
691
- replace // استبدال الإدخال الحالي في السجل بالإدخال الجديد
692
- />
693
- );
694
- }
695
-
696
- // تغليف العناصر الفرعية بـ IntlayerProvider وتعيين اللغة الحالية
697
- return (
698
- <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
699
- );
700
- } else {
701
- /**
702
- * عندما تكون middleware.prefixDefault خاطئة، لا يتم إضافة بادئة للغة الافتراضية.
703
- * تأكد من أن اللغة الحالية صالحة وليست اللغة الافتراضية.
704
- */
705
- if (
706
- currentLocale.toString() !== defaultLocale.toString() &&
707
- !locales
708
- .filter(
709
- (locale) => locale.toString() !== defaultLocale.toString() // استبعاد اللغة الافتراضية
710
- )
711
- .includes(currentLocale) // التحقق مما إذا كانت اللغة الحالية موجودة في قائمة اللغات الصالحة
712
- ) {
713
- // إعادة التوجيه إلى المسار بدون بادئة اللغة
714
- return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
715
- }
716
-
717
- // تغليف العناصر الفرعية بـ IntlayerProvider وتعيين اللغة الحالية
718
- return (
719
- <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
720
- );
721
- }
722
- };
666
+ import { BrowserRouter, Route, Routes } from "react-router-dom"; // مكونات الموجه لإدارة التنقل
723
667
 
724
668
  /**
725
669
  * مكون راوتر يقوم بإعداد مسارات خاصة بكل لغة.
@@ -728,256 +672,81 @@ const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
728
672
  export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
729
673
  <BrowserRouter>
730
674
  <Routes>
731
- {locales
732
- .filter(
733
- (locale) => middleware.prefixDefault || locale !== defaultLocale
734
- )
735
- .map((locale) => (
736
- <Route
737
- // نمط المسار لالتقاط اللغة (مثل /en/، /fr/) ومطابقة جميع المسارات التالية
738
- path={`/${locale}/*`}
739
- key={locale}
740
- element={<AppLocalized locale={locale}>{children}</AppLocalized>} // يلف الأطفال بإدارة اللغة
741
- />
742
- ))}
743
-
744
- {
745
- // إذا كان تعطيل بادئة اللغة الافتراضية، يتم عرض الأطفال مباشرة في المسار الجذري
746
- !middleware.prefixDefault && (
747
- <Route
748
- path="*"
749
- element={
750
- <AppLocalized locale={defaultLocale}>{children}</AppLocalized>
751
- } // يلف الأطفال بإدارة اللغة
752
- />
753
- )
754
- }
675
+ {localeMap(({ locale, urlPrefix }) => (
676
+ <Route
677
+ // نمط المسار لالتقاط اللغة (مثل /en/، /fr/) ومطابقة جميع المسارات التالية
678
+ path={`${urlPrefix}/*`}
679
+ key={locale}
680
+ element={
681
+ <IntlayerProvider locale={locale}>{children}</IntlayerProvider>
682
+ } // يلف الأطفال بإدارة اللغة
683
+ />
684
+ ))}
755
685
  </Routes>
756
686
  </BrowserRouter>
757
687
  );
758
688
  ```
759
689
 
760
690
  ```jsx fileName="src/components/LocaleRouter.mjx" codeFormat="esm"
761
- // استيراد التبعيات والوظائف اللازمة
762
- import { configuration, getPathWithoutLocale } from "intlayer"; // وظائف وأصناف مساعدة من 'intlayer'
763
- // وظائف وأصناف مساعدة من 'intlayer'
764
- import { IntlayerProvider } from "react-intlayer"; // مزود لسياق التدويل
765
- import {
766
- BrowserRouter,
767
- Routes,
768
- Route,
769
- Navigate,
770
- useLocation,
771
- } from "react-router-dom"; // مكونات الموجه لإدارة التنقل
772
-
773
- // تفكيك التكوين من Intlayer
774
- const { internationalization, middleware } = configuration;
775
- const { locales, defaultLocale } = internationalization;
776
-
777
- /**
778
- * مكون يتعامل مع التدويل ويغلف الأطفال بسياق اللغة المناسب.
779
- * يدير اكتشاف اللغة بناءً على عنوان URL والتحقق من صحتها.
780
- */
781
- const AppLocalized = ({ children, locale }) => {
782
- const { pathname, search } = useLocation(); // الحصول على مسار URL الحالي
783
-
784
- // تحديد اللغة الحالية، والرجوع إلى اللغة الافتراضية إذا لم يتم توفيرها
785
- const currentLocale = locale ?? defaultLocale;
786
-
787
- // إزالة بادئة اللغة من المسار لبناء مسار أساسي
788
- const pathWithoutLocale = getPathWithoutLocale(
789
- pathname // مسار URL الحالي
790
- );
791
-
792
- /**
793
- * إذا كانت middleware.prefixDefault صحيحة، يجب دائمًا إضافة بادئة اللغة الافتراضية.
794
- */
795
- if (middleware.prefixDefault) {
796
- // التحقق من صحة اللغة
797
- if (!locale || !locales.includes(locale)) {
798
- // إعادة التوجيه إلى اللغة الافتراضية مع المسار المحدث
799
- return (
800
- <Navigate
801
- to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
802
- replace // استبدال إدخال السجل الحالي بالإدخال الجديد
803
- />
804
- );
805
- }
806
-
807
- // تغليف العناصر الفرعية بمزود Intlayer وتعيين اللغة الحالية
808
- return (
809
- <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
810
- );
811
- } else {
812
- /**
813
- * عندما تكون middleware.prefixDefault خاطئة، لا يتم إضافة بادئة للغة الافتراضية.
814
- * تأكد من أن اللغة الحالية صالحة وليست اللغة الافتراضية.
815
- */
816
- if (
817
- currentLocale.toString() !== defaultLocale.toString() &&
818
- !locales
819
- .filter(
820
- (locale) => locale.toString() !== defaultLocale.toString() // استبعاد اللغة الافتراضية
821
- )
822
- .includes(currentLocale) // التحقق مما إذا كانت اللغة الحالية موجودة في قائمة اللغات الصالحة
823
- ) {
824
- // إعادة التوجيه إلى المسار بدون بادئة اللغة
825
- return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
826
- }
827
-
828
- // تغليف العناصر الفرعية بمزود Intlayer وتعيين اللغة الحالية
829
- return (
830
- <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
831
- );
832
- }
833
- };
691
+ import { localeMap } from 'intlayer'; // وظائف وأصناف مساعدة من 'intlayer'
692
+ import type { FC, PropsWithChildren } from 'react'; // أنواع React للمكونات الوظيفية والخصائص
693
+ import { IntlayerProvider } from 'react-intlayer'; // مزود لسياق التدويل
694
+ import { BrowserRouter, Route, Routes } from 'react-router-dom'; // مكونات الموجه لإدارة التنقل
834
695
 
835
696
  /**
836
697
  * مكون راوتر يقوم بإعداد مسارات خاصة بكل لغة.
837
698
  * يستخدم React Router لإدارة التنقل وعرض المكونات المحلية.
838
699
  */
839
- export const LocaleRouter = ({ children }) => (
700
+ export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
840
701
  <BrowserRouter>
841
702
  <Routes>
842
- {locales
843
- .filter(
844
- (locale) => middleware.prefixDefault || locale !== defaultLocale
845
- )
846
- .map((locale) => (
847
- <Route
848
- // نمط المسار لالتقاط اللغة (مثل /en/، /fr/) ومطابقة جميع المسارات التالية
849
- path={`/${locale}/*`}
850
- key={locale}
851
- element={<AppLocalized locale={locale}>{children}</AppLocalized>} // يلف الأطفال بإدارة اللغة
852
- />
853
- ))}
854
-
855
- {
856
- // إذا كان تعطيل بادئة اللغة الافتراضية، يتم عرض الأطفال مباشرة في المسار الجذري
857
- !middleware.prefixDefault && (
858
- <Route
859
- path="*"
860
- element={
861
- <AppLocalized locale={defaultLocale}>{children}</AppLocalized>
862
- } // يلف الأطفال بإدارة اللغة
863
- />
864
- )
865
- }
703
+ {localeMap(({ locale, urlPrefix }) => (
704
+ <Route
705
+ // نمط المسار لالتقاط اللغة (مثل /en/، /fr/) ومطابقة جميع المسارات التالية
706
+ path={`${urlPrefix}/*`}
707
+ key={locale}
708
+ element={
709
+ <IntlayerProvider locale={locale}>{children}</IntlayerProvider>
710
+ } // يلف الأطفال بإدارة اللغة
711
+ />
712
+ ))}
866
713
  </Routes>
867
714
  </BrowserRouter>
868
715
  );
869
716
  ```
870
717
 
871
718
  ```jsx fileName="src/components/LocaleRouter.cjx" codeFormat="commonjs"
872
- // استيراد التبعيات والوظائف اللازمة
873
- const { configuration, getPathWithoutLocale } = require("intlayer"); // وظائف مساعدة وأنواع من 'intlayer'
874
- const { IntlayerProvider, useLocale } = require("react-intlayer"); // موفر لسياق التدويل
875
- const {
876
- BrowserRouter,
877
- Routes,
878
- Route,
879
- Navigate,
880
- useLocation,
881
- } = require("react-router-dom"); // مكونات الموجه لإدارة التنقل
882
-
883
- // تفكيك التكوين من Intlayer
884
- const { internationalization, middleware } = configuration;
885
- const { locales, defaultLocale } = internationalization;
886
-
887
- /**
888
- * مكون يتعامل مع التدويل ويغلف الأطفال بسياق اللغة المناسب.
889
- * يدير اكتشاف اللغة بناءً على عنوان URL والتحقق منها.
890
- */
891
- const AppLocalized = ({ children, locale }) => {
892
- const { pathname, search } = useLocation(); // الحصول على مسار URL الحالي
893
-
894
- // تحديد اللغة الحالية، والرجوع إلى اللغة الافتراضية إذا لم يتم توفيرها
895
- const currentLocale = locale ?? defaultLocale;
896
-
897
- // إزالة بادئة اللغة من المسار لبناء مسار أساسي
898
- const pathWithoutLocale = getPathWithoutLocale(
899
- pathname // مسار URL الحالي
900
- );
901
-
902
- /**
903
- * إذا كانت middleware.prefixDefault صحيحة، يجب دائمًا إضافة بادئة اللغة الافتراضية.
904
- */
905
- if (middleware.prefixDefault) {
906
- // التحقق من صحة اللغة
907
- if (!locale || !locales.includes(locale)) {
908
- // إعادة التوجيه إلى اللغة الافتراضية مع المسار المحدث
909
- return (
910
- <Navigate
911
- to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
912
- replace // استبدال الإدخال الحالي في السجل بالإدخال الجديد
913
- />
914
- );
915
- }
916
-
917
- // تغليف العناصر الفرعية بمزود Intlayer وتعيين اللغة الحالية
918
- return (
919
- <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
920
- );
921
- } else {
922
- /**
923
- * عندما تكون middleware.prefixDefault خاطئة، لا يتم إضافة بادئة للغة الافتراضية.
924
- * تأكد من أن اللغة الحالية صالحة وليست اللغة الافتراضية.
925
- */
926
- if (
927
- currentLocale.toString() !== defaultLocale.toString() &&
928
- !locales
929
- .filter(
930
- (locale) => locale.toString() !== defaultLocale.toString() // استبعاد اللغة الافتراضية
931
- )
932
- .includes(currentLocale) // التحقق مما إذا كانت اللغة الحالية ضمن قائمة اللغات الصالحة
933
- ) {
934
- // إعادة التوجيه إلى المسار بدون بادئة اللغة
935
- return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
936
- }
937
-
938
- // تغليف العناصر الفرعية بمزود Intlayer وتعيين اللغة الحالية
939
- return (
940
- <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
941
- );
942
- }
943
- };
719
+ const { localeMap } = require("intlayer"); // وظائف مساعدة وأنواع من 'intlayer'
720
+ const React = require("react"); // استيراد React
721
+ const { IntlayerProvider } = require("react-intlayer"); // موفر لسياق التدويل
722
+ const { BrowserRouter, Route, Routes } = require("react-router-dom"); // مكونات الموجه لإدارة التنقل
944
723
 
945
724
  /**
946
725
  * مكون راوتر يقوم بإعداد مسارات خاصة بكل لغة.
947
726
  * يستخدم React Router لإدارة التنقل وعرض المكونات المترجمة.
948
727
  */
949
- const LocaleRouter = ({ children }) => (
950
- <BrowserRouter>
951
- <Routes>
952
- {locales
953
- .filter(
954
- (locale) => middleware.prefixDefault || locale !== defaultLocale
955
- )
956
- .map((locale) => (
957
- <Route
958
- // نمط المسار لالتقاط اللغة (مثل /en/، /fr/) ومطابقة جميع المسارات التالية
959
- path={`/${locale}/*`}
960
- key={locale}
961
- element={<AppLocalized locale={locale}>{children}</AppLocalized>} // يلف الأطفال مع إدارة اللغة
962
- />
963
- ))}
728
+ const LocaleRouter = ({ children }) =>
729
+ React.createElement(
730
+ BrowserRouter,
731
+ {},
732
+ React.createElement(
733
+ Routes,
734
+ {},
735
+ localeMap(({ locale, urlPrefix }) =>
736
+ React.createElement(Route, {
737
+ path: `${urlPrefix}/*`,
738
+ key: locale,
739
+ element: React.createElement(IntlayerProvider, { locale }, children),
740
+ })
741
+ )
742
+ )
743
+ );
964
744
 
965
- {
966
- // إذا تم تعطيل إضافة بادئة اللغة الافتراضية، يتم عرض الأطفال مباشرة في المسار الجذري
967
- !middleware.prefixDefault && (
968
- <Route
969
- path="*"
970
- element={
971
- <AppLocalized locale={defaultLocale}>{children}</AppLocalized>
972
- } // يلف الأطفال مع إدارة اللغة
973
- />
974
- )
975
- }
976
- </Routes>
977
- </BrowserRouter>
978
- );
745
+ exports.LocaleRouter = LocaleRouter;
979
746
  ```
980
747
 
748
+ > ملاحظة: إذا كنت تستخدم `routing.mode: 'no-prefix' | 'search-params'`، فمن المحتمل ألا تحتاج إلى استخدام دالة `localeMap`.
749
+
981
750
  ثم يمكنك استخدام مكون `LocaleRouter` في تطبيقك:
982
751
 
983
752
  ```tsx fileName="src/App.tsx" codeFormat="typescript"
@@ -1019,6 +788,8 @@ const App = () => (
1019
788
 
1020
789
  بالتوازي، يمكنك أيضًا استخدام `intlayerProxy` لإضافة التوجيه من جانب الخادم إلى تطبيقك. سيقوم هذا المكون الإضافي بالكشف تلقائيًا عن اللغة الحالية بناءً على عنوان URL وتعيين ملف تعريف الارتباط المناسب للغة. إذا لم يتم تحديد لغة، فسيحدد المكون الإضافي اللغة الأنسب بناءً على تفضيلات لغة متصفح المستخدم. إذا لم يتم الكشف عن أي لغة، فسيتم إعادة التوجيه إلى اللغة الافتراضية.
1021
790
 
791
+ > يرجى ملاحظة أنه لاستخدام `intlayerProxy` في بيئة الإنتاج، تحتاج إلى نقل حزمة `vite-intlayer` من `devDependencies` إلى `dependencies`.
792
+
1022
793
  ```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
1023
794
  import { defineConfig } from "vite";
1024
795
  import react from "@vitejs/plugin-react-swc";
@@ -1251,14 +1022,14 @@ const LocaleSwitcher = () => {
1251
1022
 
1252
1023
  > مراجع التوثيق:
1253
1024
  >
1254
- > - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/react-intlayer/useLocale.md)
1255
- > - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/intlayer/getLocaleName.md)
1256
- > - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/intlayer/getLocalizedUrl.md)
1257
- > - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/intlayer/getHTMLTextDir.md)
1025
+ > - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/react-intlayer/useLocale.md)
1026
+ > - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getLocaleName.md)
1027
+ > - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getLocalizedUrl.md)
1028
+ > - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getHTMLTextDir.md)
1258
1029
  > - [`hrefLang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
1259
1030
  > - [`lang` attribute](https://developer.mozilla.org/ar/docs/Web/HTML/Global_attributes/lang)
1260
- > - [`dir` attribute`](https://developer.mozilla.org/ar/docs/Web/HTML/Global_attributes/dir)
1261
- > - [`aria-current` attribute`](https://developer.mozilla.org/ar/docs/Web/Accessibility/ARIA/Attributes/aria-current)
1031
+ > - [`dir` attribute](https://developer.mozilla.org/ar/docs/Web/HTML/Global_attributes/dir)
1032
+ > - [`aria-current` attribute](https://developer.mozilla.org/ar/docs/Web/Accessibility/ARIA/Attributes/aria-current)
1262
1033
 
1263
1034
  فيما يلي الخطوة التاسعة المحدثة مع توضيحات إضافية وأمثلة كود محسنة:
1264
1035
 
@@ -1451,11 +1222,10 @@ import {
1451
1222
  } from "react";
1452
1223
  import { useLocale } from "react-intlayer";
1453
1224
 
1454
- export interface LinkProps
1455
- extends DetailedHTMLProps<
1456
- AnchorHTMLAttributes<HTMLAnchorElement>,
1457
- HTMLAnchorElement
1458
- > {}
1225
+ export interface LinkProps extends DetailedHTMLProps<
1226
+ AnchorHTMLAttributes<HTMLAnchorElement>,
1227
+ HTMLAnchorElement
1228
+ > {}
1459
1229
 
1460
1230
  /**
1461
1231
  * دالة مساعدة للتحقق مما إذا كان عنوان URL معين خارجيًا.
@@ -1582,9 +1352,9 @@ Link.displayName = "Link";
1582
1352
 
1583
1353
  يستخدم Intlayer توسيع الوحدات (module augmentation) للاستفادة من TypeScript وجعل قاعدة الشيفرة الخاصة بك أقوى.
1584
1354
 
1585
- ![نص بديل](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
1355
+ ![الإكمال التلقائي](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1586
1356
 
1587
- ![نص بديل](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
1357
+ ![خطأ في الترجمة](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1588
1358
 
1589
1359
  تأكد من أن تكوين TypeScript الخاص بك يتضمن الأنواع التي تم إنشاؤها تلقائيًا.
1590
1360
 
@@ -1604,8 +1374,8 @@ Link.displayName = "Link";
1604
1374
 
1605
1375
  للقيام بذلك، يمكنك إضافة التعليمات التالية إلى ملف `.gitignore` الخاص بك:
1606
1376
 
1607
- ```plaintext
1608
- # ترجم Vite and React باستخدام Intlayer | التدويل (i18n)
1377
+ ```plaintext fileName=".gitignore"
1378
+ # تجاهل الملفات التي تم إنشاؤها بواسطة Intlayer
1609
1379
  .intlayer
1610
1380
  ```
1611
1381
 
@@ -1628,6 +1398,4 @@ Link.displayName = "Link";
1628
1398
 
1629
1399
  ### التقدم أكثر
1630
1400
 
1631
- للتقدم أكثر، يمكنك تنفيذ [المحرر المرئي](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/intlayer_visual_editor.md) أو إخراج محتواك باستخدام [نظام إدارة المحتوى (CMS)](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/intlayer_CMS.md).
1632
-
1633
- ---
1401
+ للتقدم أكثر، يمكنك تنفيذ [المحرر المرئي](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) أو إخراج محتواك باستخدام [نظام إدارة المحتوى (CMS)](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md).
@@ -22,6 +22,7 @@ slugs:
22
22
  - doc
23
23
  - plugin
24
24
  - sync-json
25
+ youtubeVideo: https://www.youtube.com/watch?v=MpGMxniDHNg
25
26
  history:
26
27
  - version: 6.1.6
27
28
  date: 2025-10-05
@@ -30,6 +31,8 @@ history:
30
31
 
31
32
  ## مزامنة JSON (جسور التدويل)
32
33
 
34
+ <iframe title="كيفية الحفاظ على مزامنة ترجمات JSON الخاصة بك مع Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/MpGMxniDHNg?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
35
+
33
36
  استخدم Intlayer كمكون إضافي إلى نظام التدويل (i18n) الحالي لديك. يحافظ هذا المكون على مزامنة رسائل JSON الخاصة بك مع قواميس Intlayer بحيث يمكنك:
34
37
 
35
38
  - الاحتفاظ بـ i18next، next-intl، react-intl، vue-i18n، next-translate، nuxt-i18n، Solid-i18next، svelte-i18n، وغيرها.
@@ -410,7 +410,7 @@ Um die Sprache innerhalb Ihrer Komponenten zu wechseln, können Sie die `setLoca
410
410
  ```tsx fileName="src/components/LocaleSwitcher.tsx"
411
411
  import { type FC } from "react";
412
412
  import { getLocaleName } from "intlayer";
413
- import { useLocale } from "intlayer";
413
+ import { useLocale } from "react-intlayer";
414
414
 
415
415
  export const LocaleSwitcher: FC = () => {
416
416
  const { setLocale, availableLocales, locale } = useLocale();