@intlayer/docs 5.7.6 → 5.7.7
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/dist/cjs/generated/docs.entry.cjs +44 -238
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +44 -238
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -2
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_tanstack.md +457 -0
- package/docs/ar/packages/next-intlayer/index.md +0 -1
- package/docs/ar/packages/react-intlayer/index.md +0 -1
- package/docs/de/intlayer_with_tanstack.md +458 -0
- package/docs/de/packages/next-intlayer/index.md +0 -1
- package/docs/de/packages/react-intlayer/index.md +0 -1
- package/docs/en/intlayer_with_tanstack.md +452 -0
- package/docs/en/packages/next-intlayer/index.md +0 -1
- package/docs/en/packages/react-intlayer/index.md +0 -1
- package/docs/en-GB/intlayer_with_tanstack.md +457 -0
- package/docs/en-GB/packages/next-intlayer/index.md +0 -1
- package/docs/en-GB/packages/react-intlayer/index.md +0 -1
- package/docs/es/intlayer_with_tanstack.md +435 -0
- package/docs/es/packages/next-intlayer/index.md +0 -1
- package/docs/es/packages/react-intlayer/index.md +0 -1
- package/docs/fr/intlayer_with_tanstack.md +435 -0
- package/docs/fr/packages/next-intlayer/index.md +0 -1
- package/docs/fr/packages/react-intlayer/index.md +0 -1
- package/docs/hi/intlayer_with_tanstack.md +438 -0
- package/docs/hi/packages/next-intlayer/index.md +0 -1
- package/docs/hi/packages/react-intlayer/index.md +0 -1
- package/docs/it/intlayer_with_tanstack.md +457 -0
- package/docs/it/packages/next-intlayer/index.md +0 -1
- package/docs/it/packages/react-intlayer/index.md +0 -1
- package/docs/ja/intlayer_with_tanstack.md +457 -0
- package/docs/ja/packages/next-intlayer/index.md +0 -1
- package/docs/ja/packages/react-intlayer/index.md +0 -1
- package/docs/ko/intlayer_with_tanstack.md +457 -0
- package/docs/ko/packages/next-intlayer/index.md +0 -1
- package/docs/ko/packages/react-intlayer/index.md +0 -1
- package/docs/pt/intlayer_with_tanstack.md +457 -0
- package/docs/pt/packages/next-intlayer/index.md +0 -1
- package/docs/pt/packages/react-intlayer/index.md +0 -1
- package/docs/ru/intlayer_with_tanstack.md +458 -0
- package/docs/ru/packages/next-intlayer/index.md +0 -1
- package/docs/ru/packages/react-intlayer/index.md +0 -1
- package/docs/zh/intlayer_with_tanstack.md +435 -0
- package/docs/zh/packages/next-intlayer/index.md +0 -1
- package/docs/zh/packages/react-intlayer/index.md +0 -1
- package/package.json +9 -9
- package/src/generated/docs.entry.ts +44 -238
- package/docs/ar/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ar/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/de/packages/next-intlayer/useIntlayerAsync.md +0 -262
- package/docs/de/packages/react-intlayer/useIntlayerAsync.md +0 -256
- package/docs/en/packages/next-intlayer/useIntlayerAsync.md +0 -239
- package/docs/en/packages/react-intlayer/useIntlayerAsync.md +0 -254
- package/docs/en-GB/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/en-GB/packages/react-intlayer/useIntlayerAsync.md +0 -257
- package/docs/es/packages/next-intlayer/useIntlayerAsync.md +0 -240
- package/docs/es/packages/react-intlayer/useIntlayerAsync.md +0 -276
- package/docs/fr/packages/next-intlayer/useIntlayerAsync.md +0 -238
- package/docs/fr/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/hi/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/hi/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/it/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/it/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/ja/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ja/packages/react-intlayer/useIntlayerAsync.md +0 -268
- package/docs/ko/packages/next-intlayer/useIntlayerAsync.md +0 -260
- package/docs/ko/packages/react-intlayer/useIntlayerAsync.md +0 -271
- package/docs/pt/packages/next-intlayer/useIntlayerAsync.md +0 -238
- package/docs/pt/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/ru/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ru/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/zh/packages/next-intlayer/useIntlayerAsync.md +0 -239
- package/docs/zh/packages/react-intlayer/useIntlayerAsync.md +0 -257
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
createdAt: 2024-08-11
|
|
3
|
-
updatedAt: 2025-06-29
|
|
4
|
-
title: توثيق الخطاف useIntlayerAsync | react-intlayer
|
|
5
|
-
description: تعرف على كيفية استخدام الخطاف useIntlayerAsync لحزمة react-intlayer
|
|
6
|
-
keywords:
|
|
7
|
-
- useIntlayerAsync
|
|
8
|
-
- dictionary
|
|
9
|
-
- key
|
|
10
|
-
- Intlayer
|
|
11
|
-
- التدويل
|
|
12
|
-
- التوثيق
|
|
13
|
-
- Next.js
|
|
14
|
-
- جافاسكريبت
|
|
15
|
-
- React
|
|
16
|
-
slugs:
|
|
17
|
-
- doc
|
|
18
|
-
- packages
|
|
19
|
-
- react-intlayer
|
|
20
|
-
- useIntlayerAsync
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
# تكامل React: توثيق الخطاف `useIntlayerAsync`
|
|
24
|
-
|
|
25
|
-
يقوم الخطاف `useIntlayerAsync` بتوسيع وظيفة `useIntlayer` ليس فقط بإرجاع القواميس التي تم عرضها مسبقًا، بل أيضًا بجلب التحديثات بشكل غير متزامن، مما يجعله مثاليًا للتطبيقات التي تقوم بتحديث محتواها المحلي بشكل متكرر بعد العرض الأولي.
|
|
26
|
-
|
|
27
|
-
## نظرة عامة
|
|
28
|
-
|
|
29
|
-
- **تحميل القاموس بشكل غير متزامن:**
|
|
30
|
-
عند التركيب الأولي، يقوم `useIntlayerAsync` أولاً بإرجاع أي قاموس محلي تم جلبه مسبقًا أو تم تجميعه بشكل ثابت (تمامًا كما يفعل `useIntlayer`) ثم يقوم بجلب ودمج أي قواميس جديدة متاحة عن بُعد بشكل غير متزامن.
|
|
31
|
-
- **إدارة حالة التقدم:**
|
|
32
|
-
يوفر الخطاف أيضًا حالة `isLoading`، التي تشير إلى متى يتم جلب قاموس عن بُعد. هذا يسمح للمطورين بعرض مؤشرات تحميل أو حالات هيكل عظمي لتجربة مستخدم أكثر سلاسة.
|
|
33
|
-
|
|
34
|
-
## إعداد البيئة
|
|
35
|
-
|
|
36
|
-
يوفر Intlayer نظام إدارة مصادر المحتوى (CSM) بدون واجهة، يمكّن غير المطورين من إدارة وتحديث محتوى التطبيق بسلاسة. من خلال استخدام لوحة تحكم Intlayer البديهية، يمكن لفريقك تحرير النصوص المحلية، الصور، والموارد الأخرى دون تعديل الكود مباشرة. هذا يبسط عملية إدارة المحتوى، يعزز التعاون، ويضمن إمكانية إجراء التحديثات بسرعة وسهولة.
|
|
37
|
-
|
|
38
|
-
للبدء مع Intlayer:
|
|
39
|
-
|
|
40
|
-
1. **سجّل واحصل على رمز وصول** من [https://intlayer.org/dashboard](https://intlayer.org/dashboard).
|
|
41
|
-
2. **أضف بيانات الاعتماد إلى ملف التكوين الخاص بك:**
|
|
42
|
-
في مشروع React الخاص بك، قم بتكوين عميل Intlayer باستخدام بيانات الاعتماد الخاصة بك:
|
|
43
|
-
|
|
44
|
-
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
45
|
-
import type { IntlayerConfig } from "intlayer";
|
|
46
|
-
|
|
47
|
-
export default {
|
|
48
|
-
// ...
|
|
49
|
-
editor: {
|
|
50
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
51
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
52
|
-
},
|
|
53
|
-
} satisfies IntlayerConfig;
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
57
|
-
import { type IntlayerConfig } from "intlayer";
|
|
58
|
-
|
|
59
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
60
|
-
const config = {
|
|
61
|
-
// ...
|
|
62
|
-
editor: {
|
|
63
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
64
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default config;
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
72
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
73
|
-
const config = {
|
|
74
|
-
// ...
|
|
75
|
-
editor: {
|
|
76
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
77
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
module.exports = config;
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
3. **دفع قاموس لغة جديد إلى Intlayer:**
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npx intlayer dictionary push -d my-first-dictionary-key
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
يقوم هذا الأمر بتحميل قواميس المحتوى الأولية الخاصة بك، مما يجعلها متاحة للتحميل والتحرير غير المتزامن من خلال منصة Intlayer.
|
|
91
|
-
|
|
92
|
-
## استيراد `useIntlayerAsync` في React
|
|
93
|
-
|
|
94
|
-
في مكونات React الخاصة بك، قم باستيراد `useIntlayerAsync`:
|
|
95
|
-
|
|
96
|
-
```ts codeFormat="typescript"
|
|
97
|
-
import { useIntlayerAsync } from "react-intlayer";
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```js codeFormat="esm"
|
|
101
|
-
import { useIntlayerAsync } from "react-intlayer";
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
```js codeFormat="commonjs"
|
|
105
|
-
const { useIntlayerAsync } = require("react-intlayer");
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
## المعاملات
|
|
109
|
-
|
|
110
|
-
1. **`key`**:
|
|
111
|
-
**النوع**: `DictionaryKeys`
|
|
112
|
-
مفتاح القاموس المستخدم لتحديد كتلة المحتوى المترجم. يجب تعريف هذا المفتاح في ملفات إعلان المحتوى الخاصة بك.
|
|
113
|
-
|
|
114
|
-
2. **`locale`** (اختياري):
|
|
115
|
-
**النوع**: `Locales`
|
|
116
|
-
اللغة المحددة التي تريد استهدافها. إذا تم حذفها، يستخدم الخطاف اللغة من سياق Intlayer الحالي.
|
|
117
|
-
|
|
118
|
-
3. **`isRenderEditor`** (اختياري، القيمة الافتراضية `true`):
|
|
119
|
-
**النوع**: `boolean`
|
|
120
|
-
يحدد ما إذا كان يجب أن يكون المحتوى جاهزًا للعرض مع تراكب محرر Intlayer. إذا تم تعيينه إلى `false`، ستستبعد بيانات القاموس المرجعة ميزات خاصة بالمحرر.
|
|
121
|
-
|
|
122
|
-
## القيمة المرجعة
|
|
123
|
-
|
|
124
|
-
يرجع الخطاف كائن قاموس يحتوي على محتوى مترجم يتم تحديده بواسطة `key` و `locale`. كما يتضمن متغيرًا منطقيًا `isLoading` يشير إلى ما إذا كان يتم حاليًا جلب قاموس عن بُعد.
|
|
125
|
-
|
|
126
|
-
## مثال على الاستخدام في مكون React
|
|
127
|
-
|
|
128
|
-
```tsx fileName="src/components/ComponentExample.tsx" codeFormat="typescript"
|
|
129
|
-
import { useEffect, type FC } from "react";
|
|
130
|
-
import { useIntlayerAsync } from "react-intlayer";
|
|
131
|
-
|
|
132
|
-
export const ComponentExample: FC = () => {
|
|
133
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
134
|
-
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (isLoading) {
|
|
137
|
-
console.log("يتم تحميل المحتوى...");
|
|
138
|
-
}
|
|
139
|
-
}, [isLoading]);
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<div>
|
|
143
|
-
{isLoading ? (
|
|
144
|
-
<div>
|
|
145
|
-
<h1>جارٍ التحميل…</h1>
|
|
146
|
-
<p>يرجى الانتظار أثناء تحديث المحتوى.</p>
|
|
147
|
-
</div>
|
|
148
|
-
) : (
|
|
149
|
-
<div>
|
|
150
|
-
<h1>{title.value}</h1>
|
|
151
|
-
<p>{description.value}</p>
|
|
152
|
-
</div>
|
|
153
|
-
)}
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
```jsx fileName="src/components/ComponentExample.mjx" codeFormat="esm"
|
|
160
|
-
import { useEffect } from "react";
|
|
161
|
-
import { useIntlayerAsync } from "react-intlayer";
|
|
162
|
-
|
|
163
|
-
const ComponentExample = () => {
|
|
164
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
165
|
-
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
if (isLoading) {
|
|
168
|
-
console.log("يتم تحميل المحتوى...");
|
|
169
|
-
}
|
|
170
|
-
}, [isLoading]);
|
|
171
|
-
|
|
172
|
-
return (
|
|
173
|
-
<div>
|
|
174
|
-
{isLoading ? (
|
|
175
|
-
<div>
|
|
176
|
-
<h1>جارٍ التحميل…</h1>
|
|
177
|
-
<p>يرجى الانتظار أثناء تحديث المحتوى.</p>
|
|
178
|
-
</div>
|
|
179
|
-
) : (
|
|
180
|
-
<div>
|
|
181
|
-
<h1>{title.value}</h1>
|
|
182
|
-
<p>{description.value}</p>
|
|
183
|
-
</div>
|
|
184
|
-
)}
|
|
185
|
-
</div>
|
|
186
|
-
);
|
|
187
|
-
};
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
```jsx fileName="src/components/ComponentExample.csx" codeFormat="commonjs"
|
|
191
|
-
const { useEffect } = require("react");
|
|
192
|
-
const { useIntlayerAsync } = require("react-intlayer");
|
|
193
|
-
|
|
194
|
-
const ComponentExample = () => {
|
|
195
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
196
|
-
|
|
197
|
-
useEffect(() => {
|
|
198
|
-
if (isLoading) {
|
|
199
|
-
console.log("يتم تحميل المحتوى...");
|
|
200
|
-
}
|
|
201
|
-
}, [isLoading]);
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<div>
|
|
205
|
-
{isLoading ? (
|
|
206
|
-
<div>
|
|
207
|
-
<h1>جارٍ التحميل…</h1>
|
|
208
|
-
<p>يرجى الانتظار أثناء تحديث المحتوى.</p>
|
|
209
|
-
</div>
|
|
210
|
-
) : (
|
|
211
|
-
<div>
|
|
212
|
-
<h1>{title.value}</h1>
|
|
213
|
-
<p>{description.value}</p>
|
|
214
|
-
</div>
|
|
215
|
-
)}
|
|
216
|
-
</div>
|
|
217
|
-
);
|
|
218
|
-
};
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
**النقاط الرئيسية:**
|
|
222
|
-
|
|
223
|
-
- عند العرض الأولي، يأتي `title` و `description` من قاموس اللغة الذي تم جلبه مسبقًا أو المضمن بشكل ثابت.
|
|
224
|
-
- بينما تكون قيمة `isLoading` هي `true`، يتم إجراء طلب في الخلفية لجلب قاموس محدث.
|
|
225
|
-
- بمجرد اكتمال الجلب، يتم تحديث `title` و `description` بأحدث المحتويات، وتعود قيمة `isLoading` إلى `false`.
|
|
226
|
-
|
|
227
|
-
## التعامل مع تعريب السمات
|
|
228
|
-
|
|
229
|
-
يمكنك أيضًا استرجاع القيم المعربة لسمات HTML المختلفة (مثل `alt`، `title`، `aria-label`):
|
|
230
|
-
|
|
231
|
-
```jsx
|
|
232
|
-
<img src={title.image.src.value} alt={title.image.alt.value} />
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
## ملفات القاموس
|
|
236
|
-
|
|
237
|
-
يجب تعريف جميع مفاتيح المحتوى في ملفات إعلان المحتوى الخاصة بك لضمان سلامة النوع ومنع أخطاء وقت التشغيل. تتيح هذه الملفات التحقق من صحة TypeScript، مما يضمن أنك تشير دائمًا إلى المفاتيح واللغات الموجودة.
|
|
238
|
-
|
|
239
|
-
تعليمات إعداد ملفات إعلان المحتوى متوفرة [هنا](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/dictionary/get_started.md).
|
|
240
|
-
|
|
241
|
-
## معلومات إضافية
|
|
242
|
-
|
|
243
|
-
- **محرر Intlayer المرئي:**
|
|
244
|
-
دمج مع محرر Intlayer المرئي لإدارة وتحرير المحتوى مباشرة من واجهة المستخدم. مزيد من التفاصيل [هنا](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/intlayer_visual_editor.md).
|
|
245
|
-
|
|
246
|
-
---
|
|
247
|
-
|
|
248
|
-
**باختصار**، `useIntlayerAsync` هو هوك قوي في React مصمم لتعزيز تجربة المستخدم والحفاظ على تحديث المحتوى من خلال دمج القواميس التي تم تقديمها مسبقًا أو جلبها مسبقًا مع تحديثات القاموس غير المتزامنة. من خلال الاستفادة من `isLoading` وإعلانات المحتوى المعتمدة على TypeScript، يمكنك دمج المحتوى الديناميكي والمحلي بسلاسة في تطبيقات React الخاصة بك.
|
|
249
|
-
|
|
250
|
-
## تاريخ الوثيقة
|
|
251
|
-
|
|
252
|
-
- 5.5.10 - 2025-06-29: بدء التاريخ
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
createdAt: 2024-08-11
|
|
3
|
-
updatedAt: 2025-06-29
|
|
4
|
-
title: useIntlayerAsync Hook Dokumentation | next-intlayer
|
|
5
|
-
description: Siehe, wie der useIntlayerAsync Hook für das next-intlayer Paket verwendet wird
|
|
6
|
-
keywords:
|
|
7
|
-
- useIntlayerAsync
|
|
8
|
-
- Wörterbuch
|
|
9
|
-
- Schlüssel
|
|
10
|
-
- Intlayer
|
|
11
|
-
- Internationalisierung
|
|
12
|
-
- Dokumentation
|
|
13
|
-
- Next.js
|
|
14
|
-
- JavaScript
|
|
15
|
-
- React
|
|
16
|
-
slugs:
|
|
17
|
-
- doc
|
|
18
|
-
- packages
|
|
19
|
-
- next-intlayer
|
|
20
|
-
- useIntlayerAsync
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
# Next.js Integration: `useIntlayerAsync` Hook Dokumentation
|
|
24
|
-
|
|
25
|
-
Der `useIntlayerAsync` Hook erweitert die Funktionalität von `useIntlayer`, indem er nicht nur vorgerenderte Wörterbücher zurückgibt, sondern auch Aktualisierungen asynchron abruft. Dadurch ist er ideal für Anwendungen, die ihre lokalisierten Inhalte nach dem ersten Rendern häufig aktualisieren.
|
|
26
|
-
|
|
27
|
-
## Überblick
|
|
28
|
-
|
|
29
|
-
- **Asynchrones Laden von Wörterbüchern:**
|
|
30
|
-
Auf der Client-Seite gibt `useIntlayerAsync` zunächst das vorgerenderte Lokalisierungswörterbuch zurück (genau wie `useIntlayer`) und ruft anschließend asynchron alle neu verfügbaren entfernten Wörterbücher ab und fügt sie zusammen.
|
|
31
|
-
- **Verwaltung des Ladezustands:**
|
|
32
|
-
Der Hook stellt außerdem einen `isLoading` Zustand bereit, der anzeigt, wann ein entferntes Wörterbuch abgerufen wird. Dies ermöglicht es Entwicklern, Ladeanzeigen oder Skeleton-Zustände für eine flüssigere Benutzererfahrung anzuzeigen.
|
|
33
|
-
|
|
34
|
-
## Einrichtung der Umgebung
|
|
35
|
-
|
|
36
|
-
Intlayer bietet ein kopfloses Content Source Management (CSM)-System, das es Nicht-Entwicklern ermöglicht, Anwendungsinhalte nahtlos zu verwalten und zu aktualisieren. Durch die Nutzung des intuitiven Dashboards von Intlayer kann Ihr Team lokalisierten Text, Bilder und andere Ressourcen bearbeiten, ohne den Code direkt ändern zu müssen. Dies vereinfacht den Content-Management-Prozess, fördert die Zusammenarbeit und stellt sicher, dass Aktualisierungen schnell und einfach vorgenommen werden können.
|
|
37
|
-
|
|
38
|
-
Um mit Intlayer zu beginnen, müssen Sie sich zunächst registrieren und einen Zugriffstoken im [Dashboard](https://intlayer.org/dashboard) erhalten. Sobald Sie Ihre Zugangsdaten haben, fügen Sie diese wie unten gezeigt in Ihre Konfigurationsdatei ein:
|
|
39
|
-
|
|
40
|
-
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
41
|
-
import type { IntlayerConfig } from "intlayer";
|
|
42
|
-
|
|
43
|
-
export default {
|
|
44
|
-
// ...
|
|
45
|
-
editor: {
|
|
46
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
47
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
48
|
-
},
|
|
49
|
-
} satisfies IntlayerConfig;
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
53
|
-
import { type IntlayerConfig } from "intlayer";
|
|
54
|
-
|
|
55
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
56
|
-
// Konfiguration für den Editor mit Client-ID und Client-Secret aus Umgebungsvariablen
|
|
57
|
-
const config = {
|
|
58
|
-
// ...
|
|
59
|
-
editor: {
|
|
60
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
61
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default config;
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
69
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
70
|
-
// Konfiguration für den Editor mit Client-ID und Client-Secret aus Umgebungsvariablen
|
|
71
|
-
const config = {
|
|
72
|
-
// ...
|
|
73
|
-
editor: {
|
|
74
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
75
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
module.exports = config;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
Nach der Konfiguration Ihrer Zugangsdaten können Sie ein neues Sprachwörterbuch zu Intlayer hochladen, indem Sie folgenden Befehl ausführen:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npx intlayer dictionary push -d my-first-dictionary-key
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Dieser Befehl lädt Ihre initialen Inhaltswörterbücher hoch und macht sie für asynchrones Abrufen und Bearbeiten über die Intlayer-Plattform verfügbar.
|
|
89
|
-
|
|
90
|
-
## Importieren von `useIntlayerAsync` in Next.js
|
|
91
|
-
|
|
92
|
-
Da `useIntlayerAsync` für **Client-seitige** Komponenten vorgesehen ist, importieren Sie es vom gleichen Client-Einstiegspunkt wie `useIntlayer`:
|
|
93
|
-
|
|
94
|
-
```tsx codeFormat="typescript"
|
|
95
|
-
"use client";
|
|
96
|
-
|
|
97
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```javascript codeFormat="esm"
|
|
101
|
-
"use client";
|
|
102
|
-
|
|
103
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
```javascript codeFormat="commonjs"
|
|
107
|
-
"use client";
|
|
108
|
-
|
|
109
|
-
const { useIntlayerAsync } = require("next-intlayer");
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Stellen Sie sicher, dass die importierende Datei oben mit `"use client"` annotiert ist, wenn Sie den Next.js App Router mit getrennten Server- und Client-Komponenten verwenden.
|
|
113
|
-
|
|
114
|
-
## Parameter
|
|
115
|
-
|
|
116
|
-
1. **`key`**:
|
|
117
|
-
**Typ**: `DictionaryKeys`
|
|
118
|
-
Der Wörterbuchschlüssel, der verwendet wird, um den lokalisierten Inhaltsblock zu identifizieren. Dieser Schlüssel sollte in Ihren Inhaltsdeklarationsdateien definiert sein.
|
|
119
|
-
|
|
120
|
-
2. **`locale`** (optional):
|
|
121
|
-
**Typ**: `Locales`
|
|
122
|
-
Die spezifische Locale, die Sie ansprechen möchten. Wenn ausgelassen, verwendet der Hook die Locale aus dem Client-Kontext.
|
|
123
|
-
|
|
124
|
-
3. **`isRenderEditor`** (optional, Standardwert `true`):
|
|
125
|
-
**Typ**: `boolean`
|
|
126
|
-
Bestimmt, ob der Inhalt für die Darstellung mit der Intlayer-Editor-Overlay bereit sein soll. Wenn auf `false` gesetzt, enthält das zurückgegebene Wörterbuch keine editor-spezifischen Funktionen.
|
|
127
|
-
|
|
128
|
-
## Rückgabewert
|
|
129
|
-
|
|
130
|
-
Der Hook gibt ein Wörterbuchobjekt zurück, das lokalisierten Inhalt enthält, der durch `key` und `locale` indiziert ist. Es enthält außerdem ein `isLoading`-Boolean, das angibt, ob gerade ein entferntes Wörterbuch geladen wird.
|
|
131
|
-
|
|
132
|
-
## Beispielverwendung in Next.js
|
|
133
|
-
|
|
134
|
-
### Beispiel für eine Client-seitige Komponente
|
|
135
|
-
|
|
136
|
-
```tsx fileName="src/components/AsyncClientComponentExample.tsx" codeFormat="typescript"
|
|
137
|
-
"use client";
|
|
138
|
-
|
|
139
|
-
import { useEffect, type FC } from "react";
|
|
140
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
141
|
-
|
|
142
|
-
export const AsyncClientComponentExample: FC = () => {
|
|
143
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
144
|
-
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
if (isLoading) {
|
|
147
|
-
console.log("Inhalt wird geladen...");
|
|
148
|
-
}
|
|
149
|
-
}, [isLoading]);
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<div>
|
|
153
|
-
<h1>{title.value}</h1>
|
|
154
|
-
<p>{description.value}</p>
|
|
155
|
-
</div>
|
|
156
|
-
);
|
|
157
|
-
};
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
```jsx fileName="src/components/AsyncClientComponentExample.mjx" codeFormat="esm"
|
|
161
|
-
"use client";
|
|
162
|
-
|
|
163
|
-
import { useEffect } from "react";
|
|
164
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
165
|
-
|
|
166
|
-
const AsyncClientComponentExample = () => {
|
|
167
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
168
|
-
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
if (isLoading) {
|
|
171
|
-
console.log("Inhalt wird geladen...");
|
|
172
|
-
}
|
|
173
|
-
}, [isLoading]);
|
|
174
|
-
|
|
175
|
-
return (
|
|
176
|
-
<div>
|
|
177
|
-
<h1>{title.value}</h1>
|
|
178
|
-
<p>{description.value}</p>
|
|
179
|
-
</div>
|
|
180
|
-
);
|
|
181
|
-
};
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
```jsx fileName="src/components/AsyncClientComponentExample.csx" codeFormat="commonjs"
|
|
185
|
-
"use client";
|
|
186
|
-
|
|
187
|
-
const { useEffect } = require("react");
|
|
188
|
-
const { useIntlayerAsync } = require("next-intlayer");
|
|
189
|
-
|
|
190
|
-
const AsyncClientComponentExample = () => {
|
|
191
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
192
|
-
|
|
193
|
-
useEffect(() => {
|
|
194
|
-
if (isLoading) {
|
|
195
|
-
console.log("Inhalt wird geladen...");
|
|
196
|
-
}
|
|
197
|
-
}, [isLoading]);
|
|
198
|
-
|
|
199
|
-
return (
|
|
200
|
-
<div>
|
|
201
|
-
<h1>{title.value}</h1>
|
|
202
|
-
<p>{description.value}</p>
|
|
203
|
-
</div>
|
|
204
|
-
);
|
|
205
|
-
};
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
**Wichtige Punkte:**
|
|
209
|
-
|
|
210
|
-
- Beim ersten Rendern stammen `title` und `description` aus dem vorgerenderten Lokalisierungswörterbuch.
|
|
211
|
-
- Während `isLoading` auf `true` gesetzt ist, wird im Hintergrund eine Remote-Anfrage ausgeführt, um ein aktualisiertes Wörterbuch abzurufen.
|
|
212
|
-
- Sobald der Abruf abgeschlossen ist, werden `title` und `description` mit dem neuesten Inhalt aktualisiert, und `isLoading` wird wieder auf `false` gesetzt.
|
|
213
|
-
|
|
214
|
-
## Umgang mit der Attribut-Lokalisierung
|
|
215
|
-
|
|
216
|
-
Wie bei `useIntlayer` können Sie lokalisierte Attributwerte für verschiedene HTML-Eigenschaften abrufen (z. B. `alt`, `title`, `aria-label`):
|
|
217
|
-
|
|
218
|
-
```tsx
|
|
219
|
-
<img src={title.image.src.value} alt={title.image.alt.value} />
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Wörterbuchdateien
|
|
223
|
-
|
|
224
|
-
Alle Inhalts-Schlüssel müssen in Ihren Inhaltsdeklarationsdateien definiert sein, um Typensicherheit zu gewährleisten und Laufzeitfehler zu vermeiden. Diese Dateien ermöglichen die TypeScript-Validierung, sodass Sie immer auf vorhandene Schlüssel und Sprachen verweisen.
|
|
225
|
-
|
|
226
|
-
- Während `isLoading` auf `true` gesetzt ist, wird im Hintergrund eine Remote-Anfrage ausgeführt, um ein aktualisiertes Wörterbuch abzurufen.
|
|
227
|
-
- Sobald der Abruf abgeschlossen ist, werden `title` und `description` mit dem neuesten Inhalt aktualisiert, und `isLoading` wird wieder auf `false` gesetzt.
|
|
228
|
-
|
|
229
|
-
## Umgang mit der Attribut-Lokalisierung
|
|
230
|
-
|
|
231
|
-
Wie bei `useIntlayer` können Sie lokalisierte Attributwerte für verschiedene HTML-Eigenschaften (z. B. `alt`, `title`, `aria-label`) abrufen:
|
|
232
|
-
|
|
233
|
-
```tsx
|
|
234
|
-
<img src={title.image.src.value} alt={title.image.alt.value} />
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
## Wörterbuchdateien
|
|
238
|
-
|
|
239
|
-
Alle Inhaltsschlüssel müssen in Ihren Inhaltsdeklarationsdateien definiert sein, um Typsicherheit zu gewährleisten und Laufzeitfehler zu vermeiden. Diese Dateien ermöglichen die TypeScript-Validierung, sodass Sie immer auf vorhandene Schlüssel und Sprachen verweisen.
|
|
240
|
-
|
|
241
|
-
Anleitungen zum Einrichten von Inhaltsdeklarationsdateien finden Sie [hier](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/dictionary/get_started.md).
|
|
242
|
-
|
|
243
|
-
## Weitere Informationen
|
|
244
|
-
|
|
245
|
-
- **Intlayer Visual Editor:**
|
|
246
|
-
Integration mit dem Intlayer Visual Editor zur Verwaltung und Bearbeitung von Inhalten direkt über die Benutzeroberfläche. Weitere Details [hier](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/intlayer_visual_editor.md).
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
**Zusammenfassend** ist `useIntlayerAsync` ein leistungsstarker Client-seitiger Hook, der darauf ausgelegt ist, die Benutzererfahrung zu verbessern und die Aktualität der Inhalte zu gewährleisten, indem vorgerenderte Wörterbücher mit asynchronen Wörterbuchaktualisierungen kombiniert werden. Durch die Nutzung von `isLoading` und TypeScript-basierten Inhaltsdeklarationen können Sie dynamische, lokalisierte Inhalte nahtlos in Ihre Next.js-Anwendungen integrieren.
|
|
251
|
-
|
|
252
|
-
## Dokumentationshistorie
|
|
253
|
-
|
|
254
|
-
- 5.5.10 - 2025-06-29: Initiale Historie
|
|
255
|
-
|
|
256
|
-
---
|
|
257
|
-
|
|
258
|
-
**Zusammenfassung**, `useIntlayerAsync` ist ein leistungsstarker Client-seitiger Hook, der entwickelt wurde, um die Benutzererfahrung zu verbessern und die Aktualität der Inhalte zu gewährleisten, indem vorgerenderte Wörterbücher mit asynchronen Wörterbuch-Updates kombiniert werden. Durch die Nutzung von `isLoading` und TypeScript-basierten Inhaltsdeklarationen können Sie dynamische, lokalisierte Inhalte nahtlos in Ihre Next.js-Anwendungen integrieren.
|
|
259
|
-
|
|
260
|
-
## Dokumentationshistorie
|
|
261
|
-
|
|
262
|
-
- 5.5.10 - 2025-06-29: Historie initialisiert
|