@intlayer/docs 8.0.0 → 8.0.1-canary.0
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 +160 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +160 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +8 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_adonisjs.md +394 -0
- package/docs/ar/intlayer_with_hono.md +223 -0
- package/docs/ar/intlayer_with_vite+preact.md +317 -675
- package/docs/ar/packages/adonis-intlayer/exports.md +50 -0
- package/docs/ar/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/ar/packages/adonis-intlayer/t.md +149 -0
- package/docs/ar/packages/hono-intlayer/exports.md +59 -0
- package/docs/ar/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/ar/packages/hono-intlayer/t.md +268 -0
- package/docs/de/intlayer_with_adonisjs.md +392 -0
- package/docs/de/intlayer_with_hono.md +418 -0
- package/docs/de/intlayer_with_vite+preact.md +272 -632
- package/docs/de/packages/adonis-intlayer/exports.md +50 -0
- package/docs/de/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/de/packages/adonis-intlayer/t.md +149 -0
- package/docs/de/packages/hono-intlayer/exports.md +59 -0
- package/docs/de/packages/hono-intlayer/intlayer.md +59 -0
- package/docs/de/packages/hono-intlayer/t.md +316 -0
- package/docs/en/index.md +8 -0
- package/docs/en/intlayer_with_adonisjs.md +388 -0
- package/docs/en/intlayer_with_hono.md +418 -0
- package/docs/en/intlayer_with_vite+preact.md +171 -556
- package/docs/en/introduction.md +1 -0
- package/docs/en/packages/adonis-intlayer/exports.md +50 -0
- package/docs/en/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/en/packages/adonis-intlayer/t.md +149 -0
- package/docs/en/packages/hono-intlayer/exports.md +59 -0
- package/docs/en/packages/hono-intlayer/intlayer.md +59 -0
- package/docs/en/packages/hono-intlayer/t.md +316 -0
- package/docs/en-GB/intlayer_with_adonisjs.md +394 -0
- package/docs/en-GB/intlayer_with_hono.md +418 -0
- package/docs/en-GB/intlayer_with_vite+preact.md +236 -583
- package/docs/en-GB/packages/adonis-intlayer/exports.md +50 -0
- package/docs/en-GB/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/en-GB/packages/adonis-intlayer/t.md +149 -0
- package/docs/en-GB/packages/hono-intlayer/exports.md +59 -0
- package/docs/en-GB/packages/hono-intlayer/intlayer.md +59 -0
- package/docs/en-GB/packages/hono-intlayer/t.md +316 -0
- package/docs/es/intlayer_with_adonisjs.md +388 -0
- package/docs/es/intlayer_with_hono.md +418 -0
- package/docs/es/intlayer_with_vite+preact.md +286 -650
- package/docs/es/packages/adonis-intlayer/exports.md +50 -0
- package/docs/es/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/es/packages/adonis-intlayer/t.md +149 -0
- package/docs/es/packages/hono-intlayer/exports.md +59 -0
- package/docs/es/packages/hono-intlayer/intlayer.md +59 -0
- package/docs/es/packages/hono-intlayer/t.md +316 -0
- package/docs/fr/intlayer_with_adonisjs.md +388 -0
- package/docs/fr/intlayer_with_hono.md +418 -0
- package/docs/fr/intlayer_with_vite+preact.md +274 -614
- package/docs/fr/packages/adonis-intlayer/exports.md +50 -0
- package/docs/fr/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/fr/packages/adonis-intlayer/t.md +149 -0
- package/docs/fr/packages/hono-intlayer/exports.md +59 -0
- package/docs/fr/packages/hono-intlayer/intlayer.md +59 -0
- package/docs/fr/packages/hono-intlayer/t.md +316 -0
- package/docs/hi/intlayer_with_adonisjs.md +394 -0
- package/docs/hi/intlayer_with_hono.md +227 -0
- package/docs/hi/intlayer_with_vite+preact.md +304 -680
- package/docs/hi/packages/adonis-intlayer/exports.md +50 -0
- package/docs/hi/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/hi/packages/adonis-intlayer/t.md +149 -0
- package/docs/hi/packages/hono-intlayer/exports.md +59 -0
- package/docs/hi/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/hi/packages/hono-intlayer/t.md +268 -0
- package/docs/id/intlayer_with_adonisjs.md +394 -0
- package/docs/id/intlayer_with_hono.md +227 -0
- package/docs/id/intlayer_with_vite+preact.md +297 -697
- package/docs/id/packages/adonis-intlayer/exports.md +50 -0
- package/docs/id/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/id/packages/adonis-intlayer/t.md +149 -0
- package/docs/id/packages/hono-intlayer/exports.md +59 -0
- package/docs/id/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/id/packages/hono-intlayer/t.md +268 -0
- package/docs/it/intlayer_with_adonisjs.md +394 -0
- package/docs/it/intlayer_with_hono.md +227 -0
- package/docs/it/intlayer_with_vite+preact.md +290 -659
- package/docs/it/packages/adonis-intlayer/exports.md +50 -0
- package/docs/it/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/it/packages/adonis-intlayer/t.md +149 -0
- package/docs/it/packages/hono-intlayer/exports.md +59 -0
- package/docs/it/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/it/packages/hono-intlayer/t.md +268 -0
- package/docs/ja/intlayer_with_adonisjs.md +394 -0
- package/docs/ja/intlayer_with_hono.md +227 -0
- package/docs/ja/intlayer_with_vite+preact.md +307 -662
- package/docs/ja/packages/adonis-intlayer/exports.md +50 -0
- package/docs/ja/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/ja/packages/adonis-intlayer/t.md +149 -0
- package/docs/ja/packages/hono-intlayer/exports.md +59 -0
- package/docs/ja/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/ja/packages/hono-intlayer/t.md +268 -0
- package/docs/ko/intlayer_with_adonisjs.md +394 -0
- package/docs/ko/intlayer_with_hono.md +227 -0
- package/docs/ko/intlayer_with_vite+preact.md +303 -703
- package/docs/ko/packages/adonis-intlayer/exports.md +50 -0
- package/docs/ko/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/ko/packages/adonis-intlayer/t.md +149 -0
- package/docs/ko/packages/hono-intlayer/exports.md +59 -0
- package/docs/ko/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/ko/packages/hono-intlayer/t.md +268 -0
- package/docs/pl/intlayer_with_adonisjs.md +394 -0
- package/docs/pl/intlayer_with_hono.md +227 -0
- package/docs/pl/intlayer_with_vite+preact.md +289 -690
- package/docs/pl/packages/adonis-intlayer/exports.md +50 -0
- package/docs/pl/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/pl/packages/adonis-intlayer/t.md +149 -0
- package/docs/pl/packages/hono-intlayer/exports.md +59 -0
- package/docs/pl/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/pl/packages/hono-intlayer/t.md +268 -0
- package/docs/pt/intlayer_with_adonisjs.md +394 -0
- package/docs/pt/intlayer_with_hono.md +227 -0
- package/docs/pt/intlayer_with_vite+preact.md +275 -637
- package/docs/pt/packages/adonis-intlayer/exports.md +50 -0
- package/docs/pt/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/pt/packages/adonis-intlayer/t.md +149 -0
- package/docs/pt/packages/hono-intlayer/exports.md +59 -0
- package/docs/pt/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/pt/packages/hono-intlayer/t.md +268 -0
- package/docs/ru/intlayer_with_adonisjs.md +393 -0
- package/docs/ru/intlayer_with_hono.md +223 -0
- package/docs/ru/intlayer_with_vite+preact.md +319 -683
- package/docs/ru/packages/adonis-intlayer/exports.md +50 -0
- package/docs/ru/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/ru/packages/adonis-intlayer/t.md +149 -0
- package/docs/ru/packages/hono-intlayer/exports.md +59 -0
- package/docs/ru/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/ru/packages/hono-intlayer/t.md +268 -0
- package/docs/tr/intlayer_with_adonisjs.md +394 -0
- package/docs/tr/intlayer_with_hono.md +227 -0
- package/docs/tr/intlayer_with_vite+preact.md +332 -665
- package/docs/tr/packages/adonis-intlayer/exports.md +50 -0
- package/docs/tr/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/tr/packages/adonis-intlayer/t.md +149 -0
- package/docs/tr/packages/hono-intlayer/exports.md +59 -0
- package/docs/tr/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/tr/packages/hono-intlayer/t.md +268 -0
- package/docs/uk/intlayer_with_adonisjs.md +394 -0
- package/docs/uk/intlayer_with_hono.md +227 -0
- package/docs/uk/intlayer_with_vite+preact.md +228 -626
- package/docs/uk/packages/adonis-intlayer/exports.md +50 -0
- package/docs/uk/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/uk/packages/adonis-intlayer/t.md +149 -0
- package/docs/uk/packages/hono-intlayer/exports.md +59 -0
- package/docs/uk/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/uk/packages/hono-intlayer/t.md +268 -0
- package/docs/vi/intlayer_with_adonisjs.md +394 -0
- package/docs/vi/intlayer_with_hono.md +227 -0
- package/docs/vi/intlayer_with_vite+preact.md +294 -679
- package/docs/vi/packages/adonis-intlayer/exports.md +50 -0
- package/docs/vi/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/vi/packages/adonis-intlayer/t.md +149 -0
- package/docs/vi/packages/hono-intlayer/exports.md +59 -0
- package/docs/vi/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/vi/packages/hono-intlayer/t.md +268 -0
- package/docs/zh/intlayer_with_adonisjs.md +393 -0
- package/docs/zh/intlayer_with_hono.md +418 -0
- package/docs/zh/intlayer_with_vite+preact.md +338 -743
- package/docs/zh/packages/adonis-intlayer/exports.md +50 -0
- package/docs/zh/packages/adonis-intlayer/intlayer.md +54 -0
- package/docs/zh/packages/adonis-intlayer/t.md +149 -0
- package/docs/zh/packages/hono-intlayer/exports.md +59 -0
- package/docs/zh/packages/hono-intlayer/intlayer.md +60 -0
- package/docs/zh/packages/hono-intlayer/t.md +294 -0
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +160 -0
|
@@ -24,7 +24,7 @@ history:
|
|
|
24
24
|
changes: प्रारंभिक इतिहास
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
# Intlayer के साथ
|
|
27
|
+
# Intlayer के साथ अपनी Vite और Preact वेबसाइट का अनुवाद करें | अंतर्राष्ट्रीयकरण (i18n)
|
|
28
28
|
|
|
29
29
|
<Tabs defaultTab="video">
|
|
30
30
|
<Tab label="Video" value="video">
|
|
@@ -45,9 +45,9 @@ history:
|
|
|
45
45
|
</Tab>
|
|
46
46
|
</Tabs>
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
## विषय सूची
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
<TOC/>
|
|
51
51
|
|
|
52
52
|
## Intlayer क्या है?
|
|
53
53
|
|
|
@@ -55,15 +55,17 @@ GitHub पर [Application Template](https://github.com/aymericzip/intlayer-vite
|
|
|
55
55
|
|
|
56
56
|
Intlayer के साथ, आप कर सकते हैं:
|
|
57
57
|
|
|
58
|
-
-
|
|
58
|
+
- **अनुवादों का आसानी से प्रबंधन करें**: कॉम्पोनेंट स्तर पर घोषणात्मक शब्दकोशों का उपयोग करके।
|
|
59
59
|
- **मेटाडेटा, रूट्स, और सामग्री को गतिशील रूप से स्थानीयकृत करें**।
|
|
60
|
-
-
|
|
61
|
-
- **उन्नत विशेषताओं का लाभ
|
|
60
|
+
- **TypeScript समर्थन सुनिश्चित करें**: स्वचालित रूप से उत्पन्न प्रकारों के साथ, ऑटोकंप्लीशन और त्रुटि पहचान में सुधार होता है।
|
|
61
|
+
- **उन्नत विशेषताओं का लाभ उठाएं**: जैसे गतिशील लोकल डिटेक्शन और स्विचिंग।
|
|
62
62
|
|
|
63
63
|
---
|
|
64
64
|
|
|
65
65
|
## Vite और Preact एप्लिकेशन में Intlayer सेटअप करने के लिए चरण-दर-चरण मार्गदर्शिका
|
|
66
66
|
|
|
67
|
+
GitHub पर [Application Template](https://github.com/aymericzip/intlayer-vite-preact-template) देखें।
|
|
68
|
+
|
|
67
69
|
### चरण 1: निर्भरताएँ इंस्टॉल करें
|
|
68
70
|
|
|
69
71
|
npm का उपयोग करके आवश्यक पैकेज इंस्टॉल करें:
|
|
@@ -94,14 +96,14 @@ bunx intlayer init
|
|
|
94
96
|
|
|
95
97
|
- **intlayer**
|
|
96
98
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
मुख्य पैकेज जो कॉन्फ़िगरेशन प्रबंधन, अनुवाद, [सामग्री घोषणा](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/dictionary/get_started.md), ट्रांसपाइलेशन, और [CLI कमांड्स](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_cli.md) के लिए अंतरराष्ट्रीयकरण उपकरण प्रदान करता है।
|
|
99
|
+
मुख्य पैकेज जो कॉन्फ़िगरेशन प्रबंधन, अनुवाद, [सामग्री घोषणा](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/dictionary/content_file.md), ट्रांसपाइलेशन, और [CLI कमांड्स](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/cli/index.md) के लिए अंतरराष्ट्रीयकरण उपकरण प्रदान करता है।
|
|
100
100
|
|
|
101
101
|
- **preact-intlayer**
|
|
102
|
+
|
|
102
103
|
वह पैकेज जो Intlayer को Preact एप्लिकेशन के साथ एकीकृत करता है। यह Preact अंतरराष्ट्रीयकरण के लिए संदर्भ प्रदाता और हुक्स प्रदान करता है।
|
|
103
104
|
|
|
104
105
|
- **vite-intlayer**
|
|
106
|
+
|
|
105
107
|
इसमें Vite प्लगइन शामिल है जो Intlayer को [Vite बंडलर](https://vite.dev/guide/why.html#why-bundle-for-production) के साथ एकीकृत करता है, साथ ही उपयोगकर्ता की पसंदीदा लोकल का पता लगाने, कुकीज़ प्रबंधित करने, और URL पुनर्निर्देशन को संभालने के लिए मिडलवेयर भी शामिल है।
|
|
106
108
|
|
|
107
109
|
### चरण 2: अपने प्रोजेक्ट का कॉन्फ़िगरेशन
|
|
@@ -121,6 +123,10 @@ const config: IntlayerConfig = {
|
|
|
121
123
|
],
|
|
122
124
|
defaultLocale: Locales.ENGLISH,
|
|
123
125
|
},
|
|
126
|
+
routing: {
|
|
127
|
+
mode: "prefix-no-default", // डिफ़ॉल्ट: डिफ़ॉल्ट लोकल को छोड़कर सभी लोकल को उपसर्ग दें
|
|
128
|
+
storage: ["cookie", "header"], // डिफ़ॉल्ट: कुकी में लोकल स्टोर करें और हेडर से डिटेक्ट करें
|
|
129
|
+
},
|
|
124
130
|
};
|
|
125
131
|
|
|
126
132
|
export default config;
|
|
@@ -140,6 +146,10 @@ const config = {
|
|
|
140
146
|
],
|
|
141
147
|
defaultLocale: Locales.ENGLISH,
|
|
142
148
|
},
|
|
149
|
+
routing: {
|
|
150
|
+
mode: "prefix-no-default", // डिफ़ॉल्ट: डिफ़ॉल्ट लोकल को छोड़कर सभी लोकल को उपसर्ग दें
|
|
151
|
+
storage: ["cookie", "header"], // डिफ़ॉल्ट: कुकी में लोकल स्टोर करें और हेडर से डिटेक्ट करें
|
|
152
|
+
},
|
|
143
153
|
};
|
|
144
154
|
|
|
145
155
|
export default config;
|
|
@@ -159,12 +169,16 @@ const config = {
|
|
|
159
169
|
],
|
|
160
170
|
defaultLocale: Locales.ENGLISH,
|
|
161
171
|
},
|
|
172
|
+
routing: {
|
|
173
|
+
mode: "prefix-no-default", // डिफ़ॉल्ट: डिफ़ॉल्ट लोकल को छोड़कर सभी लोकल को उपसर्ग दें
|
|
174
|
+
storage: ["cookie", "header"], // डिफ़ॉल्ट: कुकी में लोकल स्टोर करें और हेडर से डिटेक्ट करें
|
|
175
|
+
},
|
|
162
176
|
};
|
|
163
177
|
|
|
164
178
|
module.exports = config;
|
|
165
179
|
```
|
|
166
180
|
|
|
167
|
-
> इस कॉन्फ़िगरेशन फ़ाइल के माध्यम से, आप स्थानीयकृत URL,
|
|
181
|
+
> इस कॉन्फ़िगरेशन फ़ाइल के माध्यम से, आप स्थानीयकृत URL, रूटिंग मोड, स्टोरेज विकल्प, कुकी नाम, आपकी सामग्री घोषणाओं का स्थान और एक्सटेंशन सेट कर सकते हैं, कंसोल में Intlayer लॉग को अक्षम कर सकते हैं, और भी बहुत कुछ। उपलब्ध सभी पैरामीटर की पूरी सूची के लिए, कृपया [कॉन्फ़िगरेशन दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/configuration.md) देखें।
|
|
168
182
|
|
|
169
183
|
### चरण 3: अपने Vite कॉन्फ़िगरेशन में Intlayer को एकीकृत करें
|
|
170
184
|
|
|
@@ -238,8 +252,7 @@ const appContent = {
|
|
|
238
252
|
edit: t<ComponentChildren>({
|
|
239
253
|
en: (
|
|
240
254
|
<>
|
|
241
|
-
<code>src/app.tsx</code>
|
|
242
|
-
सहेजें
|
|
255
|
+
Edit <code>src/app.tsx</code> and save to test HMR
|
|
243
256
|
</>
|
|
244
257
|
),
|
|
245
258
|
fr: (
|
|
@@ -265,7 +278,7 @@ const appContent = {
|
|
|
265
278
|
export default appContent;
|
|
266
279
|
```
|
|
267
280
|
|
|
268
|
-
```javascript fileName="src/app.content.mjs"
|
|
281
|
+
```javascript fileName="src/app.content.mjs" codeFormat="esm"
|
|
269
282
|
import { t } from "intlayer";
|
|
270
283
|
// import { h } from 'preact'; // यदि आप सीधे .mjs में JSX का उपयोग करते हैं तो आवश्यक है
|
|
271
284
|
|
|
@@ -309,7 +322,7 @@ const appContent = {
|
|
|
309
322
|
export default appContent;
|
|
310
323
|
```
|
|
311
324
|
|
|
312
|
-
```javascript fileName="src/app.content.cjs"
|
|
325
|
+
```javascript fileName="src/app.content.cjs" codeFormat="commonjs"
|
|
313
326
|
const { t } = require("intlayer");
|
|
314
327
|
// const { h } = require('preact'); // यदि आप सीधे .cjs में JSX का उपयोग करते हैं तो आवश्यक है
|
|
315
328
|
|
|
@@ -334,21 +347,18 @@ const appContent = {
|
|
|
334
347
|
en: "count is ",
|
|
335
348
|
fr: "le compte est ",
|
|
336
349
|
es: "el recuento es ",
|
|
337
|
-
hi: "गिनती है ",
|
|
338
350
|
}),
|
|
339
351
|
|
|
340
352
|
edit: t({
|
|
341
353
|
en: "Edit src/app.tsx and save to test HMR",
|
|
342
354
|
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
343
355
|
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
344
|
-
hi: "src/app.tsx संपादित करें और HMR परीक्षण के लिए सहेजें",
|
|
345
356
|
}),
|
|
346
357
|
|
|
347
358
|
readTheDocs: t({
|
|
348
359
|
en: "Click on the Vite and Preact logos to learn more",
|
|
349
360
|
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
350
|
-
es: "Haga clic en los logotipos de Vite
|
|
351
|
-
hi: "अधिक जानने के लिए Vite और Preact लोगो पर क्लिक करें",
|
|
361
|
+
es: "Haga clic en los logotipos de Vite et Preact pour en savoir plus",
|
|
352
362
|
}),
|
|
353
363
|
},
|
|
354
364
|
};
|
|
@@ -356,7 +366,7 @@ const appContent = {
|
|
|
356
366
|
module.exports = appContent;
|
|
357
367
|
```
|
|
358
368
|
|
|
359
|
-
```json fileName="src/app.content.json"
|
|
369
|
+
```json fileName="src/app.content.json" codeFormat="json"
|
|
360
370
|
{
|
|
361
371
|
"$schema": "https://intlayer.org/schema.json",
|
|
362
372
|
"key": "app",
|
|
@@ -366,8 +376,7 @@ module.exports = appContent;
|
|
|
366
376
|
"translation": {
|
|
367
377
|
"en": "Vite logo",
|
|
368
378
|
"fr": "Logo Vite",
|
|
369
|
-
"es": "Logo Vite"
|
|
370
|
-
"hi": "Vite लोगो"
|
|
379
|
+
"es": "Logo Vite"
|
|
371
380
|
}
|
|
372
381
|
},
|
|
373
382
|
"preactLogo": {
|
|
@@ -375,8 +384,7 @@ module.exports = appContent;
|
|
|
375
384
|
"translation": {
|
|
376
385
|
"en": "Preact logo",
|
|
377
386
|
"fr": "Logo Preact",
|
|
378
|
-
"es": "Logo Preact"
|
|
379
|
-
"hi": "Preact लोगो"
|
|
387
|
+
"es": "Logo Preact"
|
|
380
388
|
}
|
|
381
389
|
},
|
|
382
390
|
"title": {
|
|
@@ -384,8 +392,7 @@ module.exports = appContent;
|
|
|
384
392
|
"translation": {
|
|
385
393
|
"en": "Vite + Preact",
|
|
386
394
|
"fr": "Vite + Preact",
|
|
387
|
-
"es": "Vite + Preact"
|
|
388
|
-
"hi": "Vite + Preact"
|
|
395
|
+
"es": "Vite + Preact"
|
|
389
396
|
}
|
|
390
397
|
},
|
|
391
398
|
"count": {
|
|
@@ -393,8 +400,7 @@ module.exports = appContent;
|
|
|
393
400
|
"translation": {
|
|
394
401
|
"en": "count is ",
|
|
395
402
|
"fr": "le compte est ",
|
|
396
|
-
"es": "el recuento es "
|
|
397
|
-
"hi": "गिनती है "
|
|
403
|
+
"es": "el recuento es "
|
|
398
404
|
}
|
|
399
405
|
},
|
|
400
406
|
"edit": {
|
|
@@ -402,8 +408,7 @@ module.exports = appContent;
|
|
|
402
408
|
"translation": {
|
|
403
409
|
"en": "Edit src/app.tsx and save to test HMR",
|
|
404
410
|
"fr": "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
405
|
-
"es": "Edita src/app.tsx y guarda para probar HMR"
|
|
406
|
-
"hi": "src/app.tsx को संपादित करें और HMR परीक्षण के लिए सहेजें"
|
|
411
|
+
"es": "Edita src/app.tsx y guarda para probar HMR"
|
|
407
412
|
}
|
|
408
413
|
},
|
|
409
414
|
"readTheDocs": {
|
|
@@ -411,8 +416,7 @@ module.exports = appContent;
|
|
|
411
416
|
"translation": {
|
|
412
417
|
"en": "Click on the Vite and Preact logos to learn more",
|
|
413
418
|
"fr": "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
414
|
-
"es": "Haga clic en los logotipos de Vite y Preact para obtener más información"
|
|
415
|
-
"hi": "अधिक जानने के लिए Vite और Preact लोगो पर क्लिक करें"
|
|
419
|
+
"es": "Haga clic en los logotipos de Vite y Preact para obtener más información"
|
|
416
420
|
}
|
|
417
421
|
}
|
|
418
422
|
}
|
|
@@ -421,7 +425,7 @@ module.exports = appContent;
|
|
|
421
425
|
|
|
422
426
|
> आपकी सामग्री घोषणाएँ आपके एप्लिकेशन में कहीं भी परिभाषित की जा सकती हैं जब तक कि वे `contentDir` निर्देशिका (डिफ़ॉल्ट रूप से, `./src`) में शामिल हों। और सामग्री घोषणा फ़ाइल एक्सटेंशन से मेल खाती हों (डिफ़ॉल्ट रूप से, `.content.{json,ts,tsx,js,jsx,mjs,cjs}`)।
|
|
423
427
|
|
|
424
|
-
> अधिक विवरण के लिए, [सामग्री घोषणा
|
|
428
|
+
> अधिक विवरण के लिए, [सामग्री घोषणा दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/dictionary/get_started.md) देखें।
|
|
425
429
|
|
|
426
430
|
> यदि आपकी सामग्री फ़ाइल में TSX कोड शामिल है, तो आपको `import { h } from "preact";` आयात करने की आवश्यकता हो सकती है या सुनिश्चित करें कि आपका JSX प्रैग्मा Preact के लिए सही ढंग से सेट है।
|
|
427
431
|
|
|
@@ -463,6 +467,12 @@ const AppContent: FunctionalComponent = () => {
|
|
|
463
467
|
</button>
|
|
464
468
|
<p>{content.edit}</p>
|
|
465
469
|
</div>
|
|
470
|
+
{/* Markdown सामग्री */}
|
|
471
|
+
<div>{content.myMarkdownContent}</div>
|
|
472
|
+
|
|
473
|
+
{/* HTML सामग्री */}
|
|
474
|
+
<div>{content.myHtmlContent}</div>
|
|
475
|
+
|
|
466
476
|
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
467
477
|
</>
|
|
468
478
|
);
|
|
@@ -579,7 +589,7 @@ module.exports = App;
|
|
|
579
589
|
|
|
580
590
|
> नोट: Preact में, `className` आमतौर पर `class` के रूप में लिखा जाता है।
|
|
581
591
|
|
|
582
|
-
> `useIntlayer` हुक के बारे में अधिक जानने के लिए, [
|
|
592
|
+
> `useIntlayer` हुक के बारे में अधिक जानने के लिए, [दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/react-intlayer/useIntlayer.md) देखें (API `preact-intlayer` के लिए समान है)।
|
|
583
593
|
|
|
584
594
|
### (वैकल्पिक) चरण 6: अपनी सामग्री की भाषा बदलें
|
|
585
595
|
|
|
@@ -595,7 +605,7 @@ const LocaleSwitcher: FunctionalComponent = () => {
|
|
|
595
605
|
|
|
596
606
|
return (
|
|
597
607
|
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
598
|
-
|
|
608
|
+
Change Language to English
|
|
599
609
|
</button>
|
|
600
610
|
);
|
|
601
611
|
};
|
|
@@ -612,7 +622,7 @@ const LocaleSwitcher = () => {
|
|
|
612
622
|
|
|
613
623
|
return (
|
|
614
624
|
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
615
|
-
|
|
625
|
+
Change Language to English
|
|
616
626
|
</button>
|
|
617
627
|
);
|
|
618
628
|
};
|
|
@@ -629,7 +639,7 @@ const LocaleSwitcher = () => {
|
|
|
629
639
|
|
|
630
640
|
return (
|
|
631
641
|
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
632
|
-
|
|
642
|
+
Change Language to English
|
|
633
643
|
</button>
|
|
634
644
|
);
|
|
635
645
|
};
|
|
@@ -637,7 +647,7 @@ const LocaleSwitcher = () => {
|
|
|
637
647
|
module.exports = LocaleSwitcher;
|
|
638
648
|
```
|
|
639
649
|
|
|
640
|
-
> `useLocale` हुक के बारे में अधिक जानने के लिए, [
|
|
650
|
+
> `useLocale` हुक के बारे में अधिक जानने के लिए, [प्रलेखन](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/react-intlayer/useLocale.md) देखें (API `preact-intlayer` के लिए समान है)।
|
|
641
651
|
|
|
642
652
|
### (वैकल्पिक) चरण 7: अपने एप्लिकेशन में स्थानीयकृत रूटिंग जोड़ें
|
|
643
653
|
|
|
@@ -650,420 +660,96 @@ module.exports = LocaleSwitcher;
|
|
|
650
660
|
- https://example.com/fr/about
|
|
651
661
|
```
|
|
652
662
|
|
|
653
|
-
> डिफ़ॉल्ट रूप से, डिफ़ॉल्ट लोकल के लिए रूट्स को कोई उपसर्ग नहीं दिया जाता है। यदि आप डिफ़ॉल्ट लोकल के लिए उपसर्ग जोड़ना चाहते हैं, तो आप अपनी कॉन्फ़िगरेशन में `
|
|
663
|
+
> डिफ़ॉल्ट रूप से, डिफ़ॉल्ट लोकल के लिए रूट्स को कोई उपसर्ग नहीं दिया जाता है। यदि आप डिफ़ॉल्ट लोकल के लिए उपसर्ग जोड़ना चाहते हैं, तो आप अपनी कॉन्फ़िगरेशन में `routing.mode` विकल्प को `"prefix-all"` पर सेट कर सकते हैं। अधिक जानकारी के लिए [कॉन्फ़िगरेशन दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/configuration.md) देखें।
|
|
654
664
|
|
|
655
665
|
अपने एप्लिकेशन में स्थानीयकृत रूटिंग जोड़ने के लिए, आप एक `LocaleRouter` कॉम्पोनेंट बना सकते हैं जो आपके एप्लिकेशन के रूट्स को लपेटता है और लोकल-आधारित रूटिंग को संभालता है। यहाँ [preact-iso](https://github.com/preactjs/preact-iso) का उपयोग करते हुए एक उदाहरण दिया गया है:
|
|
656
666
|
|
|
657
|
-
सबसे पहले, `preact-iso` इंस्टॉल करें:
|
|
658
|
-
|
|
659
|
-
```bash packageManager="npm"
|
|
660
|
-
npm install preact-iso
|
|
661
|
-
npx intlayer init
|
|
662
|
-
```
|
|
663
|
-
|
|
664
|
-
```bash packageManager="pnpm"
|
|
665
|
-
pnpm add preact-iso
|
|
666
|
-
pnpm intlayer init
|
|
667
|
-
```
|
|
668
|
-
|
|
669
|
-
```bash packageManager="yarn"
|
|
670
|
-
yarn add preact-iso
|
|
671
|
-
```
|
|
672
|
-
|
|
673
667
|
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
674
|
-
import {
|
|
675
|
-
import { ComponentChildren, FunctionalComponent } from "preact";
|
|
668
|
+
import { localeMap } from "intlayer";
|
|
676
669
|
import { IntlayerProvider } from "preact-intlayer";
|
|
677
|
-
import { LocationProvider,
|
|
678
|
-
import {
|
|
679
|
-
|
|
680
|
-
const { internationalization, middleware } = configuration;
|
|
681
|
-
const { locales, defaultLocale } = internationalization;
|
|
682
|
-
|
|
683
|
-
const Navigate: FunctionalComponent<{ to: string; replace?: boolean }> = ({
|
|
684
|
-
to,
|
|
685
|
-
replace,
|
|
686
|
-
}) => {
|
|
687
|
-
const { route } = useLocation();
|
|
688
|
-
useEffect(() => {
|
|
689
|
-
route(to, replace);
|
|
690
|
-
}, [to, replace, route]);
|
|
691
|
-
return null;
|
|
692
|
-
};
|
|
693
|
-
|
|
694
|
-
/**
|
|
695
|
-
* एक घटक जो स्थानीयकरण को संभालता है और बच्चों को उपयुक्त लोकल संदर्भ के साथ लपेटता है।
|
|
696
|
-
* यह URL-आधारित लोकल पहचान और सत्यापन का प्रबंधन करता है।
|
|
697
|
-
*/
|
|
698
|
-
const AppLocalized: FunctionalComponent<{
|
|
699
|
-
children: ComponentChildren;
|
|
700
|
-
locale?: Locales;
|
|
701
|
-
}> = ({ children, locale }) => {
|
|
702
|
-
const { path: pathname, url } = useLocation();
|
|
703
|
-
|
|
704
|
-
if (!url) {
|
|
705
|
-
return null;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
const search = url.substring(pathname.length);
|
|
709
|
-
|
|
710
|
-
// वर्तमान लोकल निर्धारित करें, यदि प्रदान नहीं किया गया है तो डिफ़ॉल्ट लोकल पर वापस जाएं
|
|
711
|
-
const currentLocale = locale ?? defaultLocale;
|
|
712
|
-
|
|
713
|
-
// पथ से लोकल उपसर्ग हटाएं ताकि एक आधार पथ बनाया जा सके
|
|
714
|
-
const pathWithoutLocale = getPathWithoutLocale(
|
|
715
|
-
pathname // वर्तमान URL पथ
|
|
716
|
-
);
|
|
670
|
+
import { LocationProvider, Router, Route } from "preact-iso";
|
|
671
|
+
import type { ComponentChildren, FunctionalComponent } from "preact";
|
|
717
672
|
|
|
718
|
-
/**
|
|
719
673
|
/**
|
|
720
|
-
* एक कॉम्पोनेंट जो
|
|
721
|
-
* यह
|
|
722
|
-
*/
|
|
723
|
-
const AppLocalized: FunctionalComponent<{
|
|
724
|
-
children: ComponentChildren;
|
|
725
|
-
locale?: Locales;
|
|
726
|
-
}> = ({ children, locale }) => {
|
|
727
|
-
const { path: pathname, url } = useLocation();
|
|
728
|
-
|
|
729
|
-
if (!url) {
|
|
730
|
-
return null;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
const search = url.substring(pathname.length);
|
|
734
|
-
|
|
735
|
-
// वर्तमान स्थानीय भाषा निर्धारित करें, यदि प्रदान नहीं की गई है तो डिफ़ॉल्ट पर वापस जाएं
|
|
736
|
-
const currentLocale = locale ?? defaultLocale;
|
|
737
|
-
|
|
738
|
-
// पथ से स्थानीय उपसर्ग हटाएं ताकि एक मूल पथ बनाया जा सके
|
|
739
|
-
const pathWithoutLocale = getPathWithoutLocale(
|
|
740
|
-
pathname // वर्तमान URL पथ
|
|
741
|
-
);
|
|
742
|
-
|
|
743
|
-
/**
|
|
744
|
-
* यदि middleware.prefixDefault सत्य है, तो डिफ़ॉल्ट स्थानीय हमेशा उपसर्गित होना चाहिए।
|
|
745
|
-
*/
|
|
746
|
-
if (middleware.prefixDefault) {
|
|
747
|
-
// स्थानीय की सत्यापन करें
|
|
748
|
-
if (!locale || !locales.includes(locale)) {
|
|
749
|
-
// अद्यतन पथ के साथ डिफ़ॉल्ट स्थानीय पर पुनर्निर्देशित करें
|
|
750
|
-
return (
|
|
751
|
-
<Navigate
|
|
752
|
-
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
753
|
-
replace // वर्तमान इतिहास प्रविष्टि को नए से बदलें
|
|
754
|
-
/>
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
// IntlayerProvider के साथ बच्चों को लपेटें और वर्तमान स्थानीय सेट करें
|
|
759
|
-
return (
|
|
760
|
-
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
761
|
-
);
|
|
762
|
-
} else {
|
|
763
|
-
/**
|
|
764
|
-
* जब middleware.prefixDefault गलत होता है, तो डिफ़ॉल्ट स्थानीय उपसर्गित नहीं होता है।
|
|
765
|
-
* सुनिश्चित करें कि वर्तमान लोकल मान्य है और डिफ़ॉल्ट लोकल नहीं है।
|
|
766
|
-
*/
|
|
767
|
-
if (
|
|
768
|
-
currentLocale.toString() !== defaultLocale.toString() &&
|
|
769
|
-
!locales
|
|
770
|
-
.filter(
|
|
771
|
-
(loc) => loc.toString() !== defaultLocale.toString() // डिफ़ॉल्ट लोकल को बाहर करें
|
|
772
|
-
)
|
|
773
|
-
.includes(currentLocale) // जांचें कि वर्तमान लोकल मान्य लोकलों की सूची में है या नहीं
|
|
774
|
-
) {
|
|
775
|
-
// लोकल उपसर्ग के बिना पथ पर पुनर्निर्देशित करें
|
|
776
|
-
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
// IntlayerProvider के साथ बच्चों को लपेटें और वर्तमान लोकल सेट करें
|
|
780
|
-
return (
|
|
781
|
-
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
782
|
-
);
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
|
|
786
|
-
const RouterContent: FunctionalComponent<{
|
|
787
|
-
children: ComponentChildren;
|
|
788
|
-
}> = ({ children }) => {
|
|
789
|
-
const { path } = useLocation();
|
|
790
|
-
|
|
791
|
-
if (!path) {
|
|
792
|
-
return null;
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
const pathLocale = path.split("/")[1] as Locales;
|
|
796
|
-
|
|
797
|
-
const isLocaleRoute = locales
|
|
798
|
-
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
799
|
-
.some((locale) => locale.toString() === pathLocale);
|
|
800
|
-
|
|
801
|
-
if (isLocaleRoute) {
|
|
802
|
-
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
return (
|
|
806
|
-
<AppLocalized
|
|
807
|
-
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
808
|
-
>
|
|
809
|
-
{children}
|
|
810
|
-
</AppLocalized>
|
|
811
|
-
);
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
/**
|
|
815
|
-
* एक राउटर कॉम्पोनेंट जो स्थानीय-विशिष्ट रूट सेट करता है।
|
|
816
|
-
* यह प्रीऐक्ट-आइसो का उपयोग नेविगेशन प्रबंधित करने और स्थानीयकृत कॉम्पोनेंट्स को रेंडर करने के लिए करता है।
|
|
674
|
+
* एक राउटर कॉम्पोनेंट जो लोकल-विशिष्ट रूट्स सेटअप करता है।
|
|
675
|
+
* यह नेविगेशन प्रबंधित करने और स्थानीयकृत कॉम्पोनेंट्स को रेंडर करने के लिए preact-iso का उपयोग करता है।
|
|
817
676
|
*/
|
|
818
677
|
export const LocaleRouter: FunctionalComponent<{
|
|
819
678
|
children: ComponentChildren;
|
|
820
679
|
}> = ({ children }) => (
|
|
821
680
|
<LocationProvider>
|
|
822
|
-
<
|
|
681
|
+
<Router>
|
|
682
|
+
{localeMap(({ locale, urlPrefix }) => ({ locale, urlPrefix }))
|
|
683
|
+
.sort((a, b) => b.urlPrefix.length - a.urlPrefix.length)
|
|
684
|
+
.map(({ locale, urlPrefix }) => (
|
|
685
|
+
<Route
|
|
686
|
+
key={locale}
|
|
687
|
+
path={`${urlPrefix}/:rest*`}
|
|
688
|
+
component={() => (
|
|
689
|
+
<IntlayerProvider locale={locale}>{children}</IntlayerProvider>
|
|
690
|
+
)}
|
|
691
|
+
/>
|
|
692
|
+
))}
|
|
693
|
+
</Router>
|
|
823
694
|
</LocationProvider>
|
|
824
695
|
);
|
|
825
696
|
```
|
|
826
697
|
|
|
827
698
|
```jsx fileName="src/components/LocaleRouter.jsx" codeFormat="esm"
|
|
828
|
-
|
|
829
|
-
import { configuration, getPathWithoutLocale } from "intlayer";
|
|
699
|
+
import { localeMap } from "intlayer";
|
|
830
700
|
import { IntlayerProvider } from "preact-intlayer";
|
|
831
|
-
import { LocationProvider,
|
|
832
|
-
import { useEffect } from "preact/hooks";
|
|
833
|
-
import { h } from "preact"; // JSX के लिए आवश्यक
|
|
834
|
-
|
|
835
|
-
// Intlayer से कॉन्फ़िगरेशन को डेस्ट्रक्चर करना
|
|
836
|
-
const { internationalization, middleware } = configuration;
|
|
837
|
-
const { locales, defaultLocale } = internationalization;
|
|
838
|
-
|
|
839
|
-
const Navigate = ({ to, replace }) => {
|
|
840
|
-
const { route } = useLocation();
|
|
841
|
-
useEffect(() => {
|
|
842
|
-
route(to, replace);
|
|
843
|
-
}, [to, replace, route]);
|
|
844
|
-
return null;
|
|
845
|
-
};
|
|
701
|
+
import { LocationProvider, Router, Route } from "preact-iso";
|
|
846
702
|
|
|
847
703
|
/**
|
|
848
|
-
* एक
|
|
849
|
-
* यह
|
|
850
|
-
*/
|
|
851
|
-
const AppLocalized = ({ children, locale }) => {
|
|
852
|
-
const { path: pathname, url } = useLocation();
|
|
853
|
-
|
|
854
|
-
if (!url) {
|
|
855
|
-
return null;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
const search = url.substring(pathname.length);
|
|
859
|
-
|
|
860
|
-
// वर्तमान स्थानीय भाषा निर्धारित करें, यदि प्रदान नहीं की गई हो तो डिफ़ॉल्ट पर वापस जाएं
|
|
861
|
-
const currentLocale = locale ?? defaultLocale;
|
|
862
|
-
|
|
863
|
-
// पथ से स्थानीय उपसर्ग हटाएं ताकि एक मूल पथ बनाया जा सके
|
|
864
|
-
const pathWithoutLocale = getPathWithoutLocale(
|
|
865
|
-
pathname // वर्तमान URL पथ
|
|
866
|
-
);
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* यदि middleware.prefixDefault सत्य है, तो डिफ़ॉल्ट स्थानीय भाषा को हमेशा उपसर्गित किया जाना चाहिए।
|
|
870
|
-
*/
|
|
871
|
-
if (middleware.prefixDefault) {
|
|
872
|
-
// स्थानीय भाषा को मान्य करें
|
|
873
|
-
if (!locale || !locales.includes(locale)) {
|
|
874
|
-
// अपडेट किए गए पथ के साथ डिफ़ॉल्ट स्थानीय भाषा पर पुनर्निर्देशित करें
|
|
875
|
-
return (
|
|
876
|
-
<Navigate
|
|
877
|
-
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
878
|
-
replace // वर्तमान इतिहास प्रविष्टि को नए से बदलें
|
|
879
|
-
/>
|
|
880
|
-
);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
// IntlayerProvider के साथ बच्चों को लपेटें और वर्तमान स्थानीय भाषा सेट करें
|
|
884
|
-
return (
|
|
885
|
-
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
886
|
-
);
|
|
887
|
-
} else {
|
|
888
|
-
/**
|
|
889
|
-
* जब middleware.prefixDefault गलत होता है, तो डिफ़ॉल्ट स्थानीय भाषा को उपसर्गित नहीं किया जाता है।
|
|
890
|
-
* सुनिश्चित करें कि वर्तमान स्थानीय भाषा मान्य है और डिफ़ॉल्ट स्थानीय भाषा नहीं है।
|
|
891
|
-
*/
|
|
892
|
-
if (
|
|
893
|
-
currentLocale.toString() !== defaultLocale.toString() &&
|
|
894
|
-
!locales
|
|
895
|
-
.filter(
|
|
896
|
-
(loc) => loc.toString() !== defaultLocale.toString() // डिफ़ॉल्ट लोकल को बाहर करें
|
|
897
|
-
)
|
|
898
|
-
.includes(currentLocale) // जांचें कि वर्तमान लोकल मान्य लोकलों की सूची में है या नहीं
|
|
899
|
-
) {
|
|
900
|
-
// लोकल उपसर्ग के बिना पथ पर पुनर्निर्देशित करें
|
|
901
|
-
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
// बच्चों को IntlayerProvider के साथ लपेटें और वर्तमान लोकल सेट करें
|
|
905
|
-
return (
|
|
906
|
-
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
907
|
-
);
|
|
908
|
-
}
|
|
909
|
-
};
|
|
910
|
-
|
|
911
|
-
const RouterContent = ({ children }) => {
|
|
912
|
-
const { path } = useLocation();
|
|
913
|
-
|
|
914
|
-
if (!path) {
|
|
915
|
-
return null;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
const pathLocale = path.split("/")[1];
|
|
919
|
-
|
|
920
|
-
const isLocaleRoute = locales
|
|
921
|
-
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
922
|
-
.some((locale) => locale.toString() === pathLocale);
|
|
923
|
-
|
|
924
|
-
if (isLocaleRoute) {
|
|
925
|
-
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
return (
|
|
929
|
-
<AppLocalized
|
|
930
|
-
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
931
|
-
>
|
|
932
|
-
{children}
|
|
933
|
-
</AppLocalized>
|
|
934
|
-
);
|
|
935
|
-
};
|
|
936
|
-
|
|
937
|
-
/**
|
|
938
|
-
* एक राउटर कॉम्पोनेंट जो स्थानीय-विशिष्ट मार्ग सेट करता है।
|
|
939
|
-
* यह प्रीएक्ट-आइस का उपयोग नेविगेशन प्रबंधित करने और स्थानीयकृत कॉम्पोनेंट्स को रेंडर करने के लिए करता है।
|
|
704
|
+
* एक राउटर कॉम्पोनेंट जो लोकल-विशिष्ट रूट्स सेटअप करता है।
|
|
705
|
+
* यह नेविगेशन प्रबंधित करने और स्थानीयकृत कॉम्पोनेंट्स को रेंडर करने के लिए preact-iso का उपयोग करता है।
|
|
940
706
|
*/
|
|
941
707
|
export const LocaleRouter = ({ children }) => (
|
|
942
708
|
<LocationProvider>
|
|
943
|
-
<
|
|
709
|
+
<Router>
|
|
710
|
+
{localeMap(({ locale, urlPrefix }) => ({ locale, urlPrefix }))
|
|
711
|
+
.sort((a, b) => b.urlPrefix.length - a.urlPrefix.length)
|
|
712
|
+
.map(({ locale, urlPrefix }) => (
|
|
713
|
+
<Route
|
|
714
|
+
key={locale}
|
|
715
|
+
path={`${urlPrefix}/:rest*`}
|
|
716
|
+
component={() => (
|
|
717
|
+
<IntlayerProvider locale={locale}>{children}</IntlayerProvider>
|
|
718
|
+
)}
|
|
719
|
+
/>
|
|
720
|
+
))}
|
|
721
|
+
</Router>
|
|
944
722
|
</LocationProvider>
|
|
945
723
|
);
|
|
946
724
|
```
|
|
947
725
|
|
|
948
726
|
```jsx fileName="src/components/LocaleRouter.cjsx" codeFormat="commonjs"
|
|
949
|
-
|
|
950
|
-
const { configuration, getPathWithoutLocale } = require("intlayer");
|
|
727
|
+
const { localeMap } = require("intlayer");
|
|
951
728
|
const { IntlayerProvider } = require("preact-intlayer");
|
|
952
|
-
const { LocationProvider,
|
|
953
|
-
const { useEffect } = require("preact/hooks");
|
|
954
|
-
const { h } = require("preact"); // JSX के लिए आवश्यक
|
|
955
|
-
|
|
956
|
-
// Intlayer से configuration को डीस्ट्रक्चर करना
|
|
957
|
-
const { internationalization, middleware } = configuration;
|
|
958
|
-
const { locales, defaultLocale } = internationalization;
|
|
959
|
-
|
|
960
|
-
const Navigate = ({ to, replace }) => {
|
|
961
|
-
const { route } = useLocation();
|
|
962
|
-
useEffect(() => {
|
|
963
|
-
route(to, replace);
|
|
964
|
-
}, [to, replace, route]);
|
|
965
|
-
return null;
|
|
966
|
-
};
|
|
729
|
+
const { LocationProvider, Router, Route } = require("preact-iso");
|
|
967
730
|
|
|
968
731
|
/**
|
|
969
|
-
* एक कॉम्पोनेंट जो
|
|
970
|
-
* यह
|
|
732
|
+
* एक राउटर कॉम्पोनेंट जो लोकल-विशिष्ट रूट्स सेटअप करता है।
|
|
733
|
+
* यह नेविगेशन प्रबंधित करने$ और स्थानीयकृत कॉम्पोनेंट्स को रेंडर करने के लिए preact-iso का उपयोग करता है।
|
|
971
734
|
*/
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
);
|
|
988
|
-
|
|
989
|
-
/**
|
|
990
|
-
* यदि middleware.prefixDefault true है, तो डिफ़ॉल्ट लोकल हमेशा उपसर्गित होना चाहिए।
|
|
991
|
-
*/
|
|
992
|
-
if (middleware.prefixDefault) {
|
|
993
|
-
// लोकल को मान्य करें
|
|
994
|
-
if (!locale || !locales.includes(locale)) {
|
|
995
|
-
// अपडेट किए गए पथ के साथ डिफ़ॉल्ट लोकल पर पुनर्निर्देशित करें
|
|
996
|
-
return (
|
|
997
|
-
<Navigate
|
|
998
|
-
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
999
|
-
replace // वर्तमान इतिहास प्रविष्टि को नए से बदलें
|
|
1000
|
-
/>
|
|
1001
|
-
);
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
// IntlayerProvider के साथ बच्चों को लपेटें और वर्तमान स्थानीय सेट करें
|
|
1005
|
-
return (
|
|
1006
|
-
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
1007
|
-
);
|
|
1008
|
-
} else {
|
|
1009
|
-
/**
|
|
1010
|
-
* जब middleware.prefixDefault गलत होता है, तो डिफ़ॉल्ट स्थानीय उपसर्गित नहीं होता है।
|
|
1011
|
-
* सुनिश्चित करें कि वर्तमान स्थानीय मान्य है और डिफ़ॉल्ट स्थानीय नहीं है।
|
|
1012
|
-
*/
|
|
1013
|
-
if (
|
|
1014
|
-
currentLocale.toString() !== defaultLocale.toString() &&
|
|
1015
|
-
!locales
|
|
1016
|
-
.filter(
|
|
1017
|
-
(loc) => loc.toString() !== defaultLocale.toString() // डिफ़ॉल्ट स्थानीय को बाहर करें
|
|
735
|
+
const LocaleRouter = ({ children }) =>
|
|
736
|
+
h(
|
|
737
|
+
LocationProvider,
|
|
738
|
+
{},
|
|
739
|
+
h(
|
|
740
|
+
Router,
|
|
741
|
+
{},
|
|
742
|
+
localeMap(({ locale, urlPrefix }) => ({ locale, urlPrefix }))
|
|
743
|
+
.sort((a, b) => b.urlPrefix.length - a.urlPrefix.length)
|
|
744
|
+
.map(({ locale, urlPrefix }) =>
|
|
745
|
+
h(Route, {
|
|
746
|
+
key: locale,
|
|
747
|
+
path: `${urlPrefix}/:rest*`,
|
|
748
|
+
component: () => h(IntlayerProvider, { locale }, children),
|
|
749
|
+
})
|
|
1018
750
|
)
|
|
1019
|
-
|
|
1020
|
-
) {
|
|
1021
|
-
// स्थानीय भाषा उपसर्ग के बिना पथ पर पुनर्निर्देशित करें
|
|
1022
|
-
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
// बच्चों को IntlayerProvider के साथ लपेटें और वर्तमान स्थानीय भाषा सेट करें
|
|
1026
|
-
return (
|
|
1027
|
-
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
1028
|
-
);
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
const RouterContent = ({ children }) => {
|
|
1033
|
-
const { path } = useLocation();
|
|
1034
|
-
|
|
1035
|
-
if (!path) {
|
|
1036
|
-
return null;
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
const pathLocale = path.split("/")[1];
|
|
1040
|
-
|
|
1041
|
-
const isLocaleRoute = locales
|
|
1042
|
-
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
1043
|
-
.some((locale) => locale.toString() === pathLocale);
|
|
1044
|
-
|
|
1045
|
-
if (isLocaleRoute) {
|
|
1046
|
-
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
return (
|
|
1050
|
-
<AppLocalized
|
|
1051
|
-
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
1052
|
-
>
|
|
1053
|
-
{children}
|
|
1054
|
-
</AppLocalized>
|
|
751
|
+
)
|
|
1055
752
|
);
|
|
1056
|
-
};
|
|
1057
|
-
|
|
1058
|
-
/**
|
|
1059
|
-
* एक राउटर कॉम्पोनेंट जो लोकल-विशिष्ट रूट सेट करता है।
|
|
1060
|
-
* यह नेविगेशन प्रबंधित करने और स्थानीयकृत कॉम्पोनेंट्स को रेंडर करने के लिए preact-iso का उपयोग करता है।
|
|
1061
|
-
*/
|
|
1062
|
-
const LocaleRouter = ({ children }) => (
|
|
1063
|
-
<LocationProvider>
|
|
1064
|
-
<RouterContent>{children}</RouterContent>
|
|
1065
|
-
</LocationProvider>
|
|
1066
|
-
);
|
|
1067
753
|
|
|
1068
754
|
module.exports = { LocaleRouter };
|
|
1069
755
|
```
|
|
@@ -1073,7 +759,8 @@ module.exports = { LocaleRouter };
|
|
|
1073
759
|
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
1074
760
|
import { LocaleRouter } from "./components/LocaleRouter";
|
|
1075
761
|
import type { FunctionalComponent } from "preact";
|
|
1076
|
-
|
|
762
|
+
|
|
763
|
+
// ... आपका AppContent कॉम्पोनेंट
|
|
1077
764
|
|
|
1078
765
|
const App: FunctionalComponent = () => (
|
|
1079
766
|
<LocaleRouter>
|
|
@@ -1086,7 +773,8 @@ export default App;
|
|
|
1086
773
|
|
|
1087
774
|
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1088
775
|
import { LocaleRouter } from "./components/LocaleRouter";
|
|
1089
|
-
|
|
776
|
+
|
|
777
|
+
// ... आपका AppContent कॉम्पोनेंट
|
|
1090
778
|
|
|
1091
779
|
const App = () => (
|
|
1092
780
|
<LocaleRouter>
|
|
@@ -1099,7 +787,8 @@ export default App;
|
|
|
1099
787
|
|
|
1100
788
|
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1101
789
|
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
1102
|
-
|
|
790
|
+
|
|
791
|
+
// ... आपका AppContent कॉम्पोनेंट
|
|
1103
792
|
|
|
1104
793
|
const App = () => (
|
|
1105
794
|
<LocaleRouter>
|
|
@@ -1110,47 +799,12 @@ const App = () => (
|
|
|
1110
799
|
module.exports = App;
|
|
1111
800
|
```
|
|
1112
801
|
|
|
1113
|
-
|
|
802
|
+
### (वैकल्पिक) चरण 8: लोकल बदलने पर URL बदलें
|
|
1114
803
|
|
|
1115
|
-
|
|
1116
|
-
import { defineConfig } from "vite";
|
|
1117
|
-
import preact from "@preact/preset-vite";
|
|
1118
|
-
import { intlayer, intlayerProxy } from "vite-intlayer";
|
|
1119
|
-
|
|
1120
|
-
// https://vitejs.dev/config/
|
|
1121
|
-
export default defineConfig({
|
|
1122
|
-
plugins: [preact(), intlayer(), intlayerProxy()],
|
|
1123
|
-
});
|
|
1124
|
-
```
|
|
1125
|
-
|
|
1126
|
-
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1127
|
-
import { defineConfig } from "vite";
|
|
1128
|
-
import preact from "@preact/preset-vite";
|
|
1129
|
-
import { intlayer, intlayerProxy } from "vite-intlayer";
|
|
1130
|
-
|
|
1131
|
-
// https://vitejs.dev/config/
|
|
1132
|
-
export default defineConfig({
|
|
1133
|
-
plugins: [preact(), intlayer(), intlayerProxy()],
|
|
1134
|
-
});
|
|
1135
|
-
```
|
|
1136
|
-
|
|
1137
|
-
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1138
|
-
const { defineConfig } = require("vite");
|
|
1139
|
-
const preact = require("@preact/preset-vite");
|
|
1140
|
-
const { intlayer, intlayerProxy } = require("vite-intlayer");
|
|
1141
|
-
|
|
1142
|
-
// https://vitejs.dev/config/
|
|
1143
|
-
module.exports = defineConfig({
|
|
1144
|
-
plugins: [preact(), intlayer(), intlayerProxy()],
|
|
1145
|
-
});
|
|
1146
|
-
```
|
|
1147
|
-
|
|
1148
|
-
### (वैकल्पिक) चरण 8: जब भाषा बदलती है तो URL बदलें
|
|
1149
|
-
|
|
1150
|
-
जब लोकल बदलता है तो URL बदलने के लिए, आप `useLocale` हुक द्वारा प्रदान किया गया `onLocaleChange` प्रॉप का उपयोग कर सकते हैं। साथ ही, आप URL पथ को अपडेट करने के लिए `preact-iso` से `useLocation` और `route` का उपयोग कर सकते हैं।
|
|
804
|
+
लोकल बदलने पर URL बदलने के लिए, आप `useLocale` हुक द्वारा प्रदान किए गए `onLocaleChange` प्रॉप का उपयोग कर सकते हैं। साथ ही, आप URL पथ अपडेट करने के लिए `preact-iso` के `useLocation` से `route` विधि का उपयोग कर सकते हैं।
|
|
1151
805
|
|
|
1152
806
|
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1153
|
-
import { useLocation
|
|
807
|
+
import { useLocation } from "preact-iso";
|
|
1154
808
|
import {
|
|
1155
809
|
Locales,
|
|
1156
810
|
getHTMLTextDir,
|
|
@@ -1161,16 +815,15 @@ import { useLocale } from "preact-intlayer";
|
|
|
1161
815
|
import type { FunctionalComponent } from "preact";
|
|
1162
816
|
|
|
1163
817
|
const LocaleSwitcher: FunctionalComponent = () => {
|
|
1164
|
-
const
|
|
818
|
+
const { url, route } = useLocation();
|
|
1165
819
|
const { locale, availableLocales, setLocale } = useLocale({
|
|
1166
820
|
onLocaleChange: (newLocale) => {
|
|
1167
|
-
|
|
1168
|
-
// अपडेट किए गए लोकल के साथ URL बनाएं
|
|
821
|
+
// अपडेटेड लोकल के साथ URL का निर्माण करें
|
|
1169
822
|
// उदाहरण: /es/about?foo=bar
|
|
1170
|
-
const pathWithLocale = getLocalizedUrl(
|
|
823
|
+
const pathWithLocale = getLocalizedUrl(url, newLocale);
|
|
1171
824
|
|
|
1172
825
|
// URL पथ अपडेट करें
|
|
1173
|
-
route(pathWithLocale, true); //
|
|
826
|
+
route(pathWithLocale, true); // रिप्लेस के लिए true
|
|
1174
827
|
},
|
|
1175
828
|
});
|
|
1176
829
|
|
|
@@ -1180,30 +833,30 @@ const LocaleSwitcher: FunctionalComponent = () => {
|
|
|
1180
833
|
<div id="localePopover" popover="auto">
|
|
1181
834
|
{availableLocales.map((localeItem) => (
|
|
1182
835
|
<a
|
|
1183
|
-
href={getLocalizedUrl(
|
|
836
|
+
href={getLocalizedUrl(url, localeItem)}
|
|
1184
837
|
hreflang={localeItem}
|
|
1185
838
|
aria-current={locale === localeItem ? "page" : undefined}
|
|
1186
839
|
onClick={(e) => {
|
|
1187
840
|
e.preventDefault();
|
|
1188
841
|
setLocale(localeItem);
|
|
1189
|
-
//
|
|
842
|
+
// लोकल सेट करने के बाद प्रोग्रामेटिक नेविगेशन onLocaleChange द्वारा संभाला जाएगा
|
|
1190
843
|
}}
|
|
1191
844
|
key={localeItem}
|
|
1192
845
|
>
|
|
1193
846
|
<span>
|
|
1194
|
-
{/* लोकल -
|
|
847
|
+
{/* लोकल - उदा. FR */}
|
|
1195
848
|
{localeItem}
|
|
1196
849
|
</span>
|
|
1197
850
|
<span>
|
|
1198
|
-
{/*
|
|
851
|
+
{/* स्वयं के लोकल में भाषा - उदा. Français */}
|
|
1199
852
|
{getLocaleName(localeItem, localeItem)}
|
|
1200
853
|
</span>
|
|
1201
854
|
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1202
|
-
{/* वर्तमान लोकल में भाषा -
|
|
855
|
+
{/* वर्तमान लोकल में भाषा - उदा. Francés यदि वर्तमान लोकल Locales.SPANISH सेट है */}
|
|
1203
856
|
{getLocaleName(localeItem, locale)}
|
|
1204
857
|
</span>
|
|
1205
858
|
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1206
|
-
{/* अंग्रेज़ी में भाषा -
|
|
859
|
+
{/* अंग्रेज़ी में भाषा - उदा. French */}
|
|
1207
860
|
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1208
861
|
</span>
|
|
1209
862
|
</a>
|
|
@@ -1217,7 +870,7 @@ export default LocaleSwitcher;
|
|
|
1217
870
|
```
|
|
1218
871
|
|
|
1219
872
|
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
1220
|
-
import { useLocation
|
|
873
|
+
import { useLocation } from "preact-iso";
|
|
1221
874
|
import {
|
|
1222
875
|
Locales,
|
|
1223
876
|
getHTMLTextDir,
|
|
@@ -1225,14 +878,12 @@ import {
|
|
|
1225
878
|
getLocalizedUrl,
|
|
1226
879
|
} from "intlayer";
|
|
1227
880
|
import { useLocale } from "preact-intlayer";
|
|
1228
|
-
import { h } from "preact"; // JSX के लिए
|
|
1229
881
|
|
|
1230
882
|
const LocaleSwitcher = () => {
|
|
1231
|
-
const
|
|
883
|
+
const { url, route } = useLocation();
|
|
1232
884
|
const { locale, availableLocales, setLocale } = useLocale({
|
|
1233
885
|
onLocaleChange: (newLocale) => {
|
|
1234
|
-
const
|
|
1235
|
-
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
886
|
+
const pathWithLocale = getLocalizedUrl(url, newLocale);
|
|
1236
887
|
route(pathWithLocale, true);
|
|
1237
888
|
},
|
|
1238
889
|
});
|
|
@@ -1243,7 +894,7 @@ const LocaleSwitcher = () => {
|
|
|
1243
894
|
<div id="localePopover" popover="auto">
|
|
1244
895
|
{availableLocales.map((localeItem) => (
|
|
1245
896
|
<a
|
|
1246
|
-
href={getLocalizedUrl(
|
|
897
|
+
href={getLocalizedUrl(url, localeItem)}
|
|
1247
898
|
hreflang={localeItem}
|
|
1248
899
|
aria-current={locale === localeItem ? "page" : undefined}
|
|
1249
900
|
onClick={(e) => {
|
|
@@ -1271,7 +922,7 @@ export default LocaleSwitcher;
|
|
|
1271
922
|
```
|
|
1272
923
|
|
|
1273
924
|
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
1274
|
-
const { useLocation
|
|
925
|
+
const { useLocation } = require("preact-iso");
|
|
1275
926
|
const {
|
|
1276
927
|
Locales,
|
|
1277
928
|
getHTMLTextDir,
|
|
@@ -1279,45 +930,51 @@ const {
|
|
|
1279
930
|
getLocalizedUrl,
|
|
1280
931
|
} = require("intlayer");
|
|
1281
932
|
const { useLocale } = require("preact-intlayer");
|
|
1282
|
-
const { h } = require("preact"); // JSX के लिए
|
|
1283
933
|
|
|
1284
934
|
const LocaleSwitcher = () => {
|
|
1285
|
-
const
|
|
935
|
+
const { url, route } = useLocation();
|
|
1286
936
|
const { locale, availableLocales, setLocale } = useLocale({
|
|
1287
937
|
onLocaleChange: (newLocale) => {
|
|
1288
|
-
const
|
|
1289
|
-
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
938
|
+
const pathWithLocale = getLocalizedUrl(url, newLocale);
|
|
1290
939
|
route(pathWithLocale, true);
|
|
1291
940
|
},
|
|
1292
941
|
});
|
|
1293
942
|
|
|
1294
|
-
return (
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
943
|
+
return h(
|
|
944
|
+
"div",
|
|
945
|
+
{},
|
|
946
|
+
h("button", { popovertarget: "localePopover" }, getLocaleName(locale)),
|
|
947
|
+
h(
|
|
948
|
+
"div",
|
|
949
|
+
{ id: "localePopover", popover: "auto" },
|
|
950
|
+
availableLocales.map((localeItem) =>
|
|
951
|
+
h(
|
|
952
|
+
"a",
|
|
953
|
+
{
|
|
954
|
+
href: getLocalizedUrl(url, localeItem),
|
|
955
|
+
hreflang: localeItem,
|
|
956
|
+
"aria-current": locale === localeItem ? "page" : undefined,
|
|
957
|
+
onClick: (e) => {
|
|
1304
958
|
e.preventDefault();
|
|
1305
959
|
setLocale(localeItem);
|
|
1306
|
-
}
|
|
1307
|
-
key
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
960
|
+
},
|
|
961
|
+
key: localeItem,
|
|
962
|
+
},
|
|
963
|
+
h("span", {}, localeItem),
|
|
964
|
+
h("span", {}, getLocaleName(localeItem, localeItem)),
|
|
965
|
+
h(
|
|
966
|
+
"span",
|
|
967
|
+
{ dir: getHTMLTextDir(localeItem), lang: localeItem },
|
|
968
|
+
getLocaleName(localeItem, locale)
|
|
969
|
+
),
|
|
970
|
+
h(
|
|
971
|
+
"span",
|
|
972
|
+
{ dir: "ltr", lang: Locales.ENGLISH },
|
|
973
|
+
getLocaleName(localeItem, Locales.ENGLISH)
|
|
974
|
+
)
|
|
975
|
+
)
|
|
976
|
+
)
|
|
977
|
+
)
|
|
1321
978
|
);
|
|
1322
979
|
};
|
|
1323
980
|
|
|
@@ -1326,33 +983,21 @@ module.exports = LocaleSwitcher;
|
|
|
1326
983
|
|
|
1327
984
|
> दस्तावेज़ संदर्भ:
|
|
1328
985
|
>
|
|
1329
|
-
> > - [`useLocale` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/react-intlayer/useLocale.md) (`preact-intlayer` के लिए
|
|
1330
|
-
> > - [`getLocaleName` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getLocaleName.md)
|
|
1331
|
-
> > - [`getLocalizedUrl` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getLocalizedUrl.md)
|
|
1332
|
-
> > - [`getHTMLTextDir` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getHTMLTextDir.md)
|
|
1333
|
-
> > - [`hreflang` एट्रिब्यूट](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=hi)
|
|
1334
|
-
> > - [`lang` एट्रिब्यूट](https://developer.mozilla.org/hi/docs/Web/HTML/Global_attributes/lang)
|
|
1335
|
-
> > - [`dir` एट्रिब्यूट](https://developer.mozilla.org/hi/docs/Web/HTML/Global_attributes/dir)
|
|
1336
|
-
> > - [`aria-current` एट्रिब्यूट](https://developer.mozilla.org/hi/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1337
|
-
> > - [Popover API](https://developer.mozilla.org/hi/docs/Web/API/Popover_API)la.org/en-US/docs/Web/HTML/Global_attributes/dir)> - [`aria-current` विशेषता](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)> - [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
1338
|
-
|
|
1339
|
-
नीचे अपडेट किया गया **चरण 9** है जिसमें अतिरिक्त व्याख्याएँ और परिष्कृत कोड उदाहरण शामिल हैं:
|
|
1340
|
-
|
|
1341
|
-
---
|
|
986
|
+
> > - [`useLocale` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/react-intlayer/useLocale.md) (API `preact-intlayer` के लिए समान है)> - [`getLocaleName` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getLocaleName.md)> - [`getLocalizedUrl` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getLocalizedUrl.md)> - [`getHTMLTextDir` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getHTMLTextDir.md)> - [`hreflang` एट्रिब्यूट](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=hi)> - [`lang` एट्रिब्यूट](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)> - [`dir` एट्रिब्यूट](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)> - [`aria-current` एट्रिब्यूट](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)> - [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
1342
987
|
|
|
1343
988
|
### (वैकल्पिक) चरण 9: HTML भाषा और दिशा विशेषताएँ स्विच करें
|
|
1344
989
|
|
|
1345
|
-
जब आपका एप्लिकेशन कई भाषाओं का समर्थन करता है, तो
|
|
990
|
+
जब आपका एप्लिकेशन कई भाषाओं का समर्थन करता है, तो `<html>` टैग के `lang` और `dir` विशेषताओं को वर्तमान लोकल से मिलान करने के लिए अपडेट करना महत्वपूर्ण है। ऐसा करने से सुनिश्चित होता है:
|
|
1346
991
|
|
|
1347
|
-
- **सुलभता**: स्क्रीन रीडर और सहायक तकनीकें
|
|
1348
|
-
-
|
|
1349
|
-
-
|
|
992
|
+
- **सुलभता**: स्क्रीन रीडर और सहायक तकनीकें सामग्री को सही ढंग से उच्चारित और व्याख्या करने के लिए सही `lang` विशेषता पर निर्भर करती हैं।
|
|
993
|
+
- **टेक्स्ट रेंडरिंग**: `dir` (दिशा) विशेषता सुनिश्चित करती है कि टेक्स्ट सही क्रम में रेंडर हो (उदा. अंग्रेज़ी के लिए बाएं-से-दाएं, अरबी या हिब्रू के लिए दाएं-से-बाएं), जो पठनीयता के लिए आवश्यक है।
|
|
994
|
+
- **SEO**: सर्च इंजन आपके पेज की भाषा निर्धारित करने के लिए `lang` विशेषता का उपयोग करते हैं, जिससे सर्च परिणामों में सही स्थानीयकृत सामग्री परोसने में मदद मिलती है।
|
|
1350
995
|
|
|
1351
|
-
|
|
996
|
+
लोकल बदलने पर इन विशेषताओं को गतिशील रूप से अपडेट करके, आप सभी समर्थित भाषाओं में उपयोगकर्ताओं के लिए एक सुसंगत और सुलभ अनुभव की गारंटी देते हैं।
|
|
1352
997
|
|
|
1353
998
|
#### हुक को लागू करना
|
|
1354
999
|
|
|
1355
|
-
HTML
|
|
1000
|
+
HTML विशेषताओं को प्रबंधित करने के लिए एक कस्टम हुक बनाएं। यह हुक लोकल परिवर्तनों को सुनता है और तदनुसार विशेषताओं को अपडेट करता है:
|
|
1356
1001
|
|
|
1357
1002
|
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1358
1003
|
import { useEffect } from "preact/hooks";
|
|
@@ -1360,20 +1005,20 @@ import { useLocale } from "preact-intlayer";
|
|
|
1360
1005
|
import { getHTMLTextDir } from "intlayer";
|
|
1361
1006
|
|
|
1362
1007
|
/**
|
|
1363
|
-
* वर्तमान
|
|
1364
|
-
* - `lang`: ब्राउज़र और सर्च
|
|
1365
|
-
* - `dir`: सही पढ़ने
|
|
1008
|
+
* वर्तमान लोकल के आधार पर HTML <html> तत्व के `lang` और `dir` विशेषताओं को अपडेट करता है।
|
|
1009
|
+
* - `lang`: ब्राउज़र और सर्च इंजन को पेज की भाषा के बारे में सूचित करता है।
|
|
1010
|
+
* - `dir`: सही पढ़ने का क्रम सुनिश्चित करता है (उदा. अंग्रेज़ी के लिए 'ltr', अरबी के लिए 'rtl')।
|
|
1366
1011
|
*
|
|
1367
|
-
* यह गतिशील अपडेट
|
|
1012
|
+
* यह गतिशील अपडेट उचित टेक्स्ट रेंडरिंग, सुलभता और SEO के लिए आवश्यक है।
|
|
1368
1013
|
*/
|
|
1369
1014
|
export const useI18nHTMLAttributes = () => {
|
|
1370
1015
|
const { locale } = useLocale();
|
|
1371
1016
|
|
|
1372
1017
|
useEffect(() => {
|
|
1373
|
-
//
|
|
1018
|
+
// भाषा विशेषता को वर्तमान लोकल में अपडेट करें।
|
|
1374
1019
|
document.documentElement.lang = locale;
|
|
1375
1020
|
|
|
1376
|
-
// वर्तमान लोकल के आधार पर टेक्स्ट दिशा सेट करें।
|
|
1021
|
+
// वर्तमान लोकल के आधार पर टेक्स्ट की दिशा सेट करें।
|
|
1377
1022
|
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1378
1023
|
}, [locale]);
|
|
1379
1024
|
};
|
|
@@ -1385,7 +1030,7 @@ import { useLocale } from "preact-intlayer";
|
|
|
1385
1030
|
import { getHTMLTextDir } from "intlayer";
|
|
1386
1031
|
|
|
1387
1032
|
/**
|
|
1388
|
-
* वर्तमान लोकल के आधार पर HTML <html> तत्व के `lang` और `dir`
|
|
1033
|
+
* वर्तमान लोकल के आधार पर HTML <html> तत्व के `lang` और `dir` विशेषताओं को अपडेट करता है।
|
|
1389
1034
|
*/
|
|
1390
1035
|
export const useI18nHTMLAttributes = () => {
|
|
1391
1036
|
const { locale } = useLocale();
|
|
@@ -1403,7 +1048,7 @@ const { useLocale } = require("preact-intlayer");
|
|
|
1403
1048
|
const { getHTMLTextDir } = require("intlayer");
|
|
1404
1049
|
|
|
1405
1050
|
/**
|
|
1406
|
-
* वर्तमान लोकल के आधार पर HTML <html> तत्व के `lang` और `dir`
|
|
1051
|
+
* वर्तमान लोकल के आधार पर HTML <html> तत्व के `lang` और `dir` विशेषताओं को अपडेट करता है।
|
|
1407
1052
|
*/
|
|
1408
1053
|
const useI18nHTMLAttributes = () => {
|
|
1409
1054
|
const { locale } = useLocale();
|
|
@@ -1419,20 +1064,20 @@ module.exports = { useI18nHTMLAttributes };
|
|
|
1419
1064
|
|
|
1420
1065
|
#### अपने एप्लिकेशन में हुक का उपयोग करना
|
|
1421
1066
|
|
|
1422
|
-
अपने मुख्य कॉम्पोनेंट में
|
|
1067
|
+
हुक को अपने मुख्य कॉम्पोनेंट में एकीकृत करें ताकि जब भी लोकल बदले, HTML विशेषताएँ अपडेट हो जाएं:
|
|
1423
1068
|
|
|
1424
1069
|
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
1425
1070
|
import type { FunctionalComponent } from "preact";
|
|
1426
|
-
import { IntlayerProvider } from "preact-intlayer"; //
|
|
1071
|
+
import { IntlayerProvider } from "preact-intlayer"; // useIntlayer पहले से आयातित है यदि AppContent को इसकी आवश्यकता है
|
|
1427
1072
|
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1428
1073
|
import "./app.css";
|
|
1429
1074
|
// चरण 5 से AppContent परिभाषा
|
|
1430
1075
|
|
|
1431
1076
|
const AppWithHooks: FunctionalComponent = () => {
|
|
1432
|
-
//
|
|
1077
|
+
// लोकल के आधार पर <html> टैग के lang और dir विशेषताओं को अपडेट करने के लिए हुक लागू करें।
|
|
1433
1078
|
useI18nHTMLAttributes();
|
|
1434
1079
|
|
|
1435
|
-
// मान लेते हैं कि AppContent
|
|
1080
|
+
// मान लेते हैं कि AppContent चरण 5 से आपका मुख्य सामग्री प्रदर्शन कॉम्पोनेंट है
|
|
1436
1081
|
return <AppContent />;
|
|
1437
1082
|
};
|
|
1438
1083
|
|
|
@@ -1449,7 +1094,7 @@ export default App;
|
|
|
1449
1094
|
import { IntlayerProvider } from "preact-intlayer";
|
|
1450
1095
|
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1451
1096
|
import "./app.css";
|
|
1452
|
-
// चरण 5 से AppContent
|
|
1097
|
+
// चरण 5 से AppContent परिभाषा
|
|
1453
1098
|
|
|
1454
1099
|
const AppWithHooks = () => {
|
|
1455
1100
|
useI18nHTMLAttributes();
|
|
@@ -1485,199 +1130,178 @@ const App = () => (
|
|
|
1485
1130
|
module.exports = App;
|
|
1486
1131
|
```
|
|
1487
1132
|
|
|
1488
|
-
इन परिवर्तनों को लागू करने से, आपका एप्लिकेशन:
|
|
1489
|
-
|
|
1490
|
-
- सुनिश्चित करेगा कि **भाषा** (`lang`) एट्रिब्यूट वर्तमान लोकल को सही ढंग से दर्शाता है, जो SEO और ब्राउज़र व्यवहार के लिए महत्वपूर्ण है।
|
|
1491
|
-
- लोकल के अनुसार **पाठ दिशा** (`dir`) को समायोजित करेगा, जिससे विभिन्न पढ़ने के क्रम वाली भाषाओं के लिए पठनीयता और उपयोगिता बढ़ेगी।
|
|
1492
|
-
- एक अधिक **सुलभ** अनुभव प्रदान करें, क्योंकि सहायक तकनीकें इन विशेषताओं पर निर्भर करती हैं ताकि वे सही ढंग से काम कर सकें।
|
|
1493
|
-
|
|
1494
1133
|
### (वैकल्पिक) चरण 10: एक स्थानीयकृत लिंक कॉम्पोनेंट बनाना
|
|
1495
1134
|
|
|
1496
|
-
यह सुनिश्चित करने के लिए कि आपके एप्लिकेशन का नेविगेशन वर्तमान लोकल का सम्मान करता है, आप एक कस्टम `Link` कॉम्पोनेंट बना सकते हैं। यह कॉम्पोनेंट स्वचालित रूप से आंतरिक URL को वर्तमान भाषा के साथ
|
|
1135
|
+
यह सुनिश्चित करने के लिए कि आपके एप्लिकेशन का नेविगेशन वर्तमान लोकल का सम्मान करता है, आप एक कस्टम `Link` कॉम्पोनेंट बना सकते हैं। यह कॉम्पोनेंट स्वचालित रूप से आंतरिक URL को वर्तमान भाषा के साथ उपसर्ग (prefix) करता है।
|
|
1497
1136
|
|
|
1498
1137
|
यह व्यवहार कई कारणों से उपयोगी है:
|
|
1499
1138
|
|
|
1500
1139
|
- **SEO और उपयोगकर्ता अनुभव**: स्थानीयकृत URL खोज इंजन को भाषा-विशिष्ट पृष्ठों को सही ढंग से अनुक्रमित करने में मदद करते हैं और उपयोगकर्ताओं को उनकी पसंदीदा भाषा में सामग्री प्रदान करते हैं।
|
|
1501
|
-
- **संगति**:
|
|
1502
|
-
-
|
|
1140
|
+
- **संगति**: पूरे एप्लिकेशन में स्थानीयकृत लिंक का उपयोग करके, आप गारंटी देते हैं कि नेविगेशन वर्तमान लोकल के भीतर बना रहे, जिससे अप्रत्याशित भाषा परिवर्तन रुक जाते हैं।
|
|
1141
|
+
- **रखरखाव**: एक ही कॉम्पोनेंट में स्थानीयकरण तर्क को केंद्रित करने से URL का प्रबंधन सरल हो जाता है।
|
|
1503
1142
|
|
|
1504
|
-
Preact
|
|
1143
|
+
Preact में एक स्थानीयकृत `Link` कॉम्पोनेंट का कार्यान्वयन नीचे दिया गया है:
|
|
1505
1144
|
|
|
1506
|
-
```tsx fileName="src/components/
|
|
1145
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1507
1146
|
import { getLocalizedUrl } from "intlayer";
|
|
1508
|
-
import { useLocale
|
|
1509
|
-
|
|
1510
|
-
import type { JSX } from "preact";
|
|
1511
|
-
import { forwardRef } from "preact/compat"; // refs अग्रेषित करने के लिए
|
|
1147
|
+
import { useLocale } from "preact-intlayer";
|
|
1148
|
+
import { forwardRef } from "preact/compat";
|
|
1149
|
+
import type { JSX } from "preact";
|
|
1512
1150
|
|
|
1513
|
-
export interface
|
|
1151
|
+
export interface LinkProps extends JSX.HTMLAttributes<HTMLAnchorElement> {
|
|
1514
1152
|
href: string;
|
|
1515
|
-
replace?: boolean; // वैकल्पिक: इतिहास स्थिति को बदलने के लिए
|
|
1516
1153
|
}
|
|
1517
1154
|
|
|
1518
1155
|
/**
|
|
1519
|
-
*
|
|
1156
|
+
* यह जांचने के लिए उपयोगिता फ़ंक्शन कि दिया गया URL बाहरी है या नहीं।
|
|
1520
1157
|
* यदि URL http:// या https:// से शुरू होता है, तो इसे बाहरी माना जाता है।
|
|
1521
1158
|
*/
|
|
1522
1159
|
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1523
1160
|
/^https?:\/\//.test(href ?? "");
|
|
1524
1161
|
|
|
1525
1162
|
/**
|
|
1526
|
-
* एक कस्टम लिंक कॉम्पोनेंट जो वर्तमान
|
|
1527
|
-
* आंतरिक लिंक के लिए, यह
|
|
1528
|
-
* यह सुनिश्चित करता है कि नेविगेशन उसी
|
|
1529
|
-
* यह एक मानक <a> टैग का उपयोग करता है लेकिन preact-iso के `route` का उपयोग करके क्लाइंट-साइड नेविगेशन को ट्रिगर कर सकता है।
|
|
1163
|
+
* एक कस्टम लिंक कॉम्पोनेंट जो वर्तमान लोकल के आधार पर href विशेषता को अनुकूलित करता है।
|
|
1164
|
+
* आंतरिक लिंक के लिए, यह URL को लोकल (उदा. /fr/about) के साथ उपसर्ग करने के लिए `getLocalizedUrl` का उपयोग करता है।
|
|
1165
|
+
* यह सुनिश्चित करता है कि नेविगेशन उसी लोकल संदर्भ के भीतर बना रहे।
|
|
1530
1166
|
*/
|
|
1531
|
-
export const
|
|
1532
|
-
({ href, children,
|
|
1167
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
1168
|
+
({ href, children, ...props }, ref) => {
|
|
1533
1169
|
const { locale } = useLocale();
|
|
1534
|
-
const location = useLocation(); // preact-iso से
|
|
1535
1170
|
const isExternalLink = checkIsExternalLink(href);
|
|
1536
1171
|
|
|
1172
|
+
// यदि लिंक आंतरिक है और एक मान्य href प्रदान किया गया है, तो स्थानीयकृत URL प्राप्त करें।
|
|
1537
1173
|
const hrefI18n =
|
|
1538
1174
|
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1539
1175
|
|
|
1540
|
-
const handleClick = (event: JSX.TargetedMouseEvent<HTMLAnchorElement>) => {
|
|
1541
|
-
if (onClick) {
|
|
1542
|
-
onClick(event);
|
|
1543
|
-
}
|
|
1544
|
-
if (
|
|
1545
|
-
!isExternalLink &&
|
|
1546
|
-
href && // सुनिश्चित करें कि href परिभाषित है
|
|
1547
|
-
event.button === 0 && // बायाँ क्लिक
|
|
1548
|
-
!event.metaKey &&
|
|
1549
|
-
!event.ctrlKey &&
|
|
1550
|
-
!event.shiftKey &&
|
|
1551
|
-
!event.altKey && // मानक मॉडिफायर जांच
|
|
1552
|
-
!props.target // नया टैब/विंडो लक्षित नहीं कर रहा है
|
|
1553
|
-
) {
|
|
1554
|
-
event.preventDefault();
|
|
1555
|
-
if (location.url !== hrefI18n) {
|
|
1556
|
-
// केवल तब नेविगेट करें जब URL अलग हो
|
|
1557
|
-
route(hrefI18n, replace); // preact-iso के route का उपयोग करें
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
};
|
|
1561
|
-
|
|
1562
1176
|
return (
|
|
1563
|
-
<a href={hrefI18n} ref={ref}
|
|
1177
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1564
1178
|
{children}
|
|
1565
1179
|
</a>
|
|
1566
1180
|
);
|
|
1567
1181
|
}
|
|
1568
1182
|
);
|
|
1183
|
+
|
|
1184
|
+
Link.displayName = "Link";
|
|
1569
1185
|
```
|
|
1570
1186
|
|
|
1571
|
-
```jsx fileName="src/components/
|
|
1187
|
+
```jsx fileName="src/components/Link.jsx" codeFormat="esm"
|
|
1572
1188
|
import { getLocalizedUrl } from "intlayer";
|
|
1573
1189
|
import { useLocale } from "preact-intlayer";
|
|
1574
|
-
import { useLocation, route } from "preact-iso"; // preact-iso से आयात करें
|
|
1575
1190
|
import { forwardRef } from "preact/compat";
|
|
1576
|
-
import { h } from "preact"; // JSX के लिए
|
|
1577
1191
|
|
|
1192
|
+
/**
|
|
1193
|
+
* यह जांचने के लिए उपयोगिता फ़ंक्शन कि दिया गया URL बाहरी है या नहीं।
|
|
1194
|
+
* यदि URL http:// या https:// से शुरू होता है, तो इसे बाहरी माना जाता है।
|
|
1195
|
+
*/
|
|
1578
1196
|
export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1579
1197
|
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1198
|
+
/**
|
|
1199
|
+
* एक कस्टम लिंक कॉम्पोनेंट जो वर्तमान लोकल के आधार पर href विशेषता को अनुकूलित करता.
|
|
1200
|
+
* आंतरिक लिंक के लिए, यह URL को लोकल (उदा. /fr/about) के साथ उपसर्ग करने के लिए `getLocalizedUrl` का उपयोग करता है.
|
|
1201
|
+
* यह सुनिश्चित करता है कि नेविगेशन उसी लोकल संदर्भ के भीतर बना रहे.
|
|
1202
|
+
*/
|
|
1203
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1204
|
+
const { locale } = useLocale();
|
|
1205
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1585
1206
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1207
|
+
// यदि लिंक आंतरिक है और एक मान्य href प्रदान किया गया है, तो स्थानीयकृत URL प्राप्त करें।
|
|
1208
|
+
const hrefI18n =
|
|
1209
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1588
1210
|
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
href &&
|
|
1596
|
-
event.button === 0 &&
|
|
1597
|
-
!event.metaKey &&
|
|
1598
|
-
!event.ctrlKey &&
|
|
1599
|
-
!event.shiftKey &&
|
|
1600
|
-
!event.altKey &&
|
|
1601
|
-
!props.target
|
|
1602
|
-
) {
|
|
1603
|
-
event.preventDefault();
|
|
1604
|
-
if (location.url !== hrefI18n) {
|
|
1605
|
-
route(hrefI18n, replace);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
};
|
|
1211
|
+
return (
|
|
1212
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1213
|
+
{children}
|
|
1214
|
+
</a>
|
|
1215
|
+
);
|
|
1216
|
+
});
|
|
1609
1217
|
|
|
1610
|
-
|
|
1611
|
-
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1612
|
-
{children}
|
|
1613
|
-
</a>
|
|
1614
|
-
);
|
|
1615
|
-
}
|
|
1616
|
-
);
|
|
1218
|
+
Link.displayName = "Link";
|
|
1617
1219
|
```
|
|
1618
1220
|
|
|
1619
|
-
```jsx fileName="src/components/
|
|
1221
|
+
```jsx fileName="src/components/Link.cjsx" codeFormat="commonjs"
|
|
1620
1222
|
const { getLocalizedUrl } = require("intlayer");
|
|
1621
1223
|
const { useLocale } = require("preact-intlayer");
|
|
1622
|
-
const { useLocation, route } = require("preact-iso"); // preact-iso से आयात करें
|
|
1623
1224
|
const { forwardRef } = require("preact/compat");
|
|
1624
|
-
const { h } = require("preact"); // JSX के लिए
|
|
1625
|
-
|
|
1626
|
-
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? ""); // जांचें कि लिंक बाहरी है या नहीं
|
|
1627
1225
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
const hrefI18n =
|
|
1635
|
-
href && !isExternalLink ? getLocalizedUrl(href, locale) : href; // स्थानीयकृत URL प्राप्त करें
|
|
1226
|
+
/**
|
|
1227
|
+
* यह जांचने के लिए उपयोगिता फ़ंक्शन कि दिया गया URL बाहरी है या नहीं।
|
|
1228
|
+
* यदि URL http:// या https:// से शुरू होता है, तो इसे बाहरी माना जाता है।
|
|
1229
|
+
*/
|
|
1230
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1636
1231
|
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
}
|
|
1232
|
+
/**
|
|
1233
|
+
* एक कस्टम लिंक कॉम्पोनेंट जो वर्तमान लोकल के आधार पर href विशेषता को अनुकूलित करता है।
|
|
1234
|
+
* आंतरिक लिंक के लिए, यह URL को लोकल (उदा. /fr/about) के साथ उपसर्ग करने के लिए `getLocalizedUrl` का उपयोग करता है।
|
|
1235
|
+
* यह सुनिश्चित करता है कि नेविगेशन उसी लोकल संदर्भ के भीतर बना रहे।
|
|
1236
|
+
*/
|
|
1237
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1238
|
+
const { locale } = useLocale();
|
|
1239
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1240
|
+
|
|
1241
|
+
// यदि लिंक आंतरिक है और एक मान्य href प्रदान किया गया है, तो स्थानीयकृत URL प्राप्त करें।
|
|
1242
|
+
const hrefI18n =
|
|
1243
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1244
|
+
|
|
1245
|
+
return h(
|
|
1246
|
+
"a",
|
|
1247
|
+
{
|
|
1248
|
+
href: hrefI18n,
|
|
1249
|
+
ref: ref,
|
|
1250
|
+
...props,
|
|
1251
|
+
},
|
|
1252
|
+
children
|
|
1253
|
+
);
|
|
1254
|
+
});
|
|
1657
1255
|
|
|
1658
|
-
|
|
1659
|
-
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1660
|
-
{children}
|
|
1661
|
-
</a>
|
|
1662
|
-
);
|
|
1663
|
-
}
|
|
1664
|
-
);
|
|
1256
|
+
Link.displayName = "Link";
|
|
1665
1257
|
|
|
1666
|
-
module.exports = {
|
|
1258
|
+
module.exports = { Link, checkIsExternalLink };
|
|
1667
1259
|
```
|
|
1668
1260
|
|
|
1669
1261
|
#### यह कैसे काम करता है
|
|
1670
1262
|
|
|
1671
1263
|
- **बाहरी लिंक का पता लगाना**:
|
|
1672
|
-
सहायक फ़ंक्शन `checkIsExternalLink` यह निर्धारित करता है कि
|
|
1264
|
+
सहायक फ़ंक्शन `checkIsExternalLink` यह निर्धारित करता है कि URL बाहरी है या नहीं। बाहरी लिंक अपरिवर्तित छोड़ दिए जाते हैं क्योंकि उन्हें स्थानीयकरण की आवश्यकता नहीं होती है।
|
|
1673
1265
|
- **वर्तमान लोकल प्राप्त करना**:
|
|
1674
|
-
`useLocale` हुक वर्तमान लोकल प्रदान करता है।
|
|
1675
|
-
- **URL
|
|
1676
|
-
आंतरिक लिंक के लिए, `getLocalizedUrl`
|
|
1677
|
-
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1266
|
+
`useLocale` हुक वर्तमान लोकल (उदा. फ़्रेंच के लिए `fr`) प्रदान करता है।
|
|
1267
|
+
- **URL को स्थानीयकृत करना**:
|
|
1268
|
+
आंतरिक लिंक (यानी, गैर-बाहरी) के लिए, URL को वर्तमान लोकल के साथ स्वचालित रूप से उपसर्ग करने के लिए `getLocalizedUrl` का उपयोग किया जाता है। इसका मतलब है कि यदि आपका उपयोगकर्ता फ़्रेंच में है, तो `/about` को `href` के रूप में पास करने से यह `/fr/about` में बदल जाएगा।
|
|
1269
|
+
- **लिंक लौटना**:
|
|
1270
|
+
कॉम्पोनेंट स्थानीयकृत URL के साथ एक `<a>` तत्व लौटाता है, जिससे सुनिश्चित होता है कि नेविगेशन लोकल के साथ सुसंगत है।
|
|
1271
|
+
|
|
1272
|
+
### (वैकल्पिक) चरण 11: Markdown और HTML रेंडर करें
|
|
1273
|
+
|
|
1274
|
+
Intlayer Preact में Markdown और HTML सामग्री रेंडर करने का समर्थन करता है।
|
|
1275
|
+
|
|
1276
|
+
आप `.use()` विधि का उपयोग करके Markdown और HTML सामग्री के रेंडरिंग को कस्टमाइज़ कर सकते हैं। यह विधि आपको विशिष्ट टैग के डिफ़ॉल्ट रेंडरिंग को ओवरराइड करने की अनुमति देती है।
|
|
1277
|
+
|
|
1278
|
+
```tsx
|
|
1279
|
+
import { useIntlayer } from "preact-intlayer";
|
|
1280
|
+
|
|
1281
|
+
const { myMarkdownContent, myHtmlContent } = useIntlayer("my-component");
|
|
1282
|
+
|
|
1283
|
+
// ...
|
|
1284
|
+
|
|
1285
|
+
return (
|
|
1286
|
+
<div>
|
|
1287
|
+
{/* बुनियादी रेंडरिंग */}
|
|
1288
|
+
{myMarkdownContent}
|
|
1289
|
+
|
|
1290
|
+
{/* Markdown के लिए कस्टम रेंडरिंग */}
|
|
1291
|
+
{myMarkdownContent.use({
|
|
1292
|
+
h1: (props) => <h1 style={{ color: "red" }} {...props} />,
|
|
1293
|
+
})}
|
|
1294
|
+
|
|
1295
|
+
{/* HTML के लिए बुनियादी रेंडरिंग */}
|
|
1296
|
+
{myHtmlContent}
|
|
1297
|
+
|
|
1298
|
+
{/* HTML के लिए कस्टम रेंडरिंग */}
|
|
1299
|
+
{myHtmlContent.use({
|
|
1300
|
+
b: (props) => <strong style={{ color: "blue" }} {...props} />,
|
|
1301
|
+
})}
|
|
1302
|
+
</div>
|
|
1303
|
+
);
|
|
1304
|
+
```
|
|
1681
1305
|
|
|
1682
1306
|
### टाइपस्क्रिप्ट कॉन्फ़िगर करें
|
|
1683
1307
|
|
|
@@ -1687,11 +1311,11 @@ Intlayer टाइपस्क्रिप्ट के लाभ प्रा
|
|
|
1687
1311
|
|
|
1688
1312
|

|
|
1689
1313
|
|
|
1690
|
-
सुनिश्चित करें कि आपकी
|
|
1314
|
+
सुनिश्चित करें कि आपकी टाइपस्क्रिप्ट कॉन्फ़िगरेशन में ऑटो-जेनरेटेड प्रकार शामिल हैं।
|
|
1691
1315
|
|
|
1692
1316
|
```json5 fileName="tsconfig.json"
|
|
1693
1317
|
{
|
|
1694
|
-
// ... आपकी मौजूदा
|
|
1318
|
+
// ... आपकी मौजूदा टाइपस्क्रिप्ट कॉन्फ़िगरेशन
|
|
1695
1319
|
"compilerOptions": {
|
|
1696
1320
|
// ...
|
|
1697
1321
|
"jsx": "react-jsx",
|
|
@@ -1699,8 +1323,8 @@ Intlayer टाइपस्क्रिप्ट के लाभ प्रा
|
|
|
1699
1323
|
// ...
|
|
1700
1324
|
},
|
|
1701
1325
|
"include": [
|
|
1702
|
-
// ... आपकी मौजूदा
|
|
1703
|
-
".intlayer/**/*.ts", // ऑटो-जेनरेटेड
|
|
1326
|
+
// ... आपकी मौजूदा टाइपस्क्रिप्ट कॉन्फ़िगरेशन
|
|
1327
|
+
".intlayer/**/*.ts", // ऑटो-जेनरेटेड प्रकारों को शामिल करें
|
|
1704
1328
|
],
|
|
1705
1329
|
}
|
|
1706
1330
|
```
|
|
@@ -1709,9 +1333,9 @@ Intlayer टाइपस्क्रिप्ट के लाभ प्रा
|
|
|
1709
1333
|
|
|
1710
1334
|
### Git कॉन्फ़िगरेशन
|
|
1711
1335
|
|
|
1712
|
-
यह
|
|
1336
|
+
यह अनुशंसा की जाती है कि Intlayer द्वारा उत्पन्न फ़ाइलों को अनदेखा किया जाए। यह आपको उन्हें अपने Git रिपॉजिटरी में कमिट करने से बचने की अनुमति देता है।
|
|
1713
1337
|
|
|
1714
|
-
|
|
1338
|
+
ऐसा करने के लिए, आप अपनी `.gitignore` फ़ाइल में निम्नलिखित निर्देश जोड़ सकते हैं:
|
|
1715
1339
|
|
|
1716
1340
|
```plaintext
|
|
1717
1341
|
# Intlayer द्वारा उत्पन्न फ़ाइलों को अनदेखा करें
|
|
@@ -1726,17 +1350,17 @@ Intlayer के साथ अपने विकास अनुभव को
|
|
|
1726
1350
|
|
|
1727
1351
|
यह एक्सटेंशन प्रदान करता है:
|
|
1728
1352
|
|
|
1729
|
-
- अनुवाद कुंजियों के लिए
|
|
1353
|
+
- अनुवाद कुंजियों के लिए **ऑटोकंप्लीट**।
|
|
1730
1354
|
- गायब अनुवादों के लिए **रीयल-टाइम त्रुटि पहचान**।
|
|
1731
1355
|
- अनुवादित सामग्री के **इनलाइन पूर्वावलोकन**।
|
|
1732
1356
|
- अनुवादों को आसानी से बनाने और अपडेट करने के लिए **त्वरित क्रियाएं**।
|
|
1733
1357
|
|
|
1734
|
-
एक्सटेंशन का उपयोग
|
|
1358
|
+
एक्सटेंशन का उपयोग करने के तरीके के बारे में अधिक जानकारी के लिए, [Intlayer VS कोड एक्सटेंशन प्रलेखन](https://intlayer.org/doc/vs-code-extension) देखें।
|
|
1735
1359
|
|
|
1736
1360
|
---
|
|
1737
1361
|
|
|
1738
1362
|
### आगे बढ़ें
|
|
1739
1363
|
|
|
1740
|
-
आगे बढ़ने के लिए, आप [विज़ुअल एडिटर](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_visual_editor.md) को लागू कर सकते हैं या अपनी सामग्री को [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_CMS.md) का उपयोग करके बाहरी रूप से
|
|
1364
|
+
आगे बढ़ने के लिए, आप [विज़ुअल एडिटर](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_visual_editor.md) को लागू कर सकते हैं या अपनी सामग्री को [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_CMS.md) का उपयोग करके बाहरी रूप से व्यवस्थित कर सकते हैं।
|
|
1741
1365
|
|
|
1742
1366
|
---
|