@intlayer/docs 7.3.11 → 7.3.13

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 (90) hide show
  1. package/dist/cjs/generated/docs.entry.cjs +19 -0
  2. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  3. package/dist/esm/generated/docs.entry.mjs +19 -0
  4. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  5. package/dist/types/generated/docs.entry.d.ts +1 -0
  6. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  7. package/docs/ar/intlayer_with_nuxt.md +294 -438
  8. package/docs/ar/intlayer_with_react_router_v7.md +33 -4
  9. package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +516 -0
  10. package/docs/ar/intlayer_with_tanstack.md +2 -12
  11. package/docs/ar/intlayer_with_vite+vue.md +1 -0
  12. package/docs/de/intlayer_with_nuxt.md +284 -410
  13. package/docs/de/intlayer_with_react_router_v7.md +33 -4
  14. package/docs/de/intlayer_with_react_router_v7_fs_routes.md +573 -0
  15. package/docs/de/intlayer_with_tanstack.md +1 -0
  16. package/docs/de/intlayer_with_vite+vue.md +1 -0
  17. package/docs/en/intlayer_with_nuxt.md +237 -341
  18. package/docs/en/intlayer_with_react_router_v7.md +24 -0
  19. package/docs/en/intlayer_with_react_router_v7_fs_routes.md +570 -0
  20. package/docs/en/intlayer_with_tanstack.md +2 -12
  21. package/docs/en/intlayer_with_vite+vue.md +49 -48
  22. package/docs/en-GB/intlayer_with_nuxt.md +254 -378
  23. package/docs/en-GB/intlayer_with_react_router_v7.md +33 -4
  24. package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +513 -0
  25. package/docs/en-GB/intlayer_with_tanstack.md +2 -12
  26. package/docs/en-GB/intlayer_with_vite+vue.md +1 -0
  27. package/docs/es/intlayer_with_nuxt.md +271 -390
  28. package/docs/es/intlayer_with_react_router_v7.md +33 -4
  29. package/docs/es/intlayer_with_react_router_v7_fs_routes.md +575 -0
  30. package/docs/es/intlayer_with_tanstack.md +1 -0
  31. package/docs/es/intlayer_with_vite+vue.md +1 -2
  32. package/docs/fr/intlayer_with_nuxt.md +278 -405
  33. package/docs/fr/intlayer_with_react_router_v7.md +34 -5
  34. package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +574 -0
  35. package/docs/fr/intlayer_with_tanstack.md +1 -0
  36. package/docs/fr/intlayer_with_vite+vue.md +1 -0
  37. package/docs/hi/intlayer_with_nuxt.md +303 -447
  38. package/docs/hi/intlayer_with_react_router_v7.md +33 -4
  39. package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +518 -0
  40. package/docs/hi/intlayer_with_tanstack.md +2 -12
  41. package/docs/hi/intlayer_with_vite+vue.md +1 -0
  42. package/docs/id/intlayer_with_nuxt.md +266 -395
  43. package/docs/id/intlayer_with_react_router_v7.md +29 -4
  44. package/docs/id/intlayer_with_react_router_v7_fs_routes.md +521 -0
  45. package/docs/id/intlayer_with_tanstack.md +2 -12
  46. package/docs/id/intlayer_with_vite+vue.md +1 -0
  47. package/docs/it/intlayer_with_nuxt.md +299 -423
  48. package/docs/it/intlayer_with_react_router_v7.md +33 -4
  49. package/docs/it/intlayer_with_react_router_v7_fs_routes.md +574 -0
  50. package/docs/it/intlayer_with_tanstack.md +1 -0
  51. package/docs/ja/intlayer_with_nuxt.md +309 -432
  52. package/docs/ja/intlayer_with_react_router_v7.md +33 -4
  53. package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +574 -0
  54. package/docs/ja/intlayer_with_tanstack.md +2 -12
  55. package/docs/ja/intlayer_with_vite+vue.md +1 -0
  56. package/docs/ko/intlayer_with_nuxt.md +295 -422
  57. package/docs/ko/intlayer_with_react_router_v7.md +33 -4
  58. package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +515 -0
  59. package/docs/ko/intlayer_with_tanstack.md +2 -12
  60. package/docs/ko/intlayer_with_vite+vue.md +1 -0
  61. package/docs/pl/intlayer_with_nuxt.md +273 -476
  62. package/docs/pl/intlayer_with_react_router_v7.md +32 -5
  63. package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +615 -0
  64. package/docs/pl/intlayer_with_tanstack.md +2 -12
  65. package/docs/pl/intlayer_with_vite+vue.md +1 -0
  66. package/docs/pt/intlayer_with_nuxt.md +277 -420
  67. package/docs/pt/intlayer_with_react_router_v7.md +28 -0
  68. package/docs/pt/intlayer_with_tanstack.md +1 -0
  69. package/docs/ru/intlayer_with_nuxt.md +287 -425
  70. package/docs/ru/intlayer_with_react_router_v7.md +33 -4
  71. package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +574 -0
  72. package/docs/ru/intlayer_with_tanstack.md +1 -0
  73. package/docs/ru/intlayer_with_vite+vue.md +1 -0
  74. package/docs/tr/intlayer_with_nuxt.md +313 -406
  75. package/docs/tr/intlayer_with_react_router_v7.md +33 -4
  76. package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +572 -0
  77. package/docs/tr/intlayer_with_tanstack.md +2 -12
  78. package/docs/tr/intlayer_with_vite+vue.md +1 -0
  79. package/docs/vi/intlayer_with_nuxt.md +273 -418
  80. package/docs/vi/intlayer_with_react_router_v7.md +29 -4
  81. package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +523 -0
  82. package/docs/vi/intlayer_with_tanstack.md +2 -12
  83. package/docs/vi/intlayer_with_vite+vue.md +1 -0
  84. package/docs/zh/intlayer_with_nuxt.md +300 -461
  85. package/docs/zh/intlayer_with_react_router_v7.md +33 -4
  86. package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +516 -0
  87. package/docs/zh/intlayer_with_tanstack.md +2 -12
  88. package/docs/zh/intlayer_with_vite+vue.md +1 -0
  89. package/package.json +10 -11
  90. package/src/generated/docs.entry.ts +19 -0
@@ -18,6 +18,7 @@ slugs:
18
18
  - vite-and-react
19
19
  - react-router-v7
20
20
  applicationTemplate: https://github.com/aymericzip/intlayer-react-router-v7-template
21
+ youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
21
22
  history:
22
23
  - version: 6.1.5
23
24
  date: 2025-10-03
@@ -31,6 +32,10 @@ history:
31
32
 
32
33
  يوضح هذا الدليل كيفية دمج **Intlayer** لتحقيق التدويل السلس في مشاريع React Router v7 مع توجيه يدعم اللغة المحلية، ودعم TypeScript، وممارسات تطوير حديثة.
33
34
 
35
+ ## Table of Contents
36
+
37
+ <TOC/>
38
+
34
39
  ## ما هو Intlayer؟
35
40
 
36
41
  **Intlayer** هو مكتبة تدويل (i18n) مبتكرة ومفتوحة المصدر مصممة لتبسيط دعم تعدد اللغات في تطبيقات الويب الحديثة.
@@ -73,6 +78,29 @@ pnpm add vite-intlayer --save-dev
73
78
 
74
79
  ### الخطوة 2: تكوين مشروعك
75
80
 
81
+ ## دليل خطوة بخطوة لإعداد Intlayer في تطبيق React Router v7 مع مسارات قائمة على نظام الملفات
82
+
83
+ <Tab defaultTab="video">
84
+ <TabItem label="Video" value="video">
85
+
86
+ <iframe title="How to translate your React Router v7 app using 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?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
87
+
88
+ </TabItem>
89
+ <TabItem label="Code" value="code">
90
+
91
+ <iframe
92
+ src="https://stackblitz.com/github/aymericzip/intlayer-react-router-v7-template?embed=1&ctl=1&file=intlayer.config.ts"
93
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
94
+ title="Demo CodeSandbox - How to Internationalize your application using Intlayer"
95
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
96
+ loading="lazy"
97
+ />
98
+
99
+ </TabItem>
100
+ </Tab>
101
+
102
+ See [Application Template](https://github.com/aymericzip/intlayer-react-router-v7-template) on GitHub.
103
+
76
104
  قم بإنشاء ملف تكوين لتكوين لغات تطبيقك:
77
105
 
78
106
  ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
@@ -258,7 +286,7 @@ export const LocalizedLink: FC<LinkProps> = (props) => {
258
286
  في حال رغبت في التنقل إلى المسارات المحلية، يمكنك استخدام الخطاف `useLocalizedNavigate`:
259
287
 
260
288
  ```tsx fileName="app/hooks/useLocalizedNavigate.ts"
261
- import { useLocale } from "intlayer";
289
+ import { useLocale } from "react-intlayer";
262
290
  import { type NavigateOptions, type To, useNavigate } from "react-router";
263
291
 
264
292
  import { locacalizeTo } from "~/components/localized-link";
@@ -316,6 +344,7 @@ import {
316
344
  getLocaleName,
317
345
  getLocalizedUrl,
318
346
  getPathWithoutLocale,
347
+ Locales,
319
348
  } from "intlayer";
320
349
  import { setLocaleInStorage, useIntlayer, useLocale } from "react-intlayer";
321
350
  import { Link, useLocation } from "react-router";
@@ -409,13 +438,13 @@ export default function RootLayout() {
409
438
  > لاحظ أنه لاستخدام `intlayerProxy` في بيئة الإنتاج، تحتاج إلى نقل حزمة `vite-intlayer` من `devDependencies` إلى `dependencies`.
410
439
 
411
440
  ```typescript {3,7} fileName="vite.config.ts"
441
+ import { reactRouter } from "@react-router/dev/vite";
412
442
  import { defineConfig } from "vite";
413
- import react from "@vitejs/plugin-react-swc";
414
443
  import { intlayer, intlayerProxy } from "vite-intlayer";
444
+ import tsconfigPaths from "vite-tsconfig-paths";
415
445
 
416
- // https://vitejs.dev/config/
417
446
  export default defineConfig({
418
- plugins: [react(), intlayer(), intlayerProxy()],
447
+ plugins: [reactRouter(), tsconfigPaths(), intlayer(), intlayerProxy()],
419
448
  });
420
449
  ```
421
450
 
@@ -0,0 +1,516 @@
1
+ ---
2
+ createdAt: 2025-09-04
3
+ updatedAt: 2025-10-03
4
+ title: كيفية ترجمة تطبيق React Router v7 – دليل i18n 2025
5
+ description: تعلّم كيفية إضافة التدويل (i18n) إلى تطبيق React Router v7 الخاص بك باستخدام Intlayer. اتبع هذا الدليل الشامل لجعل تطبيقك متعدد اللغات مع توجيه يدعم اللغة المحلية.
6
+ keywords:
7
+ - التدويل
8
+ - التوثيق
9
+ - Intlayer
10
+ - React Router v7
11
+ - React
12
+ - i18n
13
+ - TypeScript
14
+ - توجيه اللغة المحلية
15
+ slugs:
16
+ - doc
17
+ - environment
18
+ - vite-and-react
19
+ - react-router-v7-fs-routes
20
+ applicationTemplate: https://github.com/aymericzip/intlayer-react-router-v7-template
21
+ youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
22
+ history:
23
+ - version: 6.1.5
24
+ date: 2025-10-03
25
+ changes: تحديث الوثيقة
26
+ - version: 5.8.2
27
+ date: 2025-09-04
28
+ changes: أضيف دعم React Router v7
29
+ ---
30
+
31
+ # ترجم React Router v7 باستخدام Intlayer | التدويل (i18n)
32
+
33
+ يوضح هذا الدليل كيفية دمج **Intlayer** لتحقيق التدويل السلس في مشاريع React Router v7 مع توجيه يدعم اللغة المحلية، ودعم TypeScript، وممارسات تطوير حديثة.
34
+
35
+ ## Table of Contents
36
+
37
+ <TOC/>
38
+
39
+ ## ما هو Intlayer؟
40
+
41
+ **Intlayer** هو مكتبة تدويل (i18n) مبتكرة ومفتوحة المصدر مصممة لتبسيط دعم تعدد اللغات في تطبيقات الويب الحديثة.
42
+
43
+ مع Intlayer، يمكنك:
44
+
45
+ - **إدارة الترجمات بسهولة** باستخدام قواميس تعبيرية على مستوى المكونات.
46
+ - **توطين البيانات الوصفية، والمسارات، والمحتوى بشكل ديناميكي**.
47
+ - **ضمان دعم TypeScript** مع أنواع مولدة تلقائيًا، مما يحسن الإكمال التلقائي واكتشاف الأخطاء.
48
+ - **الاستفادة من الميزات المتقدمة**، مثل الكشف الديناميكي عن اللغة المحلية والتبديل بينها.
49
+ - **تمكين التوجيه المدرك للغة المحلية** باستخدام نظام التوجيه القائم على التكوين في React Router v7.
50
+
51
+ ---
52
+
53
+ ## دليل خطوة بخطوة لإعداد Intlayer في تطبيق React Router v7
54
+
55
+ ### الخطوة 1: تثبيت التبعيات
56
+
57
+ قم بتثبيت الحزم اللازمة باستخدام مدير الحزم المفضل لديك:
58
+
59
+ ```bash packageManager="npm"
60
+ npm install intlayer react-intlayer
61
+ npm install vite-intlayer --save-dev
62
+ ```
63
+
64
+ ```bash packageManager="pnpm"
65
+ pnpm add intlayer react-intlayer
66
+ pnpm add vite-intlayer --save-dev
67
+ ```
68
+
69
+ - **intlayer**
70
+
71
+ الحزمة الأساسية التي توفر أدوات التدويل لإدارة التكوين، والترجمة، و[إعلان المحتوى](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).
72
+
73
+ - **react-intlayer**
74
+ الحزمة التي تدمج Intlayer مع تطبيق React. توفر موفري السياق وخطافات للتدويل في React.
75
+
76
+ - **vite-intlayer**
77
+ تتضمن إضافة Vite لدمج Intlayer مع [مجمّع Vite](https://vite.dev/guide/why.html#why-bundle-for-production)، بالإضافة إلى وسيط للكشف عن اللغة المفضلة للمستخدم، وإدارة الكوكيز، والتعامل مع إعادة توجيه URL.
78
+
79
+ ### الخطوة 2: تكوين مشروعك
80
+
81
+ ## دليل خطوة بخطوة لإعداد Intlayer في تطبيق React Router v7 مع مسارات قائمة على نظام الملفات
82
+
83
+ <Tab defaultTab="video">
84
+ <TabItem label="Video" value="video">
85
+
86
+ <iframe title="How to translate your React Router v7 (File-System Routes) app using 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?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
87
+
88
+ </TabItem>
89
+ <TabItem label="Code" value="code">
90
+
91
+ <iframe
92
+ src="https://stackblitz.com/github/aymericzip/intlayer-react-router-v7-template?embed=1&ctl=1&file=intlayer.config.ts"
93
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
94
+ title="Demo CodeSandbox - How to Internationalize your application using Intlayer"
95
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
96
+ loading="lazy"
97
+ />
98
+
99
+ </TabItem>
100
+ </Tab>
101
+
102
+ See [Application Template](https://github.com/aymericzip/intlayer-react-router-v7-template) on GitHub.
103
+
104
+ قم بإنشاء ملف تكوين لتكوين لغات تطبيقك:
105
+
106
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
107
+ import { type IntlayerConfig, Locales } from "intlayer";
108
+
109
+ const config: IntlayerConfig = {
110
+ internationalization: {
111
+ defaultLocale: Locales.ENGLISH, // اللغة الافتراضية
112
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], // اللغات المدعومة
113
+ },
114
+ };
115
+
116
+ export default config;
117
+ ```
118
+
119
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
120
+ import { Locales } from "intlayer";
121
+
122
+ /** @type {import('intlayer').IntlayerConfig} */
123
+ const config = {
124
+ internationalization: {
125
+ defaultLocale: Locales.ENGLISH, // اللغة الافتراضية
126
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], // اللغات المدعومة
127
+ },
128
+ };
129
+
130
+ export default config;
131
+ ```
132
+
133
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
134
+ const { Locales } = require("intlayer");
135
+
136
+ /** @type {import('intlayer').IntlayerConfig} */
137
+ const config = {
138
+ internationalization: {
139
+ defaultLocale: Locales.ENGLISH, // اللغة الافتراضية
140
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], // اللغات المدعومة
141
+ },
142
+ };
143
+
144
+ module.exports = config;
145
+ ```
146
+
147
+ > من خلال ملف التكوين هذا، يمكنك إعداد عناوين URL محلية، إعادة توجيه الوسيط، أسماء ملفات تعريف الارتباط، موقع وامتداد إعلانات المحتوى الخاصة بك، تعطيل سجلات Intlayer في وحدة التحكم، والمزيد. للحصول على قائمة كاملة بالمعلمات المتاحة، راجع [توثيق التكوين](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/configuration.md).
148
+
149
+ ### الخطوة 3: دمج Intlayer في تكوين Vite الخاص بك
150
+
151
+ أضف مكون intlayer الإضافي إلى تكوينك:
152
+
153
+ ```typescript fileName="vite.config.ts"
154
+ import { reactRouter } from "@react-router/dev/vite";
155
+ import { defineConfig } from "vite";
156
+ import { intlayer } from "vite-intlayer";
157
+ import tsconfigPaths from "vite-tsconfig-paths";
158
+
159
+ export default defineConfig({
160
+ plugins: [reactRouter(), tsconfigPaths(), intlayer()],
161
+ });
162
+ ```
163
+
164
+ > يتم استخدام مكون Vite الإضافي `intlayer()` لدمج Intlayer مع Vite. يضمن بناء ملفات إعلان المحتوى ويراقبها في وضع التطوير. كما يحدد متغيرات بيئة Intlayer داخل تطبيق Vite. بالإضافة إلى ذلك، يوفر أسماء مستعارة لتحسين الأداء.
165
+
166
+ ### الخطوة 4: تكوين مسارات React Router v7
167
+
168
+ قم بإعداد تكوين التوجيه الخاص بك مع مسارات مدركة للغة:
169
+
170
+ ```typescript fileName="app/routes.ts"
171
+ typescript fileName="app/routes.ts"
172
+ import { layout, route, type RouteConfig } from "@react-router/dev/routes";
173
+
174
+ export default [
175
+ layout("routes/layout.tsx", [
176
+ route("/:lang?", "routes/page.tsx"), // الصفحة الرئيسية المحلية
177
+ route("/:lang?/about", "routes/about/page.tsx"), // صفحة حول المحلية
178
+ ]),
179
+ ] satisfies RouteConfig;
180
+ ```
181
+
182
+ ### الخطوة 5: إنشاء مكونات التخطيط
183
+
184
+ قم بإعداد التخطيط الجذري والتخطيطات الخاصة باللغة:
185
+
186
+ #### التخطيط الجذري
187
+
188
+ ```tsx fileName="app/routes/layout.tsx"
189
+ import { IntlayerProvider } from "react-intlayer";
190
+ import { Outlet } from "react-router";
191
+
192
+ import type { Route } from "./+types/layout";
193
+
194
+ export default function RootLayout({ params }: Route.ComponentProps) {
195
+ const { locale } = params;
196
+
197
+ return (
198
+ <IntlayerProvider locale={locale}>
199
+ <Outlet />
200
+ </IntlayerProvider>
201
+ );
202
+ }
203
+ ```
204
+
205
+ ### الخطوة 6: إعلان المحتوى الخاص بك
206
+
207
+ قم بإنشاء وإدارة إعلانات المحتوى الخاصة بك لتخزين الترجمات:
208
+
209
+ ```tsx fileName="app/routes/[lang]/page.content.ts"
210
+ import { t, type Dictionary } from "intlayer";
211
+
212
+ const pageContent = {
213
+ key: "page",
214
+ content: {
215
+ title: t({
216
+ en: "Welcome to React Router v7 + Intlayer",
217
+ es: "Bienvenido a React Router v7 + Intlayer",
218
+ fr: "Bienvenue sur React Router v7 + Intlayer",
219
+ }),
220
+ description: t({
221
+ en: "Build multilingual applications with ease using React Router v7 and Intlayer.",
222
+ es: "Cree aplicaciones multilingües fácilmente usando React Router v7 y Intlayer.",
223
+ fr: "Créez des applications multilingues facilement avec React Router v7 et Intlayer.",
224
+ }),
225
+ aboutLink: t({
226
+ en: "تعرف علينا",
227
+ es: "Aprender Sobre Nosotros",
228
+ fr: "En savoir plus sur nous",
229
+ }),
230
+ homeLink: t({
231
+ en: "الرئيسية",
232
+ es: "Inicio",
233
+ fr: "Accueil",
234
+ }),
235
+ },
236
+ } satisfies Dictionary;
237
+
238
+ export default pageContent;
239
+ ```
240
+
241
+ > يمكن تعريف إعلانات المحتوى الخاصة بك في أي مكان في تطبيقك بمجرد تضمينها في دليل `contentDir` (افتراضيًا، `./app`). ويجب أن تتطابق مع امتداد ملف إعلان المحتوى (افتراضيًا، `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
242
+
243
+ > لمزيد من التفاصيل، راجع [توثيق إعلان المحتوى](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/dictionary/get_started.md).
244
+
245
+ ### الخطوة 7: إنشاء مكونات تدرك اللغة
246
+
247
+ قم بإنشاء مكون `LocalizedLink` للتنقل المدرك للغة:
248
+
249
+ ```tsx fileName="app/components/localized-link.tsx"
250
+ import type { FC } from "react";
251
+
252
+ import { getLocalizedUrl, type LocalesValues } from "intlayer";
253
+ import { useLocale } from "react-intlayer";
254
+ import { Link, type LinkProps, type To } from "react-router";
255
+
256
+ const isExternalLink = (to: string) => /^(https?:)?\/\//.test(to);
257
+
258
+ // دالة لتحويل الرابط إلى رابط محلي بناءً على اللغة
259
+ export const locacalizeTo = (to: To, locale: LocalesValues): To => {
260
+ if (typeof to === "string") {
261
+ if (isExternalLink(to)) {
262
+ return to;
263
+ }
264
+
265
+ return getLocalizedUrl(to, locale);
266
+ }
267
+
268
+ if (isExternalLink(to.pathname ?? "")) {
269
+ return to;
270
+ }
271
+
272
+ return {
273
+ ...to,
274
+ pathname: getLocalizedUrl(to.pathname ?? "", locale),
275
+ };
276
+ };
277
+
278
+ // مكون رابط محلي يدعم التنقل حسب اللغة
279
+ export const LocalizedLink: FC<LinkProps> = (props) => {
280
+ const { locale } = useLocale();
281
+
282
+ return <Link {...props} to={locacalizeTo(props.to, locale)} />;
283
+ };
284
+ ```
285
+
286
+ في حال رغبت في التنقل إلى المسارات المحلية، يمكنك استخدام الخطاف `useLocalizedNavigate`:
287
+
288
+ ```tsx fileName="app/hooks/useLocalizedNavigate.ts"
289
+ import { useLocale } from "react-intlayer";
290
+ import { type NavigateOptions, type To, useNavigate } from "react-router";
291
+
292
+ import { locacalizeTo } from "~/components/localized-link";
293
+
294
+ export const useLocalizedNavigate = () => {
295
+ const navigate = useNavigate();
296
+ const { locale } = useLocale();
297
+
298
+ const localizedNavigate = (to: To, options?: NavigateOptions) => {
299
+ const localedTo = locacalizeTo(to, locale);
300
+
301
+ navigate(localedTo, options);
302
+ };
303
+
304
+ return localizedNavigate;
305
+ };
306
+ ```
307
+
308
+ ### الخطوة 8: استخدام Intlayer في صفحاتك
309
+
310
+ قم بالوصول إلى قواميس المحتوى الخاصة بك في جميع أنحاء تطبيقك:
311
+
312
+ #### الصفحة الرئيسية المترجمة
313
+
314
+ ```tsx fileName="app/routes/[lang]/page.tsx"
315
+ import { useIntlayer } from "react-intlayer";
316
+ import { LocalizedLink } from "~/components/localized-link";
317
+
318
+ export default function Page() {
319
+ const { title, description, aboutLink } = useIntlayer("page");
320
+
321
+ return (
322
+ <div>
323
+ <h1>{title}</h1>
324
+ <p>{description}</p>
325
+ <nav>
326
+ <LocalizedLink to="/about">{aboutLink}</LocalizedLink>
327
+ </nav>
328
+ </div>
329
+ );
330
+ }
331
+ ```
332
+
333
+ > لمعرفة المزيد عن الخطاف `useIntlayer`، راجع [التوثيق](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/react-intlayer/useIntlayer.md).
334
+
335
+ ### الخطوة 9: إنشاء مكون لتبديل اللغة
336
+
337
+ قم بإنشاء مكون يسمح للمستخدمين بتغيير اللغات:
338
+
339
+ ```tsx fileName="app/components/locale-switcher.tsx"
340
+ import type { FC } from "react";
341
+
342
+ import {
343
+ getHTMLTextDir,
344
+ getLocaleName,
345
+ getLocalizedUrl,
346
+ getPathWithoutLocale,
347
+ Locales,
348
+ } from "intlayer";
349
+ import { setLocaleInStorage, useIntlayer, useLocale } from "react-intlayer";
350
+ import { Link, useLocation } from "react-router";
351
+
352
+ export const LocaleSwitcher: FC = () => {
353
+ const { localeSwitcherLabel } = useIntlayer("locale-switcher");
354
+ const { pathname } = useLocation();
355
+
356
+ const { availableLocales, locale } = useLocale();
357
+
358
+ const pathWithoutLocale = getPathWithoutLocale(pathname);
359
+
360
+ return (
361
+ <ol>
362
+ {availableLocales.map((localeItem) => (
363
+ <li key={localeItem}>
364
+ <Link
365
+ aria-current={localeItem === locale ? "page" : undefined}
366
+ aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeItem)}`}
367
+ onClick={() => setLocale(localeItem)}
368
+ to={getLocalizedUrl(pathWithoutLocale, localeItem)}
369
+ >
370
+ <span>
371
+ {/* اللغة - على سبيل المثال FR */}
372
+ {localeItem}
373
+ </span>
374
+ <span>
375
+ {/* اللغة بلغتها الخاصة - على سبيل المثال Français */}
376
+ {getLocaleName(localeItem, locale)}
377
+ </span>
378
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
379
+ {/* اللغة باللغة الحالية - على سبيل المثال Francés مع تعيين اللغة الحالية إلى Locales.SPANISH */}
380
+ {getLocaleName(localeItem)}
381
+ </span>
382
+ <span dir="ltr" lang={Locales.ENGLISH}>
383
+ {/* اللغة باللغة الإنجليزية - على سبيل المثال French */}
384
+ {getLocaleName(localeItem, Locales.ENGLISH)}
385
+ </span>
386
+ </Link>
387
+ </li>
388
+ ))}
389
+ </ol>
390
+ );
391
+ };
392
+ ```
393
+
394
+ > لمعرفة المزيد عن الخطاف `useLocale`، راجع [التوثيق](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/react-intlayer/useLocale.md).
395
+
396
+ ### الخطوة 10: إضافة إدارة سمات HTML (اختياري)
397
+
398
+ أنشئ خطافًا لإدارة سمات lang و dir في HTML:
399
+
400
+ ```tsx fileName="app/hooks/useI18nHTMLAttributes.tsx"
401
+ import { getHTMLTextDir } from "intlayer";
402
+ import { useEffect } from "react";
403
+ import { useLocale } from "react-intlayer";
404
+
405
+ export const useI18nHTMLAttributes = () => {
406
+ const { locale } = useLocale();
407
+
408
+ useEffect(() => {
409
+ document.documentElement.lang = locale;
410
+ document.documentElement.dir = getHTMLTextDir(locale);
411
+ }, [locale]);
412
+ };
413
+ ```
414
+
415
+ ثم استخدمه في مكون الجذر الخاص بك:
416
+
417
+ ```tsx fileName="app/routes/layout.tsx"
418
+ import { Outlet } from "react-router";
419
+ import { IntlayerProvider } from "react-intlayer";
420
+
421
+ import { useI18nHTMLAttributes } from "app/hooks/useI18nHTMLAttributes"; // استيراد الخطاف
422
+
423
+ export default function RootLayout() {
424
+ useI18nHTMLAttributes(); // استدعاء الخطاف
425
+
426
+ return (
427
+ <IntlayerProvider>
428
+ <Outlet />
429
+ </IntlayerProvider>
430
+ );
431
+ }
432
+ ```
433
+
434
+ ### الخطوة 11: إضافة الوسيط (اختياري)
435
+
436
+ يمكنك أيضًا استخدام `intlayerProxy` لإضافة التوجيه من جانب الخادم إلى تطبيقك. سيقوم هذا المكون الإضافي بالكشف تلقائيًا عن اللغة الحالية بناءً على عنوان URL وتعيين ملف تعريف الارتباط المناسب للغة. إذا لم يتم تحديد لغة، فسيحدد المكون الإضافي اللغة الأنسب بناءً على تفضيلات لغة متصفح المستخدم. إذا لم يتم الكشف عن أي لغة، فسيتم إعادة التوجيه إلى اللغة الافتراضية.
437
+
438
+ > لاحظ أنه لاستخدام `intlayerProxy` في بيئة الإنتاج، تحتاج إلى نقل حزمة `vite-intlayer` من `devDependencies` إلى `dependencies`.
439
+
440
+ ```typescript {3,7} fileName="vite.config.ts"
441
+ import { reactRouter } from "@react-router/dev/vite";
442
+ import { defineConfig } from "vite";
443
+ import { intlayer, intlayerProxy } from "vite-intlayer";
444
+ import tsconfigPaths from "vite-tsconfig-paths";
445
+
446
+ export default defineConfig({
447
+ plugins: [reactRouter(), tsconfigPaths(), intlayer(), intlayerProxy()],
448
+ });
449
+ ```
450
+
451
+ ---
452
+
453
+ ## تكوين TypeScript
454
+
455
+ يستخدم Intlayer توسيع الوحدات (module augmentation) للاستفادة من TypeScript وجعل قاعدة الشيفرة الخاصة بك أقوى.
456
+
457
+ تأكد من أن تكوين TypeScript الخاص بك يتضمن الأنواع التي تم إنشاؤها تلقائيًا:
458
+
459
+ ```json5 fileName="tsconfig.json"
460
+ {
461
+ // ... التكوينات الحالية الخاصة بك
462
+ include: [
463
+ // ... الملفات المضمنة الحالية الخاصة بك
464
+ ".intlayer/**/*.ts", // تضمين الأنواع التي تم إنشاؤها تلقائيًا
465
+ ],
466
+ }
467
+ ```
468
+
469
+ ---
470
+
471
+ ## تكوين Git
472
+
473
+ يوصى بتجاهل الملفات التي تم إنشاؤها بواسطة Intlayer. هذا يسمح لك بتجنب الالتزام بها في مستودع Git الخاص بك.
474
+
475
+ للقيام بذلك، يمكنك إضافة التعليمات التالية إلى ملف `.gitignore` الخاص بك:
476
+
477
+ ```plaintext fileName=".gitignore"
478
+ # تجاهل الملفات التي تم إنشاؤها بواسطة Intlayer
479
+ .intlayer
480
+ ```
481
+
482
+ ---
483
+
484
+ ## إضافة VS Code
485
+
486
+ لتحسين تجربة التطوير الخاصة بك مع Intlayer، يمكنك تثبيت **إضافة Intlayer الرسمية لـ VS Code**.
487
+
488
+ [التثبيت من سوق VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
489
+
490
+ تقدم هذه الإضافة:
491
+
492
+ - **الإكمال التلقائي** لمفاتيح الترجمة.
493
+ - **الكشف الفوري عن الأخطاء** للترجمات المفقودة.
494
+ - **معاينات داخلية** للمحتوى المترجم.
495
+ - **إجراءات سريعة** لإنشاء وتحديث الترجمات بسهولة.
496
+
497
+ لمزيد من التفاصيل حول كيفية استخدام الإضافة، راجع [توثيق إضافة Intlayer لـ VS Code](https://intlayer.org/doc/vs-code-extension).
498
+
499
+ ---
500
+
501
+ ## التقدم أكثر
502
+
503
+ للمضي قدمًا، يمكنك تنفيذ [المحرر المرئي](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).
504
+
505
+ ---
506
+
507
+ ## مراجع التوثيق
508
+
509
+ - [توثيق Intlayer](https://intlayer.org)
510
+ - [توثيق React Router v7](https://reactrouter.com/)
511
+ - [هوك useIntlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/react-intlayer/useIntlayer.md)
512
+ - [هوك useLocale](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/packages/react-intlayer/useLocale.md)
513
+ - [إعلان المحتوى](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/dictionary/get_started.md)
514
+ - [التكوين](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/configuration.md)
515
+
516
+ يوفر هذا الدليل الشامل كل ما تحتاجه لدمج Intlayer مع React Router v7 لتطبيق دولي بالكامل مع توجيه مدرك للغة ودعم TypeScript.
@@ -17,6 +17,7 @@ slugs:
17
17
  - environment
18
18
  - tanstack-start
19
19
  applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
20
+ youtubeVideo: https://www.youtube.com/watch?v=_XTdKVWaeqg
20
21
  history:
21
22
  - version: 7.3.9
22
23
  date: 2025-12-05
@@ -585,19 +586,8 @@ export const getLocaleServer = createServerFn().handler(async () => {
585
586
  return getCookie(name, cookieString);
586
587
  },
587
588
  // Get the header from the request (default: 'x-intlayer-locale')
588
- getHeader: (name) => getRequestHeader(name),
589
589
  // Fallback using Accept-Language negotiation
590
- getAllHeaders: async () => {
591
- const headers = getRequestHeaders();
592
- const result: Record<string, string> = {};
593
-
594
- // Convert the TypedHeaders into a plain Record<string, string>
595
- for (const [key, value] of headers.entries()) {
596
- result[key] = value;
597
- }
598
-
599
- return result;
600
- },
590
+ getHeader: (name) => getRequestHeader(name),
601
591
  });
602
592
 
603
593
  // Retrieve some content using getIntlayer()
@@ -15,6 +15,7 @@ slugs:
15
15
  - environment
16
16
  - vite-and-vue
17
17
  applicationTemplate: https://github.com/aymericzip/intlayer-vite-vue-template
18
+ youtubeVideo: https://www.youtube.com/watch?v=IE3XWkZ6a5U
18
19
  history:
19
20
  - version: 5.5.10
20
21
  date: 2025-06-29