@intlayer/docs 5.7.6-canary.0 → 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 +8 -8
- 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: react-intlayer पैकेज के लिए useIntlayerAsync हुक का उपयोग कैसे करें देखें
|
|
6
|
-
keywords:
|
|
7
|
-
- useIntlayerAsync
|
|
8
|
-
- dictionary
|
|
9
|
-
- key
|
|
10
|
-
- Intlayer
|
|
11
|
-
- Internationalization
|
|
12
|
-
- Documentation
|
|
13
|
-
- Next.js
|
|
14
|
-
- JavaScript
|
|
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
|
-
## React में `useIntlayerAsync` को इम्पोर्ट करना
|
|
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
|
-
सभी सामग्री कुंजियाँ आपके कंटेंट घोषणा फ़ाइलों में परिभाषित होनी चाहिए ताकि टाइप सुरक्षा बनी रहे और रनटाइम त्रुटियों से बचा जा सके। ये फ़ाइलें टाइपस्क्रिप्ट सत्यापन सक्षम करती हैं, जिससे आप हमेशा मौजूदा कुंजियों और लोकल्स का संदर्भ लेते हैं।
|
|
238
|
-
|
|
239
|
-
सामग्री घोषणा फ़ाइलें सेट अप करने के निर्देश [यहाँ](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/dictionary/get_started.md) उपलब्ध हैं।
|
|
240
|
-
|
|
241
|
-
## आगे की जानकारी
|
|
242
|
-
|
|
243
|
-
- **Intlayer विज़ुअल एडिटर:**
|
|
244
|
-
UI से सीधे सामग्री प्रबंधन और संपादन के लिए Intlayer विज़ुअल एडिटर के साथ एकीकरण करें। अधिक जानकारी [यहाँ](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_visual_editor.md)।
|
|
245
|
-
|
|
246
|
-
---
|
|
247
|
-
|
|
248
|
-
**सारांश में**, `useIntlayerAsync` एक शक्तिशाली React हुक है जिसे उपयोगकर्ता अनुभव को बेहतर बनाने और सामग्री की ताजगी बनाए रखने के लिए डिज़ाइन किया गया है, जो प्री-रेंडर की गई या प्री-फेच की गई शब्दकोशों को असिंक्रोनस शब्दकोश अपडेट्स के साथ मर्ज करता है। `isLoading` और TypeScript-आधारित सामग्री घोषणाओं का उपयोग करके, आप अपने React एप्लिकेशन में गतिशील, स्थानीयकृत सामग्री को सहजता से एकीकृत कर सकते हैं।
|
|
249
|
-
|
|
250
|
-
## दस्तावेज़ इतिहास
|
|
251
|
-
|
|
252
|
-
- 5.5.10 - 2025-06-29: प्रारंभिक इतिहास
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
createdAt: 2024-08-11
|
|
3
|
-
updatedAt: 2025-06-29
|
|
4
|
-
title: Documentazione Hook useIntlayerAsync | next-intlayer
|
|
5
|
-
description: Scopri come utilizzare l'hook useIntlayerAsync per il pacchetto next-intlayer
|
|
6
|
-
keywords:
|
|
7
|
-
- useIntlayerAsync
|
|
8
|
-
- dizionario
|
|
9
|
-
- chiave
|
|
10
|
-
- Intlayer
|
|
11
|
-
- Internazionalizzazione
|
|
12
|
-
- Documentazione
|
|
13
|
-
- Next.js
|
|
14
|
-
- JavaScript
|
|
15
|
-
- React
|
|
16
|
-
slugs:
|
|
17
|
-
- doc
|
|
18
|
-
- packages
|
|
19
|
-
- next-intlayer
|
|
20
|
-
- useIntlayerAsync
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
# Integrazione Next.js: Documentazione Hook `useIntlayerAsync`
|
|
24
|
-
|
|
25
|
-
L'hook `useIntlayerAsync` estende la funzionalità di `useIntlayer` restituendo non solo i dizionari pre-renderizzati, ma anche recuperando aggiornamenti in modo asincrono, rendendolo ideale per applicazioni che aggiornano frequentemente i loro contenuti localizzati dopo il rendering iniziale.
|
|
26
|
-
|
|
27
|
-
## Panoramica
|
|
28
|
-
|
|
29
|
-
- **Caricamento asincrono del dizionario:**
|
|
30
|
-
Sul lato client, `useIntlayerAsync` restituisce prima il dizionario locale pre-renderizzato (proprio come `useIntlayer`) e poi recupera e unisce in modo asincrono eventuali nuovi dizionari remoti disponibili.
|
|
31
|
-
- **Gestione dello stato di avanzamento:**
|
|
32
|
-
L'hook fornisce anche uno stato `isLoading`, che indica quando un dizionario remoto è in fase di recupero. Questo permette agli sviluppatori di mostrare indicatori di caricamento o stati scheletro per un'esperienza utente più fluida.
|
|
33
|
-
|
|
34
|
-
## Configurazione dell'ambiente
|
|
35
|
-
|
|
36
|
-
Intlayer fornisce un sistema di Content Source Management (CSM) headless che consente anche ai non sviluppatori di gestire e aggiornare i contenuti dell'applicazione in modo fluido. Utilizzando la dashboard intuitiva di Intlayer, il tuo team può modificare testi localizzati, immagini e altre risorse senza dover intervenire direttamente sul codice. Questo semplifica il processo di gestione dei contenuti, favorisce la collaborazione e garantisce che gli aggiornamenti possano essere effettuati rapidamente e facilmente.
|
|
37
|
-
|
|
38
|
-
Per iniziare con Intlayer, è necessario prima registrarsi e ottenere un token di accesso nella [dashboard](https://intlayer.org/dashboard). Una volta ottenute le credenziali, aggiungile al file di configurazione come mostrato di seguito:
|
|
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
|
-
const config = {
|
|
57
|
-
// ...
|
|
58
|
-
editor: {
|
|
59
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
60
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default config;
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
68
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
69
|
-
const config = {
|
|
70
|
-
// ...
|
|
71
|
-
editor: {
|
|
72
|
-
clientId: process.env.INTLAYER_CLIENT_ID,
|
|
73
|
-
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
module.exports = config;
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Dopo aver configurato le tue credenziali, puoi inviare un nuovo dizionario di localizzazione a Intlayer eseguendo:
|
|
81
|
-
|
|
82
|
-
```bash
|
|
83
|
-
npx intlayer dictionary push -d my-first-dictionary-key
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Questo comando carica i tuoi dizionari di contenuti iniziali, rendendoli disponibili per il recupero asincrono e la modifica tramite la piattaforma Intlayer.
|
|
87
|
-
|
|
88
|
-
## Importazione di `useIntlayerAsync` in Next.js
|
|
89
|
-
|
|
90
|
-
Poiché `useIntlayerAsync` è destinato ai componenti **client-side**, lo importerai dallo stesso punto di ingresso client di `useIntlayer`:
|
|
91
|
-
|
|
92
|
-
```tsx codeFormat="typescript"
|
|
93
|
-
"use client";
|
|
94
|
-
|
|
95
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
```javascript codeFormat="esm"
|
|
99
|
-
"use client";
|
|
100
|
-
|
|
101
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
```javascript codeFormat="commonjs"
|
|
105
|
-
"use client";
|
|
106
|
-
|
|
107
|
-
const { useIntlayerAsync } = require("next-intlayer");
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Assicurati che il file di importazione sia annotato con `"use client"` in cima, se stai utilizzando Next.js App Router con componenti server e client separati.
|
|
111
|
-
|
|
112
|
-
## Parametri
|
|
113
|
-
|
|
114
|
-
1. **`key`**:
|
|
115
|
-
**Tipo**: `DictionaryKeys`
|
|
116
|
-
La chiave del dizionario utilizzata per identificare il blocco di contenuto localizzato. Questa chiave dovrebbe essere definita nei tuoi file di dichiarazione dei contenuti.
|
|
117
|
-
|
|
118
|
-
2. **`locale`** (opzionale):
|
|
119
|
-
**Tipo**: `Locales`
|
|
120
|
-
La specifica locale che vuoi utilizzare. Se omesso, l'hook utilizza la locale dal contesto client.
|
|
121
|
-
|
|
122
|
-
3. **`isRenderEditor`** (opzionale, default a `true`):
|
|
123
|
-
**Tipo**: `boolean`
|
|
124
|
-
Determina se il contenuto deve essere pronto per il rendering con la sovrapposizione dell'editor Intlayer. Se impostato su `false`, i dati del dizionario restituiti escluderanno le funzionalità specifiche dell'editor.
|
|
125
|
-
|
|
126
|
-
## Valore di Ritorno
|
|
127
|
-
|
|
128
|
-
L'hook restituisce un oggetto dizionario contenente il contenuto localizzato identificato da `key` e `locale`. Include anche un booleano `isLoading` che indica se un dizionario remoto è attualmente in fase di recupero.
|
|
129
|
-
|
|
130
|
-
## Esempio di Utilizzo in Next.js
|
|
131
|
-
|
|
132
|
-
### Esempio di Componente Client-Side
|
|
133
|
-
|
|
134
|
-
```tsx fileName="src/components/AsyncClientComponentExample.tsx" codeFormat="typescript"
|
|
135
|
-
"use client";
|
|
136
|
-
|
|
137
|
-
import { useEffect, type FC } from "react";
|
|
138
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
139
|
-
|
|
140
|
-
export const AsyncClientComponentExample: FC = () => {
|
|
141
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
142
|
-
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (isLoading) {
|
|
145
|
-
console.log("Il contenuto si sta caricando...");
|
|
146
|
-
}
|
|
147
|
-
}, [isLoading]);
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<div>
|
|
151
|
-
<h1>{title.value}</h1>
|
|
152
|
-
<p>{description.value}</p>
|
|
153
|
-
</div>
|
|
154
|
-
);
|
|
155
|
-
};
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
```jsx fileName="src/components/AsyncClientComponentExample.mjx" codeFormat="esm"
|
|
159
|
-
"use client";
|
|
160
|
-
|
|
161
|
-
import { useEffect } from "react";
|
|
162
|
-
import { useIntlayerAsync } from "next-intlayer";
|
|
163
|
-
|
|
164
|
-
const AsyncClientComponentExample = () => {
|
|
165
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
166
|
-
|
|
167
|
-
useEffect(() => {
|
|
168
|
-
if (isLoading) {
|
|
169
|
-
console.log("Il contenuto si sta caricando...");
|
|
170
|
-
}
|
|
171
|
-
}, [isLoading]);
|
|
172
|
-
|
|
173
|
-
return (
|
|
174
|
-
<div>
|
|
175
|
-
<h1>{title.value}</h1>
|
|
176
|
-
<p>{description.value}</p>
|
|
177
|
-
</div>
|
|
178
|
-
);
|
|
179
|
-
};
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
```jsx fileName="src/components/AsyncClientComponentExample.csx" codeFormat="commonjs"
|
|
183
|
-
"use client";
|
|
184
|
-
|
|
185
|
-
const { useEffect } = require("react");
|
|
186
|
-
const { useIntlayerAsync } = require("next-intlayer");
|
|
187
|
-
|
|
188
|
-
const AsyncClientComponentExample = () => {
|
|
189
|
-
const { title, description, isLoading } = useIntlayerAsync("async-component");
|
|
190
|
-
|
|
191
|
-
useEffect(() => {
|
|
192
|
-
if (isLoading) {
|
|
193
|
-
console.log("Il contenuto si sta caricando...");
|
|
194
|
-
}
|
|
195
|
-
}, [isLoading]);
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<div>
|
|
199
|
-
<h1>{title.value}</h1>
|
|
200
|
-
<p>{description.value}</p>
|
|
201
|
-
</div>
|
|
202
|
-
);
|
|
203
|
-
};
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
**Punti chiave:**
|
|
207
|
-
|
|
208
|
-
- Al rendering iniziale, `title` e `description` provengono dal dizionario della localizzazione prerenderizzata.
|
|
209
|
-
- Mentre `isLoading` è `true`, viene effettuata in background una richiesta remota per recuperare un dizionario aggiornato.
|
|
210
|
-
- Una volta completato il recupero, `title` e `description` vengono aggiornati con il contenuto più recente, e `isLoading` torna a `false`.
|
|
211
|
-
|
|
212
|
-
## Gestione della Localizzazione degli Attributi
|
|
213
|
-
|
|
214
|
-
Come con `useIntlayer`, puoi recuperare valori localizzati per attributi HTML vari (ad esempio, `alt`, `title`, `aria-label`):
|
|
215
|
-
|
|
216
|
-
```tsx
|
|
217
|
-
<img src={title.image.src.value} alt={title.image.alt.value} />
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
## File del Dizionario
|
|
221
|
-
|
|
222
|
-
Tutte le chiavi di contenuto devono essere definite nei tuoi file di dichiarazione del contenuto per garantire la sicurezza dei tipi e prevenire errori a runtime. Questi file abilitano la validazione TypeScript, assicurandoti di fare sempre riferimento a chiavi e localizzazioni esistenti.
|
|
223
|
-
|
|
224
|
-
Istruzioni per la configurazione dei file di dichiarazione dei contenuti sono disponibili [qui](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md).
|
|
225
|
-
|
|
226
|
-
## Ulteriori Informazioni
|
|
227
|
-
|
|
228
|
-
- **Editor Visivo Intlayer:**
|
|
229
|
-
Integra l'editor visivo Intlayer per gestire e modificare i contenuti direttamente dall'interfaccia utente. Maggiori dettagli [qui](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_visual_editor.md).
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
**In sintesi**, `useIntlayerAsync` è un potente hook lato client progettato per migliorare l'esperienza utente e mantenere la freschezza dei contenuti combinando dizionari pre-renderizzati con aggiornamenti asincroni dei dizionari. Sfruttando `isLoading` e le dichiarazioni di contenuto basate su TypeScript, puoi integrare senza soluzione di continuità contenuti dinamici e localizzati nelle tue applicazioni Next.js.
|
|
234
|
-
|
|
235
|
-
## Cronologia della documentazione
|
|
236
|
-
|
|
237
|
-
- 5.5.10 - 2025-06-29: Inizio cronologia
|