@intlayer/docs 7.0.0-canary.2 → 7.0.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.
Files changed (59) hide show
  1. package/dist/cjs/common.cjs.map +1 -1
  2. package/dist/esm/common.mjs.map +1 -1
  3. package/dist/types/common.d.ts +5 -0
  4. package/dist/types/common.d.ts.map +1 -1
  5. package/docs/ar/configuration.md +0 -24
  6. package/docs/ar/intlayer_with_nextjs_16.md +1652 -0
  7. package/docs/ar/releases/v7.md +485 -0
  8. package/docs/de/configuration.md +0 -24
  9. package/docs/de/intlayer_with_nextjs_16.md +1662 -0
  10. package/docs/de/releases/v7.md +502 -0
  11. package/docs/en/autoFill.md +3 -1
  12. package/docs/en/configuration.md +53 -58
  13. package/docs/en/intlayer_with_nextjs_15.md +5 -2
  14. package/docs/en/intlayer_with_nextjs_16.md +4 -4
  15. package/docs/en/releases/v7.md +142 -2
  16. package/docs/en-GB/configuration.md +9 -30
  17. package/docs/en-GB/intlayer_with_nextjs_16.md +1642 -0
  18. package/docs/en-GB/releases/v7.md +485 -0
  19. package/docs/es/configuration.md +0 -24
  20. package/docs/es/intlayer_with_nextjs_16.md +1670 -0
  21. package/docs/es/releases/v7.md +502 -0
  22. package/docs/fr/configuration.md +0 -24
  23. package/docs/fr/intlayer_with_nextjs_16.md +1692 -0
  24. package/docs/fr/releases/v7.md +503 -0
  25. package/docs/hi/configuration.md +0 -24
  26. package/docs/hi/intlayer_with_nextjs_16.md +1618 -0
  27. package/docs/hi/releases/v7.md +485 -0
  28. package/docs/id/intlayer_with_nextjs_16.md +1604 -0
  29. package/docs/id/releases/v7.md +502 -0
  30. package/docs/it/configuration.md +0 -24
  31. package/docs/it/intlayer_with_nextjs_16.md +1600 -0
  32. package/docs/it/releases/v7.md +504 -0
  33. package/docs/ja/configuration.md +0 -24
  34. package/docs/ja/intlayer_CMS.md +0 -9
  35. package/docs/ja/intlayer_with_nextjs_16.md +1788 -0
  36. package/docs/ja/releases/v7.md +503 -0
  37. package/docs/ko/configuration.md +0 -24
  38. package/docs/ko/intlayer_with_nextjs_16.md +1641 -0
  39. package/docs/ko/releases/v7.md +503 -0
  40. package/docs/pl/intlayer_with_nextjs_16.md +1645 -0
  41. package/docs/pl/releases/v7.md +485 -0
  42. package/docs/pt/configuration.md +0 -24
  43. package/docs/pt/intlayer_with_nextjs_16.md +1646 -0
  44. package/docs/pt/introduction.md +0 -15
  45. package/docs/pt/releases/v7.md +485 -0
  46. package/docs/ru/configuration.md +0 -24
  47. package/docs/ru/intlayer_with_nextjs_16.md +1610 -0
  48. package/docs/ru/releases/v7.md +485 -0
  49. package/docs/tr/configuration.md +0 -24
  50. package/docs/tr/intlayer_with_nextjs_16.md +1599 -0
  51. package/docs/tr/releases/v7.md +485 -0
  52. package/docs/vi/intlayer_with_nextjs_16.md +1597 -0
  53. package/docs/vi/releases/v7.md +485 -0
  54. package/docs/zh/configuration.md +0 -24
  55. package/docs/zh/intlayer_CMS.md +0 -23
  56. package/docs/zh/intlayer_with_nextjs_16.md +1628 -0
  57. package/docs/zh/releases/v7.md +486 -0
  58. package/package.json +14 -14
  59. package/src/common.ts +5 -0
@@ -0,0 +1,1618 @@
1
+ ---
2
+ createdAt: 2025-10-25
3
+ updatedAt: 2025-10-25
4
+ title: अपने Next.js 16 ऐप का अनुवाद कैसे करें – i18n गाइड 2025
5
+ description: जानें कि अपनी Next.js 16 वेबसाइट को बहुभाषी कैसे बनाएं। अंतरराष्ट्रीयकरण (i18n) और अनुवाद के लिए दस्तावेज़ का पालन करें।
6
+ keywords:
7
+ - अंतरराष्ट्रीयकरण
8
+ - दस्तावेज़ीकरण
9
+ - Intlayer
10
+ - Next.js 16
11
+ - जावास्क्रिप्ट
12
+ - रिएक्ट
13
+ slugs:
14
+ - doc
15
+ - environment
16
+ - nextjs
17
+ applicationTemplate: https://github.com/aymericzip/intlayer-next-16-template
18
+ youtubeVideo: https://www.youtube.com/watch?v=e_PPG7PTqGU
19
+ history:
20
+ - version: 7.0.0
21
+ date: 2025-06-29
22
+ changes: प्रारंभिक इतिहास
23
+ ---
24
+
25
+ # Intlayer का उपयोग करके अपनी Next.js 16 वेबसाइट का अनुवाद करें | अंतरराष्ट्रीयकरण (i18n)
26
+
27
+ <iframe title="Next.js के लिए सबसे अच्छा i18n समाधान? Intlayer खोजें" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/e_PPG7PTqGU?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
28
+
29
+ GitHub पर [एप्लिकेशन टेम्प्लेट](https://github.com/aymericzip/intlayer-next-16-template) देखें।
30
+
31
+ ## Intlayer क्या है?
32
+
33
+ **Intlayer** एक अभिनव, ओपन-सोर्स अंतरराष्ट्रीयकरण (i18n) लाइब्रेरी है जिसे आधुनिक वेब एप्लिकेशन में बहुभाषी समर्थन को सरल बनाने के लिए डिज़ाइन किया गया है। Intlayer नवीनतम **Next.js 16** फ्रेमवर्क के साथ सहजता से एकीकृत होता है, जिसमें इसका शक्तिशाली **App Router** शामिल है। यह कुशल रेंडरिंग के लिए **Server Components** के साथ काम करने के लिए अनुकूलित है और पूरी तरह से [**Turbopack**](https://nextjs.org/docs/architecture/turbopack) के साथ संगत है।
34
+
35
+ Intlayer के साथ, आप कर सकते हैं:
36
+
37
+ - **घोषणात्मक शब्दकोशों का उपयोग करके अनुवादों का आसानी से प्रबंधन करें** जो कि कंपोनेंट स्तर पर होते हैं।
38
+ - **मेटाडेटा, रूट्स, और सामग्री को गतिशील रूप से स्थानीयकृत करें**।
39
+ - **क्लाइंट-साइड और सर्वर-साइड दोनों कंपोनेंट्स में अनुवादों तक पहुँच प्राप्त करें**।
40
+ - **स्वचालित रूप से उत्पन्न प्रकारों के साथ TypeScript समर्थन सुनिश्चित करें**, जिससे ऑटोकम्प्लीशन और त्रुटि पहचान में सुधार होता है।
41
+ - **उन्नत विशेषताओं का लाभ उठाएं**, जैसे गतिशील लोकल डिटेक्शन और स्विचिंग।
42
+
43
+ > Intlayer Next.js 12, 13, 14, और 16 के साथ संगत है। यदि आप Next.js Page Router का उपयोग कर रहे हैं, तो आप इस [गाइड](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_with_nextjs_page_router.md) को देख सकते हैं। Next.js 12, 13, 14 के App Router के लिए, इस [गाइड](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_with_nextjs_14.md) को देखें।
44
+
45
+ ---
46
+
47
+ ## Next.js एप्लिकेशन में Intlayer सेटअप करने के लिए चरण-दर-चरण मार्गदर्शिका
48
+
49
+ ### चरण 1: निर्भरताएँ स्थापित करें
50
+
51
+ npm का उपयोग करके आवश्यक पैकेज स्थापित करें:
52
+
53
+ ```bash packageManager="npm"
54
+ npm install intlayer next-intlayer
55
+ ```
56
+
57
+ ```bash packageManager="pnpm"
58
+ pnpm add intlayer next-intlayer
59
+ ```
60
+
61
+ ```bash packageManager="yarn"
62
+ yarn add intlayer next-intlayer
63
+ ```
64
+
65
+ - **intlayer**
66
+
67
+ मुख्य पैकेज जो कॉन्फ़िगरेशन प्रबंधन, अनुवाद, [सामग्री घोषणा](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/intlayer_cli.md) के लिए अंतरराष्ट्रीयकरण उपकरण प्रदान करता है।
68
+
69
+ - **next-intlayer**
70
+
71
+ वह पैकेज जो Intlayer को Next.js के साथ एकीकृत करता है। यह Next.js अंतरराष्ट्रीयकरण के लिए संदर्भ प्रदाता और हुक प्रदान करता है। इसके अतिरिक्त, इसमें Next.js प्लगइन शामिल है जो Intlayer को [Webpack](https://webpack.js.org/) या [Turbopack](https://nextjs.org/docs/app/api-reference/turbopack) के साथ एकीकृत करता है, साथ ही उपयोगकर्ता की पसंदीदा भाषा का पता लगाने, कुकीज़ प्रबंधित करने, और URL पुनर्निर्देशन को संभालने के लिए प्रॉक्सी भी शामिल है।
72
+
73
+ ### चरण 2: अपने प्रोजेक्ट को कॉन्फ़िगर करें
74
+
75
+ अपने एप्लिकेशन की भाषाओं को कॉन्फ़िगर करने के लिए एक कॉन्फ़िग फाइल बनाएं:
76
+
77
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
78
+ import { Locales, type IntlayerConfig } from "intlayer";
79
+
80
+ const config: IntlayerConfig = {
81
+ internationalization: {
82
+ locales: [
83
+ Locales.ENGLISH,
84
+ Locales.FRENCH,
85
+ Locales.SPANISH,
86
+ // आपकी अन्य भाषाएँ
87
+ ],
88
+ defaultLocale: Locales.ENGLISH,
89
+ },
90
+ };
91
+
92
+ export default config;
93
+ ```
94
+
95
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
96
+ import { Locales } from "intlayer";
97
+
98
+ /** @type {import('intlayer').IntlayerConfig} */
99
+ const config = {
100
+ internationalization: {
101
+ locales: [
102
+ Locales.ENGLISH,
103
+ Locales.FRENCH,
104
+ Locales.SPANISH,
105
+ // आपकी अन्य भाषाएँ
106
+ ],
107
+ defaultLocale: Locales.ENGLISH,
108
+ },
109
+ };
110
+
111
+ export default config;
112
+ ```
113
+
114
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
115
+ const { Locales } = require("intlayer");
116
+
117
+ /** @type {import('intlayer').IntlayerConfig} */
118
+ const config = {
119
+ internationalization: {
120
+ locales: [
121
+ Locales.ENGLISH,
122
+ Locales.FRENCH,
123
+ Locales.SPANISH,
124
+ // आपकी अन्य भाषाएँ
125
+ ],
126
+ defaultLocale: Locales.ENGLISH,
127
+ },
128
+ };
129
+
130
+ module.exports = config;
131
+ ```
132
+
133
+ > इस कॉन्फ़िगरेशन फ़ाइल के माध्यम से, आप स्थानीयकृत URL, प्रॉक्सी पुनर्निर्देशन, कुकी नाम, आपकी सामग्री घोषणाओं का स्थान और एक्सटेंशन सेट कर सकते हैं, कंसोल में Intlayer लॉग को अक्षम कर सकते हैं, और भी बहुत कुछ। उपलब्ध सभी पैरामीटरों की पूरी सूची के लिए, [कॉन्फ़िगरेशन दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/configuration.md) देखें।
134
+
135
+ ### चरण 3: अपने Next.js कॉन्फ़िगरेशन में Intlayer को एकीकृत करें
136
+
137
+ अपने Next.js सेटअप को Intlayer का उपयोग करने के लिए कॉन्फ़िगर करें:
138
+
139
+ ```typescript fileName="next.config.ts" codeFormat="typescript"
140
+ import type { NextConfig } from "next";
141
+ import { withIntlayer } from "next-intlayer/server";
142
+
143
+ const nextConfig: NextConfig = {
144
+ /* यहाँ कॉन्फ़िग विकल्प */
145
+ };
146
+
147
+ export default withIntlayer(nextConfig);
148
+ ```
149
+
150
+ ```typescript fileName="next.config.mjs" codeFormat="esm"
151
+ import { withIntlayer } from "next-intlayer/server";
152
+
153
+ /** @type {import('next').NextConfig} */
154
+ const nextConfig = {
155
+ /* यहाँ कॉन्फ़िग विकल्प */
156
+ };
157
+
158
+ export default withIntlayer(nextConfig);
159
+ ```
160
+
161
+ ```typescript fileName="next.config.cjs" codeFormat="commonjs"
162
+ const { withIntlayer } = require("next-intlayer/server");
163
+
164
+ /** @type {import('next').NextConfig} */
165
+ const nextConfig = {
166
+ /* यहाँ कॉन्फ़िग विकल्प */
167
+ };
168
+
169
+ module.exports = withIntlayer(nextConfig);
170
+ ```
171
+
172
+ > `withIntlayer()` Next.js प्लगइन का उपयोग Intlayer को Next.js के साथ एकीकृत करने के लिए किया जाता है। यह कंटेंट डिक्लेरेशन फाइलों के निर्माण को सुनिश्चित करता है और विकास मोड में उनकी निगरानी करता है। यह [Webpack](https://webpack.js.org/) या [Turbopack](https://nextjs.org/docs/app/api-reference/turbopack) वातावरण के भीतर Intlayer पर्यावरण चर को परिभाषित करता है। इसके अतिरिक्त, यह प्रदर्शन को अनुकूलित करने के लिए उपनाम प्रदान करता है और सर्वर कंपोनेंट्स के साथ संगतता सुनिश्चित करता है।
173
+
174
+ > `withIntlayer()` फ़ंक्शन एक प्रॉमिस फ़ंक्शन है। यह बिल्ड शुरू होने से पहले Intlayer शब्दकोशों को तैयार करने की अनुमति देता है। यदि आप इसे अन्य प्लगइन्स के साथ उपयोग करना चाहते हैं, तो आप इसे await कर सकते हैं। उदाहरण:
175
+ >
176
+ > ```tsx
177
+ > const nextConfig = await withIntlayer(nextConfig);
178
+ > const nextConfigWithOtherPlugins = withOtherPlugins(nextConfig);
179
+ >
180
+ > export default nextConfigWithOtherPlugins;
181
+ > ```
182
+ >
183
+ > यदि आप इसे सिंक्रोनसली उपयोग करना चाहते हैं, तो आप `withIntlayerSync()` फ़ंक्शन का उपयोग कर सकते हैं। उदाहरण:
184
+ >
185
+ > ```tsx
186
+ > const nextConfig = withIntlayerSync(nextConfig);
187
+ > const nextConfigWithOtherPlugins = withOtherPlugins(nextConfig);
188
+ >
189
+ > export default nextConfigWithOtherPlugins;
190
+ > ```
191
+
192
+ ### चरण 4: डायनामिक लोकल रूट्स परिभाषित करें
193
+
194
+ `RootLayout` से सब कुछ हटा दें और इसे निम्नलिखित कोड से बदलें:
195
+
196
+ ```tsx {3} fileName="src/app/layout.tsx" codeFormat="typescript"
197
+ import type { PropsWithChildren, FC } from "react";
198
+ import "./globals.css";
199
+
200
+ const RootLayout: FC<PropsWithChildren> = ({ children }) => (
201
+ // आप अभी भी बच्चों को अन्य प्रोवाइडर्स के साथ लपेट सकते हैं, जैसे `next-themes`, `react-query`, `framer-motion`, आदि।
202
+ <>{children}</>
203
+ );
204
+
205
+ export default RootLayout;
206
+ ```
207
+
208
+ ```jsx {3} fileName="src/app/layout.mjx" codeFormat="esm"
209
+ import "./globals.css";
210
+
211
+ const RootLayout = ({ children }) => (
212
+ // आप अभी भी बच्चों को अन्य प्रदाताओं के साथ लपेट सकते हैं, जैसे `next-themes`, `react-query`, `framer-motion`, आदि।
213
+ <>{children}</>
214
+ );
215
+
216
+ export default RootLayout;
217
+ ```
218
+
219
+ ```jsx {1,8} fileName="src/app/layout.csx" codeFormat="commonjs"
220
+ require("./globals.css");
221
+
222
+ const RootLayout = ({ children }) => (
223
+ // आप अभी भी बच्चों को अन्य प्रदाताओं के साथ लपेट सकते हैं, जैसे `next-themes`, `react-query`, `framer-motion`, आदि।
224
+ <>{children}</>
225
+ );
226
+
227
+ module.exports = {
228
+ default: RootLayout,
229
+ generateStaticParams,
230
+ };
231
+ ```
232
+
233
+ > `RootLayout` कॉम्पोनेंट को खाली रखने से `<html>` टैग में [`lang`](https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/lang) और [`dir`](https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/dir) एट्रिब्यूट्स सेट करने की अनुमति मिलती है।
234
+
235
+ डायनामिक रूटिंग को लागू करने के लिए, अपने `[locale]` डायरेक्टरी में एक नया लेआउट जोड़कर लोकल के लिए पाथ प्रदान करें:
236
+
237
+ ```tsx fileName="src/app/[locale]/layout.tsx" codeFormat="typescript"
238
+ import type { NextLayoutIntlayer } from "next-intlayer";
239
+ import { Inter } from "next/font/google";
240
+ import { getHTMLTextDir } from "intlayer";
241
+
242
+ const inter = Inter({ subsets: ["latin"] });
243
+
244
+ const LocaleLayout: NextLayoutIntlayer = async ({ children, params }) => {
245
+ const { locale } = await params;
246
+ return (
247
+ <html lang={locale} dir={getHTMLTextDir(locale)}>
248
+ <body className={inter.className}>{children}</body>
249
+ </html>
250
+ );
251
+ };
252
+
253
+ export default LocaleLayout;
254
+ ```
255
+
256
+ ```jsx fileName="src/app/[locale]/layout.mjx" codeFormat="esm"
257
+ import { getHTMLTextDir } from "intlayer";
258
+
259
+ const inter = Inter({ subsets: ["latin"] });
260
+
261
+ const LocaleLayout = async ({ children, params: { locale } }) => {
262
+ const { locale } = await params;
263
+ return (
264
+ <html lang={locale} dir={getHTMLTextDir(locale)}>
265
+ <body className={inter.className}>{children}</body>
266
+ </html>
267
+ );
268
+ };
269
+
270
+ export default LocaleLayout;
271
+ ```
272
+
273
+ ````jsx fileName="src/app/[locale]/layout.csx" codeFormat="commonjs"
274
+ const { Inter } = require("next/font/google");
275
+ const { getHTMLTextDir } = require("intlayer");
276
+
277
+ const inter = Inter({ subsets: ["latin"] });
278
+
279
+ // `[locale]` पाथ सेगमेंट का उपयोग लोकल को परिभाषित करने के लिए किया जाता है। उदाहरण: `/en-US/about` `en-US` को संदर्भित करेगा और `/fr/about` `fr` को।
280
+ const LocaleLayout = async ({ children, params: { locale } }) => {
281
+ const { locale } = await params;
282
+ return (
283
+ <html lang={locale} dir={getHTMLTextDir(locale)}>
284
+ <body className={inter.className}>{children}</body>
285
+ </html>
286
+ );
287
+ };
288
+
289
+ module.exports = LocaleLayout;
290
+
291
+ > इस चरण में, आपको त्रुटि का सामना करना पड़ेगा: `Error: Missing <html> and <body> tags in the root layout.`। यह अपेक्षित है क्योंकि `/app/page.tsx` फ़ाइल अब उपयोग में नहीं है और इसे हटा दिया जा सकता है। इसके बजाय, `[locale]` पाथ सेगमेंट `/app/[locale]/page.tsx` पेज को सक्रिय करेगा। परिणामस्वरूप, आपके ब्राउज़र में पेज `/en`, `/fr`, `/es` जैसे पाथ के माध्यम से सुलभ होंगे। डिफ़ॉल्ट लोकल को रूट पेज के रूप में सेट करने के लिए, चरण 7 में `proxy` सेटअप को देखें।
292
+
293
+ फिर, अपने एप्लिकेशन लेआउट में `generateStaticParams` फ़ंक्शन को लागू करें।
294
+
295
+ ```tsx {1} fileName="src/app/[locale]/layout.tsx" codeFormat="typescript"
296
+ export { generateStaticParams } from "next-intlayer"; // सम्मिलित करने के लिए लाइन
297
+
298
+ const LocaleLayout: NextLayoutIntlayer = async ({ children, params }) => {
299
+ /*... बाकी कोड */
300
+ };
301
+
302
+ export default LocaleLayout;
303
+ ````
304
+
305
+ ```jsx {1} fileName="src/app/[locale]/layout.mjx" codeFormat="esm"
306
+ export { generateStaticParams } from "next-intlayer"; // सम्मिलित करने के लिए पंक्ति
307
+
308
+ const LocaleLayout = async ({ children, params: { locale } }) => {
309
+ /*... कोड का बाकी हिस्सा*/
310
+ };
311
+
312
+ // ... कोड का बाकी हिस्सा
313
+ ```
314
+
315
+ ```jsx {1,7} fileName="src/app/[locale]/layout.csx" codeFormat="commonjs"
316
+ const { generateStaticParams } = require("next-intlayer"); // सम्मिलित करने के लिए पंक्ति
317
+
318
+ const LocaleLayout = async ({ children, params: { locale } }) => {
319
+ /*... कोड का बाकी हिस्सा*/
320
+ };
321
+
322
+ module.exports = { default: LocaleLayout, generateStaticParams };
323
+ ```
324
+
325
+ > `generateStaticParams` यह सुनिश्चित करता है कि आपका एप्लिकेशन सभी लोकल के लिए आवश्यक पृष्ठों को पूर्व-निर्मित करता है, जिससे रनटाइम गणना कम होती है और उपयोगकर्ता अनुभव बेहतर होता है। अधिक जानकारी के लिए, [Next.js दस्तावेज़ीकरण generateStaticParams पर](https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic-rendering#generate-static-params) देखें।
326
+
327
+ > Intlayer `export const dynamic = 'force-static';` के साथ काम करता है ताकि यह सुनिश्चित किया जा सके कि पृष्ठ सभी लोकल के लिए पूर्व-निर्मित हों।
328
+
329
+ ### चरण 5: अपनी सामग्री घोषित करें
330
+
331
+ अनुवाद संग्रहीत करने के लिए अपनी सामग्री घोषणाएँ बनाएं और प्रबंधित करें:
332
+
333
+ ```tsx fileName="src/app/[locale]/page.content.ts" contentDeclarationFormat="typescript"
334
+ import { t, type Dictionary } from "intlayer";
335
+
336
+ const pageContent = {
337
+ key: "page",
338
+ content: {
339
+ getStarted: {
340
+ main: t({
341
+ en: "Get started by editing",
342
+ fr: "Commencez par éditer",
343
+ es: "Comience por editar",
344
+ }),
345
+ pageLink: "src/app/page.tsx",
346
+ },
347
+ },
348
+ } satisfies Dictionary;
349
+
350
+ export default pageContent;
351
+ ```
352
+
353
+ ```javascript fileName="src/app/[locale]/page.content.mjs" contentDeclarationFormat="esm"
354
+ import { t } from "intlayer";
355
+
356
+ /** @type {import('intlayer').Dictionary} */
357
+ const pageContent = {
358
+ key: "page",
359
+ content: {
360
+ getStarted: {
361
+ main: t({
362
+ en: "Get started by editing",
363
+ fr: "Commencez par éditer",
364
+ es: "Comience por editar",
365
+ }),
366
+ pageLink: "src/app/page.tsx",
367
+ },
368
+ },
369
+ };
370
+
371
+ export default pageContent;
372
+ ```
373
+
374
+ ```javascript fileName="src/app/[locale]/page.content.cjs" contentDeclarationFormat="commonjs"
375
+ const { t } = require("intlayer");
376
+
377
+ /** @type {import('intlayer').Dictionary} */
378
+ const pageContent = {
379
+ key: "page",
380
+ content: {
381
+ getStarted: {
382
+ main: t({
383
+ en: "Get started by editing",
384
+ fr: "Commencez par éditer",
385
+ es: "Comience por editar",
386
+ hi: "संपादन करके शुरू करें",
387
+ }),
388
+ pageLink: "src/app/page.tsx",
389
+ },
390
+ },
391
+ };
392
+
393
+ module.exports = pageContent;
394
+ ```
395
+
396
+ ```json fileName="src/app/[locale]/page.content.json" contentDeclarationFormat="json"
397
+ {
398
+ "$schema": "https://intlayer.org/schema.json",
399
+ "key": "page",
400
+ "content": {
401
+ "getStarted": {
402
+ "nodeType": "translation",
403
+ "translation": {
404
+ "en": "Get started by editing",
405
+ "fr": "Commencez par éditer",
406
+ "es": "Comience por editar",
407
+ "hi": "संपादन करके शुरू करें"
408
+ }
409
+ },
410
+ "pageLink": "src/app/page.tsx"
411
+ }
412
+ }
413
+ ```
414
+
415
+ > आपकी सामग्री घोषणाएँ आपके एप्लिकेशन में कहीं भी परिभाषित की जा सकती हैं जब तक कि वे `contentDir` निर्देशिका (डिफ़ॉल्ट रूप से, `./src`) में शामिल हों। और सामग्री घोषणा फ़ाइल एक्सटेंशन से मेल खाती हों (डिफ़ॉल्ट रूप से, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`)।
416
+
417
+ > अधिक विवरण के लिए, [सामग्री घोषणा प्रलेखन](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/dictionary/content_file.md) देखें।
418
+
419
+ ### चरण 6: अपने कोड में सामग्री का उपयोग करें
420
+
421
+ अपने एप्लिकेशन में अपनी सामग्री शब्दकोशों तक पहुँचें:
422
+
423
+ ```tsx fileName="src/app/[locale]/page.tsx" codeFormat="typescript"
424
+ import type { FC } from "react";
425
+ import { ClientComponentExample } from "@components/ClientComponentExample";
426
+ import { ServerComponentExample } from "@components/ServerComponentExample";
427
+ import { type NextPageIntlayer, IntlayerClientProvider } from "next-intlayer";
428
+ import { IntlayerServerProvider, useIntlayer } from "next-intlayer/server";
429
+
430
+ const PageContent: FC = () => {
431
+ const content = useIntlayer("page"); // सामग्री प्राप्त करने के लिए हुक का उपयोग करें
432
+
433
+ return (
434
+ <>
435
+ <p>{content.getStarted.main}</p> {/* मुख्य परिचय पाठ दिखाएं */}
436
+ <code>{content.getStarted.pageLink}</code> {/* पृष्ठ लिंक दिखाएं */}
437
+ </>
438
+ );
439
+ };
440
+
441
+ const Page: NextPageIntlayer = async ({ params }) => {
442
+ const { locale } = await params; // स्थानीय भाषा प्राप्त करें
443
+
444
+ return (
445
+ <IntlayerServerProvider locale={locale}>
446
+ <PageContent />
447
+ <ServerComponentExample />
448
+
449
+ <IntlayerClientProvider locale={locale}>
450
+ <ClientComponentExample />
451
+ </IntlayerClientProvider>
452
+ </IntlayerServerProvider>
453
+ );
454
+ };
455
+
456
+ export default Page;
457
+ ```
458
+
459
+ ```jsx fileName="src/app/[locale]/page.mjx" codeFormat="esm"
460
+ import { ClientComponentExample } from "@components/ClientComponentExample";
461
+ import { ServerComponentExample } from "@components/ServerComponentExample";
462
+ import { IntlayerClientProvider } from "next-intlayer";
463
+ import { IntlayerServerProvider, useIntlayer } from "next-intlayer/server";
464
+
465
+ const PageContent = () => {
466
+ const content = useIntlayer("page"); // सामग्री प्राप्त करने के लिए हुक का उपयोग करें
467
+
468
+ return (
469
+ <>
470
+ <p>{content.getStarted.main}</p> {/* मुख्य परिचय पाठ दिखाएं */}
471
+ <code>{content.getStarted.pageLink}</code> {/* पृष्ठ लिंक दिखाएं */}
472
+ </>
473
+ );
474
+ };
475
+
476
+ const Page = async ({ params }) => {
477
+ const { locale } = await params; // स्थानीय भाषा प्राप्त करें
478
+
479
+ return (
480
+ <IntlayerServerProvider locale={locale}>
481
+ {" "}
482
+ {/* सर्वर प्रदाता के लिए स्थानीय भाषा सेट करें */}
483
+ <PageContent /> {/* पृष्ठ सामग्री प्रदर्शित करें */}
484
+ <ServerComponentExample /> {/* सर्वर घटक उदाहरण प्रदर्शित करें */}
485
+ <IntlayerClientProvider locale={locale}>
486
+ {" "}
487
+ {/* क्लाइंट प्रदाता के लिए स्थानीय भाषा सेट करें */}
488
+ <ClientComponentExample /> {/* क्लाइंट घटक उदाहरण प्रदर्शित करें */}
489
+ </IntlayerClientProvider>
490
+ </IntlayerServerProvider>
491
+ );
492
+ };
493
+
494
+ export default Page;
495
+ ```
496
+
497
+ ```jsx fileName="src/app/[locale]/page.csx" codeFormat="commonjs"
498
+ import { ClientComponentExample } from "@components/ClientComponentExample";
499
+ import { ServerComponentExample } from "@components/ServerComponentExample";
500
+ import { IntlayerClientProvider } from "next-intlayer";
501
+ import { IntlayerServerProvider, useIntlayer } from "next-intlayer/server";
502
+
503
+ const PageContent = () => {
504
+ const content = useIntlayer("page");
505
+
506
+ return (
507
+ <>
508
+ <p>{content.getStarted.main}</p>
509
+ <code>{content.getStarted.pageLink}</code>
510
+ </>
511
+ );
512
+ };
513
+
514
+ const Page = async ({ params }) => {
515
+ const { locale } = await params;
516
+
517
+ return (
518
+ <IntlayerServerProvider locale={locale}>
519
+ <PageContent />
520
+ <ServerComponentExample />
521
+
522
+ <IntlayerClientProvider locale={locale}>
523
+ <ClientComponentExample />
524
+ </IntlayerClientProvider>
525
+ </IntlayerServerProvider>
526
+ );
527
+ };
528
+ ```
529
+
530
+ - **`IntlayerClientProvider`** क्लाइंट-साइड कंपोनेंट्स को लोकल प्रदान करने के लिए उपयोग किया जाता है। इसे किसी भी पैरेंट कंपोनेंट में रखा जा सकता है, जिसमें लेआउट भी शामिल है। हालांकि, इसे लेआउट में रखना अनुशंसित है क्योंकि Next.js पेजों के बीच लेआउट कोड साझा करता है, जिससे यह अधिक कुशल हो जाता है। लेआउट में `IntlayerClientProvider` का उपयोग करके, आप हर पेज के लिए इसे पुनः आरंभ करने से बचते हैं, प्रदर्शन में सुधार करते हैं और आपके एप्लिकेशन में एक सुसंगत स्थानीयकरण संदर्भ बनाए रखते हैं।
531
+ - **`IntlayerServerProvider`** सर्वर चाइल्ड्स को लोकल प्रदान करने के लिए उपयोग किया जाता है। इसे लेआउट में सेट नहीं किया जा सकता।
532
+
533
+ > लेआउट और पेज एक सामान्य सर्वर संदर्भ साझा नहीं कर सकते क्योंकि सर्वर संदर्भ प्रणाली प्रति अनुरोध डेटा स्टोर (React के कैश [React's cache](https://react.dev/reference/react/cache) मैकेनिज्म के माध्यम से) पर आधारित है, जिससे एप्लिकेशन के विभिन्न सेगमेंट के लिए प्रत्येक "संदर्भ" पुनः बनाया जाता है। प्रदाता को साझा लेआउट में रखना इस पृथक्करण को तोड़ देगा, जिससे आपके सर्वर कंपोनेंट्स को सर्वर संदर्भ मानों का सही प्रसार नहीं हो पाएगा।
534
+
535
+ > लेआउट और पेज एक सामान्य सर्वर संदर्भ साझा नहीं कर सकते क्योंकि सर्वर संदर्भ प्रणाली प्रति अनुरोध डेटा स्टोर (React के कैश [React's cache](https://react.dev/reference/react/cache) तंत्र के माध्यम से) पर आधारित है, जिससे एप्लिकेशन के विभिन्न खंडों के लिए प्रत्येक "संदर्भ" पुनः बनाया जाता है। प्रदाता को साझा लेआउट में रखना इस पृथक्करण को तोड़ देगा, जिससे आपके सर्वर घटकों को सर्वर संदर्भ मानों का सही प्रसार नहीं हो पाएगा।
536
+
537
+ ```tsx {4,7} fileName="src/components/ClientComponentExample.tsx" codeFormat="typescript"
538
+ "use client";
539
+
540
+ import type { FC } from "react";
541
+ import { useIntlayer } from "next-intlayer";
542
+
543
+ export const ClientComponentExample: FC = () => {
544
+ const content = useIntlayer("client-component-example"); // संबंधित सामग्री घोषणा बनाएँ
545
+
546
+ return (
547
+ <div>
548
+ <h2>{content.title}</h2>
549
+ <p>{content.content}</p>
550
+ </div>
551
+ );
552
+ };
553
+ ```
554
+
555
+ ```jsx {3,6} fileName="src/components/ClientComponentExample.mjx" codeFormat="esm"
556
+ "use client";
557
+
558
+ import { useIntlayer } from "next-intlayer";
559
+
560
+ const ClientComponentExample = () => {
561
+ const content = useIntlayer("client-component-example"); // संबंधित सामग्री घोषणा बनाएँ
562
+
563
+ return (
564
+ <div>
565
+ <h2>{content.title}</h2>
566
+ <p>{content.content}</p>
567
+ </div>
568
+ );
569
+ };
570
+ ```
571
+
572
+ ```jsx {3,6} fileName="src/components/ClientComponentExample.csx" codeFormat="commonjs"
573
+ "use client";
574
+
575
+ const { useIntlayer } = require("next-intlayer");
576
+
577
+ const ClientComponentExample = () => {
578
+ const content = useIntlayer("client-component-example"); // संबंधित सामग्री घोषणा बनाएँ
579
+
580
+ return (
581
+ <div>
582
+ <h2>{content.title}</h2>
583
+ <p>{content.content}</p>
584
+ </div>
585
+ );
586
+ };
587
+ ```
588
+
589
+ ```tsx {2} fileName="src/components/ServerComponentExample.tsx" codeFormat="typescript"
590
+ import type { FC } from "react";
591
+ import { useIntlayer } from "next-intlayer/server";
592
+
593
+ export const ServerComponentExample: FC = () => {
594
+ const content = useIntlayer("server-component-example"); // संबंधित सामग्री घोषणा बनाएँ
595
+
596
+ return (
597
+ <div>
598
+ <h2>{content.title}</h2>
599
+ <p>{content.content}</p>
600
+ </div>
601
+ );
602
+ };
603
+ ```
604
+
605
+ ```jsx {1} fileName="src/components/ServerComponentExample.mjx" codeFormat="esm"
606
+ import { useIntlayer } from "next-intlayer/server";
607
+
608
+ const ServerComponentExample = () => {
609
+ const content = useIntlayer("server-component-example"); // संबंधित सामग्री घोषणा बनाएँ
610
+
611
+ return (
612
+ <div>
613
+ <h2>{content.title}</h2>
614
+ <p>{content.content}</p>
615
+ </div>
616
+ );
617
+ };
618
+ ```
619
+
620
+ ```jsx {1} fileName="src/components/ServerComponentExample.csx" codeFormat="commonjs"
621
+ const { useIntlayer } = require("next-intlayer/server");
622
+
623
+ const ServerComponentExample = () => {
624
+ const content = useIntlayer("server-component-example"); // संबंधित सामग्री घोषणा बनाएँ
625
+
626
+ return (
627
+ <div>
628
+ <h2>{content.title}</h2>
629
+ <p>{content.content}</p>
630
+ </div>
631
+ );
632
+ };
633
+ ```
634
+
635
+ > यदि आप अपनी सामग्री को किसी `string` एट्रिब्यूट में उपयोग करना चाहते हैं, जैसे कि `alt`, `title`, `href`, `aria-label`, आदि, तो आपको फ़ंक्शन के मान को कॉल करना होगा, जैसे:
636
+
637
+ > ```jsx
638
+ > <img src={content.image.src.value} alt={content.image.value} />
639
+ > ```
640
+
641
+ > `useIntlayer` हुक के बारे में अधिक जानने के लिए, [डॉक्यूमेंटेशन](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/next-intlayer/useIntlayer.md) देखें।
642
+
643
+ ### (वैकल्पिक) चरण 7: लोकल डिटेक्शन के लिए प्रॉक्सी कॉन्फ़िगर करें
644
+
645
+ उपयोगकर्ता की पसंदीदा लोकल का पता लगाने के लिए प्रॉक्सी सेट करें:
646
+
647
+ ```typescript fileName="src/proxy.ts" codeFormat="typescript"
648
+ export { intlayerProxy as proxy } from "next-intlayer/proxy";
649
+
650
+ export const config = {
651
+ matcher:
652
+ "/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
653
+ };
654
+ ```
655
+
656
+ ```javascript fileName="src/proxy.mjs" codeFormat="esm"
657
+ export { intlayerProxy as proxy } from "next-intlayer/proxy";
658
+
659
+ export const config = {
660
+ matcher:
661
+ "/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
662
+ };
663
+ ```
664
+
665
+ ```javascript fileName="src/proxy.cjs" codeFormat="commonjs"
666
+ const { intlayerProxy } = require("next-intlayer/proxy");
667
+
668
+ const config = {
669
+ matcher:
670
+ "/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
671
+ };
672
+
673
+ module.exports = { proxy: intlayerProxy, config };
674
+ ```
675
+
676
+ > `intlayerProxy` का उपयोग उपयोगकर्ता की पसंदीदा भाषा का पता लगाने और उन्हें उपयुक्त URL पर पुनर्निर्देशित करने के लिए किया जाता है जैसा कि [कॉन्फ़िगरेशन](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/configuration.md) में निर्दिष्ट है। इसके अतिरिक्त, यह उपयोगकर्ता की पसंदीदा भाषा को कुकी में सहेजने की सुविधा भी प्रदान करता है।
677
+
678
+ > यदि आपको कई प्रॉक्सी को एक साथ जोड़ने की आवश्यकता है (उदाहरण के लिए, प्रमाणीकरण या कस्टम प्रॉक्सी के साथ `intlayerProxy`), तो Intlayer अब `multipleProxies` नामक एक सहायक प्रदान करता है।
679
+
680
+ ```ts
681
+ import { multipleProxies, intlayerProxy } from "next-intlayer/proxy";
682
+ import { customProxy } from "@utils/customProxy";
683
+
684
+ export const proxy = multipleProxies([intlayerProxy, customProxy]);
685
+ ```
686
+
687
+ ### (वैकल्पिक) चरण 8: अपने मेटाडेटा का अंतरराष्ट्रीयकरण
688
+
689
+ यदि आप अपने मेटाडेटा का अंतरराष्ट्रीयकरण करना चाहते हैं, जैसे कि आपके पृष्ठ का शीर्षक, तो आप Next.js द्वारा प्रदान की गई `generateMetadata` फ़ंक्शन का उपयोग कर सकते हैं। इसके अंदर, आप अपने मेटाडेटा का अनुवाद करने के लिए `getIntlayer` फ़ंक्शन से सामग्री प्राप्त कर सकते हैं।
690
+
691
+ ```typescript fileName="src/app/[locale]/metadata.content.ts" contentDeclarationFormat="typescript"
692
+ import { type Dictionary, t } from "intlayer";
693
+ import { Metadata } from "next";
694
+
695
+ const metadataContent = {
696
+ key: "page-metadata",
697
+ content: {
698
+ title: t({
699
+ en: "Create Next App",
700
+ fr: "Créer une application Next.js",
701
+ es: "Crear una aplicación Next.js",
702
+ }),
703
+ description: t({
704
+ en: "Generated by create next app",
705
+ fr: "Généré par create next app",
706
+ es: "Generado por create next app",
707
+ }),
708
+ },
709
+ } satisfies Dictionary<Metadata>;
710
+
711
+ export default metadataContent;
712
+ ```
713
+
714
+ ```javascript fileName="src/app/[locale]/metadata.content.mjs" contentDeclarationFormat="esm"
715
+ import { t } from "intlayer";
716
+
717
+ /** @type {import('intlayer').Dictionary<import('next').Metadata>} */
718
+ const metadataContent = {
719
+ key: "page-metadata",
720
+ content: {
721
+ title: t({
722
+ en: "Create Next App",
723
+ fr: "Créer une application Next.js",
724
+ es: "Crear una aplicación Next.js",
725
+ }),
726
+ description: t({
727
+ en: "Generated by create next app",
728
+ fr: "Généré par create next app",
729
+ es: "Generado por create next app",
730
+ }),
731
+ },
732
+ };
733
+
734
+ export default metadataContent;
735
+ ```
736
+
737
+ ```javascript fileName="src/app/[locale]/metadata.content.cjs" contentDeclarationFormat="commonjs"
738
+ const { t } = require("intlayer");
739
+
740
+ /** @type {import('intlayer').Dictionary<import('next').Metadata>} */
741
+ const metadataContent = {
742
+ key: "page-metadata",
743
+ content: {
744
+ title: t({
745
+ en: "Create Next App",
746
+ fr: "Créer une application Next.js",
747
+ es: "Crear una aplicación Next.js",
748
+ }),
749
+ description: t({
750
+ en: "Generated by create next app",
751
+ fr: "Généré par create next app",
752
+ es: "Generado por create next app",
753
+ }),
754
+ },
755
+ };
756
+
757
+ module.exports = metadataContent;
758
+ ```
759
+
760
+ ```javascript fileName="src/app/[locale]/metadata.content.cjs" contentDeclarationFormat="commonjs"
761
+ const { t } = require("intlayer");
762
+
763
+ /** @type {import('intlayer').Dictionary<import('next').Metadata>} */
764
+ const metadataContent = {
765
+ key: "page-metadata",
766
+ content: {
767
+ title: t({
768
+ en: "Create Next App",
769
+ fr: "Créer une application Next.js",
770
+ es: "Crear una aplicación Next.js",
771
+ }),
772
+ description: t({
773
+ en: "Generated by create next app",
774
+ fr: "Généré par create next app",
775
+ es: "Generado por create next app",
776
+ }),
777
+ },
778
+ };
779
+
780
+ module.exports = metadataContent;
781
+ ```
782
+
783
+ ```json fileName="src/app/[locale]/metadata.content.json" contentDeclarationFormat="json"
784
+ {
785
+ "key": "page-metadata",
786
+ "content": {
787
+ "title": {
788
+ "nodeType": "translation",
789
+ "translation": {
790
+ "hi": "प्रिएक्ट लोगो",
791
+ "en": "Preact logo",
792
+ "fr": "Logo Preact",
793
+ "es": "Logo Preact"
794
+ }
795
+ },
796
+ "description": {
797
+ "nodeType": "translation",
798
+ "translation": {
799
+ "hi": "क्रिएट नेक्स्ट ऐप द्वारा उत्पन्न",
800
+ "en": "Generated by create next app",
801
+ "fr": "Généré par create next app",
802
+ "es": "Generado por create next app"
803
+ }
804
+ }
805
+ }
806
+ }
807
+ ```
808
+
809
+ ````typescript fileName="src/app/[locale]/layout.tsx or src/app/[locale]/page.tsx" codeFormat="typescript"
810
+ import { getIntlayer, getMultilingualUrls } from "intlayer";
811
+ import type { Metadata } from "next";
812
+ import type { LocalPromiseParams } from "next-intlayer";
813
+
814
+ export const generateMetadata = async ({
815
+ params,
816
+ }: LocalPromiseParams): Promise<Metadata> => {
817
+ const { locale } = await params;
818
+
819
+ const metadata = getIntlayer("page-metadata", locale);
820
+
821
+ /**
822
+ * प्रत्येक लोकल के लिए सभी URL वाले ऑब्जेक्ट को जनरेट करता है।
823
+ *
824
+ * उदाहरण:
825
+ * ```ts
826
+ * getMultilingualUrls('/about');
827
+ *
828
+ * // रिटर्न करता है
829
+ * // {
830
+ * // en: '/about',
831
+ * // fr: '/fr/about',
832
+ * // es: '/es/about',
833
+ * // }
834
+ * ```
835
+ */
836
+ const multilingualUrls = getMultilingualUrls("/");
837
+
838
+ return {
839
+ ...metadata,
840
+ alternates: {
841
+ canonical: multilingualUrls[locale as keyof typeof multilingualUrls],
842
+ languages: { ...multilingualUrls, "x-default": "/" },
843
+ },
844
+ openGraph: {
845
+ url: multilingualUrls[locale],
846
+ },
847
+ };
848
+ };
849
+
850
+ // ... बाकी कोड
851
+ ````
852
+
853
+ ````javascript fileName="src/app/[locale]/layout.mjs or src/app/[locale]/page.mjs" codeFormat="esm"
854
+ import { getIntlayer, getMultilingualUrls } from "intlayer";
855
+
856
+ export const generateMetadata = async ({ params }) => {
857
+ const { locale } = await params;
858
+
859
+ const metadata = getIntlayer("page-metadata", locale);
860
+
861
+ /**
862
+ * प्रत्येक भाषा के लिए सभी URL वाले ऑब्जेक्ट को जनरेट करता है।
863
+ *
864
+ * उदाहरण:
865
+ * ```ts
866
+ * getMultilingualUrls('/about');
867
+ *
868
+ * // रिटर्न करता है
869
+ * // {
870
+ * // en: '/about',
871
+ * // fr: '/fr/about',
872
+ * // es: '/es/about'
873
+ * // }
874
+ * ```
875
+ */
876
+ const multilingualUrls = getMultilingualUrls("/");
877
+
878
+ return {
879
+ ...metadata,
880
+ alternates: {
881
+ canonical: multilingualUrls[locale],
882
+ languages: { ...multilingualUrls, "x-default": "/" },
883
+ },
884
+ openGraph: {
885
+ url: multilingualUrls[locale],
886
+ },
887
+ };
888
+ };
889
+
890
+ // ... बाकी कोड
891
+ ````
892
+
893
+ ````javascript fileName="src/app/[locale]/layout.cjs or src/app/[locale]/page.cjs" codeFormat="commonjs"
894
+ const { getIntlayer, getMultilingualUrls } = require("intlayer");
895
+
896
+ const generateMetadata = async ({ params }) => {
897
+ const { locale } = await params;
898
+
899
+ const metadata = getIntlayer("page-metadata", locale);
900
+
901
+ /**
902
+ * प्रत्येक भाषा के लिए सभी URL वाला ऑब्जेक्ट बनाता है।
903
+ *
904
+ * उदाहरण:
905
+ * ```ts
906
+ * getMultilingualUrls('/about');
907
+ *
908
+ * // लौटाता है
909
+ * // {
910
+ * // en: '/about',
911
+ * // fr: '/fr/about',
912
+ * // es: '/es/about'
913
+ * // }
914
+ * ```
915
+ */
916
+ const multilingualUrls = getMultilingualUrls("/");
917
+
918
+ return {
919
+ ...metadata,
920
+ alternates: {
921
+ canonical: multilingualUrls[locale],
922
+ languages: { ...multilingualUrls, "x-default": "/" },
923
+ },
924
+ openGraph: {
925
+ url: multilingualUrls[locale],
926
+ },
927
+ };
928
+ };
929
+
930
+ module.exports = { generateMetadata };
931
+
932
+ // ... बाकी कोड
933
+ ````
934
+
935
+ > ध्यान दें कि `next-intlayer` से आयातित `getIntlayer` फ़ंक्शन आपकी सामग्री को `IntlayerNode` में लपेट कर लौटाता है, जो विज़ुअल एडिटर के साथ एकीकरण की अनुमति देता है। इसके विपरीत, `intlayer` से आयातित `getIntlayer` फ़ंक्शन आपकी सामग्री को सीधे बिना अतिरिक्त गुणों के लौटाता है।
936
+
937
+ वैकल्पिक रूप से, आप अपने मेटाडेटा को घोषित करने के लिए `getTranslation` फ़ंक्शन का उपयोग कर सकते हैं। हालांकि, मेटाडेटा के अनुवाद को स्वचालित करने और किसी बिंदु पर सामग्री को बाहरी बनाने के लिए कंटेंट घोषणा फ़ाइलों का उपयोग करने की सिफारिश की जाती है।
938
+
939
+ ```typescript fileName="src/app/[locale]/layout.tsx or src/app/[locale]/page.tsx" codeFormat="typescript"
940
+ import {
941
+ type IConfigLocales,
942
+ getTranslation,
943
+ getMultilingualUrls,
944
+ } from "intlayer";
945
+ import type { Metadata } from "next";
946
+ import type { LocalPromiseParams } from "next-intlayer";
947
+
948
+ export const generateMetadata = async ({
949
+ params,
950
+ }: LocalPromiseParams): Promise<Metadata> => {
951
+ const { locale } = await params;
952
+ const t = <T>(content: IConfigLocales<T>) => getTranslation(content, locale);
953
+
954
+ return {
955
+ title: t<string>({
956
+ en: "My title",
957
+ fr: "Mon titre",
958
+ es: "Mi título",
959
+ }),
960
+ description: t({
961
+ en: "मेरा विवरण",
962
+ fr: "Ma description",
963
+ es: "Mi descripción",
964
+ }),
965
+ };
966
+ };
967
+
968
+ // ... कोड का बाकी हिस्सा
969
+ ```
970
+
971
+ ```javascript fileName="src/app/[locale]/layout.mjs or src/app/[locale]/page.mjs" codeFormat="esm"
972
+ import { getTranslation, getMultilingualUrls } from "intlayer";
973
+
974
+ export const generateMetadata = async ({ params }) => {
975
+ const { locale } = await params;
976
+ const t = (content) => getTranslation(content, locale);
977
+
978
+ return {
979
+ title: t({
980
+ en: "मेरा शीर्षक",
981
+ fr: "Mon titre",
982
+ es: "Mi título",
983
+ }),
984
+ description: t({
985
+ en: "मेरा विवरण",
986
+ fr: "Ma description",
987
+ es: "Mi descripción",
988
+ }),
989
+ };
990
+ };
991
+
992
+ // ... कोड का बाकी हिस्सा
993
+ ```
994
+
995
+ ```javascript fileName="src/app/[locale]/layout.cjs or src/app/[locale]/page.cjs" codeFormat="commonjs"
996
+ const { getTranslation, getMultilingualUrls } = require("intlayer");
997
+
998
+ const generateMetadata = async ({ params }) => {
999
+ const { locale } = await params;
1000
+
1001
+ const t = (content) => getTranslation(content, locale);
1002
+
1003
+ return {
1004
+ title: t({
1005
+ en: "My title",
1006
+ fr: "Mon titre",
1007
+ es: "Mi título",
1008
+ }),
1009
+ description: t({
1010
+ en: "My description",
1011
+ fr: "Ma description",
1012
+ es: "Mi descripción",
1013
+ }),
1014
+ };
1015
+ };
1016
+
1017
+ module.exports = { generateMetadata };
1018
+
1019
+ // ... बाकी कोड
1020
+ ```
1021
+
1022
+ > आधिकारिक Next.js दस्तावेज़ में मेटाडेटा अनुकूलन के बारे में अधिक जानें [यहाँ](https://nextjs.org/docs/app/building-your-application/optimizing/metadata)।
1023
+
1024
+ ### (वैकल्पिक) चरण 9: अपने sitemap.xml और robots.txt का अंतरराष्ट्रीयकरण
1025
+
1026
+ अपने `sitemap.xml` और `robots.txt` का अंतरराष्ट्रीयकरण करने के लिए, आप Intlayer द्वारा प्रदान की गई `getMultilingualUrls` फ़ंक्शन का उपयोग कर सकते हैं। यह फ़ंक्शन आपको अपने साइटमैप के लिए बहुभाषी URL उत्पन्न करने की अनुमति देता है।
1027
+
1028
+ ```tsx fileName="src/app/sitemap.ts" codeFormat="typescript"
1029
+ import { getMultilingualUrls } from "intlayer";
1030
+ import type { MetadataRoute } from "next";
1031
+
1032
+ const sitemap = (): MetadataRoute.Sitemap => [
1033
+ {
1034
+ url: "https://example.com",
1035
+ alternates: {
1036
+ languages: { ...getMultilingualUrls("https://example.com") },
1037
+ },
1038
+ },
1039
+ {
1040
+ url: "https://example.com/login",
1041
+ alternates: {
1042
+ languages: { ...getMultilingualUrls("https://example.com/login") },
1043
+ },
1044
+ },
1045
+ {
1046
+ url: "https://example.com/register",
1047
+ alternates: {
1048
+ languages: { ...getMultilingualUrls("https://example.com/register") },
1049
+ },
1050
+ },
1051
+ ];
1052
+
1053
+ export default sitemap;
1054
+ ```
1055
+
1056
+ ```jsx fileName="src/app/sitemap.mjx" codeFormat="esm"
1057
+ import { getMultilingualUrls } from "intlayer";
1058
+
1059
+ const sitemap = () => [
1060
+ {
1061
+ url: "https://example.com",
1062
+ alternates: {
1063
+ languages: { ...getMultilingualUrls("https://example.com") },
1064
+ },
1065
+ },
1066
+ {
1067
+ url: "https://example.com/login",
1068
+ alternates: {
1069
+ languages: { ...getMultilingualUrls("https://example.com/login") },
1070
+ },
1071
+ },
1072
+ {
1073
+ url: "https://example.com/register",
1074
+ alternates: {
1075
+ languages: { ...getMultilingualUrls("https://example.com/register") },
1076
+ },
1077
+ },
1078
+ ];
1079
+
1080
+ export default sitemap;
1081
+ ```
1082
+
1083
+ ```jsx fileName="src/app/sitemap.csx" codeFormat="commonjs"
1084
+ const { getMultilingualUrls } = require("intlayer");
1085
+
1086
+ // साइटमैप को परिभाषित करता है जिसमें विभिन्न URL और उनकी बहुभाषी वैकल्पिक लिंक शामिल हैं
1087
+ const sitemap = () => [
1088
+ {
1089
+ url: "https://example.com",
1090
+ alternates: {
1091
+ languages: { ...getMultilingualUrls("https://example.com") },
1092
+ },
1093
+ },
1094
+ {
1095
+ url: "https://example.com/login",
1096
+ alternates: {
1097
+ languages: { ...getMultilingualUrls("https://example.com/login") },
1098
+ },
1099
+ },
1100
+ {
1101
+ url: "https://example.com/register",
1102
+ alternates: {
1103
+ languages: { ...getMultilingualUrls("https://example.com/register") },
1104
+ },
1105
+ },
1106
+ ];
1107
+
1108
+ module.exports = sitemap;
1109
+ ```
1110
+
1111
+ ```tsx fileName="src/app/robots.ts" codeFormat="typescript"
1112
+ import type { MetadataRoute } from "next";
1113
+ import { getMultilingualUrls } from "intlayer";
1114
+
1115
+ const getAllMultilingualUrls = (urls: string[]) =>
1116
+ urls.flatMap((url) => Object.values(getMultilingualUrls(url)) as string[]);
1117
+
1118
+ // सभी बहुभाषी URL प्राप्त करें
1119
+ const robots = (): MetadataRoute.Robots => ({
1120
+ rules: {
1121
+ userAgent: "*", // सभी यूजर एजेंट के लिए नियम
1122
+ allow: ["/"], // अनुमति प्राप्त पथ
1123
+ disallow: getAllMultilingualUrls(["/login", "/register"]), // निषिद्ध पथ
1124
+ },
1125
+ host: "https://example.com", // होस्ट URL
1126
+ sitemap: `https://example.com/sitemap.xml`, // साइटमैप URL
1127
+ });
1128
+
1129
+ export default robots;
1130
+ ```
1131
+
1132
+ ```jsx fileName="src/app/robots.mjx" codeFormat="esm"
1133
+ import { getMultilingualUrls } from "intlayer";
1134
+
1135
+ // सभी बहुभाषी URL प्राप्त करें
1136
+ const getAllMultilingualUrls = (urls) =>
1137
+ urls.flatMap((url) => Object.values(getMultilingualUrls(url)));
1138
+
1139
+ const robots = () => ({
1140
+ rules: {
1141
+ userAgent: "*", // सभी यूजर एजेंट के लिए नियम
1142
+ allow: ["/"], // अनुमति प्राप्त पथ
1143
+ disallow: getAllMultilingualUrls(["/login", "/register"]), // निषिद्ध पथ
1144
+ },
1145
+ host: "https://example.com", // होस्ट URL
1146
+ sitemap: `https://example.com/sitemap.xml`,
1147
+ });
1148
+
1149
+ export default robots;
1150
+ ```
1151
+
1152
+ ```jsx fileName="src/app/robots.csx" codeFormat="commonjs"
1153
+ const { getMultilingualUrls } = require("intlayer");
1154
+
1155
+ // सभी बहुभाषी URLs प्राप्त करें
1156
+ const getAllMultilingualUrls = (urls) =>
1157
+ urls.flatMap((url) => Object.values(getMultilingualUrls(url)));
1158
+
1159
+ const robots = () => ({
1160
+ rules: {
1161
+ userAgent: "*",
1162
+ allow: ["/"],
1163
+ disallow: getAllMultilingualUrls(["/login", "/register"]), // लॉगिन और रजिस्टर पेज को रोबोट्स से ब्लॉक करें
1164
+ },
1165
+ host: "https://example.com",
1166
+ sitemap: `https://example.com/sitemap.xml`,
1167
+ });
1168
+
1169
+ module.exports = robots;
1170
+ ```
1171
+
1172
+ > आधिकारिक Next.js दस्तावेज़ीकरण में साइटमैप अनुकूलन के बारे में अधिक जानें [यहाँ](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap)। आधिकारिक Next.js दस्तावेज़ीकरण में robots.txt अनुकूलन के बारे में अधिक जानें [यहाँ](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/robots)।
1173
+
1174
+ ### (वैकल्पिक) चरण 10: अपनी सामग्री की भाषा बदलें
1175
+
1176
+ Next.js में अपनी सामग्री की भाषा बदलने के लिए, अनुशंसित तरीका है कि उपयोगकर्ताओं को उपयुक्त स्थानीयकृत पृष्ठ पर पुनः निर्देशित करने के लिए `Link` घटक का उपयोग करें। `Link` घटक पृष्ठ की प्रीफ़ेचिंग सक्षम करता है, जो पूर्ण पृष्ठ पुनः लोड से बचने में मदद करता है।
1177
+
1178
+ ```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
1179
+ "use client";
1180
+
1181
+ import type { FC } from "react";
1182
+ import {
1183
+ Locales,
1184
+ getHTMLTextDir,
1185
+ getLocaleName,
1186
+ getLocalizedUrl,
1187
+ } from "intlayer";
1188
+ import { useLocale } from "next-intlayer";
1189
+ import Link from "next/link";
1190
+
1191
+ export const LocaleSwitcher: FC = () => {
1192
+ const { locale, pathWithoutLocale, availableLocales, setLocale } =
1193
+ useLocale();
1194
+
1195
+ return (
1196
+ <div>
1197
+ <button popoverTarget="localePopover">{getLocaleName(locale)}</button>
1198
+ <div id="localePopover" popover="auto">
1199
+ {availableLocales.map((localeItem) => (
1200
+ <Link
1201
+ href={getLocalizedUrl(pathWithoutLocale, localeItem)}
1202
+ key={localeItem}
1203
+ aria-current={locale === localeItem ? "page" : undefined}
1204
+ onClick={() => setLocale(localeItem)}
1205
+ replace // यह सुनिश्चित करेगा कि "वापस जाएं" ब्राउज़र बटन पिछले पृष्ठ पर पुनः निर्देशित होगा
1206
+ >
1207
+ <span>
1208
+ {/* लोकल - उदाहरण के लिए FR */}
1209
+ {localeItem}
1210
+ </span>
1211
+ <span>
1212
+ {/* अपनी लोकल में भाषा - उदाहरण के लिए Français */}
1213
+ {getLocaleName(localeItem, locale)}
1214
+ </span>
1215
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
1216
+ {/* वर्तमान लोकल में भाषा - उदाहरण के लिए Francés जब वर्तमान लोकल Locales.SPANISH पर सेट हो */}
1217
+ {getLocaleName(localeItem)}
1218
+ </span>
1219
+ <span dir="ltr" lang={Locales.ENGLISH}>
1220
+ {/* अंग्रेज़ी में भाषा - उदाहरण के लिए French */}
1221
+ {getLocaleName(localeItem, Locales.ENGLISH)}
1222
+ </span>
1223
+ </Link>
1224
+ ))}
1225
+ </div>
1226
+ </div>
1227
+ );
1228
+ };
1229
+ ```
1230
+
1231
+ ```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
1232
+ "use client";
1233
+
1234
+ import {
1235
+ Locales,
1236
+ getHTMLTextDir,
1237
+ getLocaleName,
1238
+ getLocalizedUrl,
1239
+ } from "intlayer";
1240
+ import { useLocale } from "next-intlayer";
1241
+ import Link from "next/link";
1242
+
1243
+ export const LocaleSwitcher = () => {
1244
+ const { locale, pathWithoutLocale, availableLocales, setLocale } =
1245
+ useLocale();
1246
+
1247
+ return (
1248
+ <div>
1249
+ <button popoverTarget="localePopover">{getLocaleName(locale)}</button>
1250
+ <div id="localePopover" popover="auto">
1251
+ {availableLocales.map((localeItem) => (
1252
+ <Link
1253
+ href={getLocalizedUrl(pathWithoutLocale, localeItem)}
1254
+ key={localeItem}
1255
+ aria-current={locale === localeItem ? "page" : undefined}
1256
+ onClick={() => setLocale(localeItem)}
1257
+ replace // यह सुनिश्चित करेगा कि "वापस जाएं" ब्राउज़र बटन पिछले पृष्ठ पर पुनः निर्देशित होगा
1258
+ >
1259
+ <span>
1260
+ {/* लोकल - उदाहरण के लिए FR */}
1261
+ {localeItem}
1262
+ </span>
1263
+ <span>
1264
+ {/* अपनी लोकल में भाषा - उदाहरण के लिए Français */}
1265
+ {getLocaleName(localeItem, locale)}
1266
+ </span>
1267
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
1268
+ {/* वर्तमान लोकल में भाषा - उदाहरण के लिए Francés, जब वर्तमान लोकल Locales.SPANISH सेट हो */}
1269
+ {getLocaleName(localeItem)}
1270
+ </span>
1271
+ <span dir="ltr" lang={Locales.ENGLISH}>
1272
+ {/* अंग्रेज़ी में भाषा - उदाहरण के लिए French */}
1273
+ {getLocaleName(localeItem, Locales.ENGLISH)}
1274
+ </span>
1275
+ </Link>
1276
+ ))}
1277
+ </div>
1278
+ </div>
1279
+ );
1280
+ };
1281
+ ```
1282
+
1283
+ ```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
1284
+ "use client";
1285
+
1286
+ const {
1287
+ Locales,
1288
+ getHTMLTextDir,
1289
+ getLocaleName,
1290
+ getLocalizedUrl,
1291
+ } = require("intlayer");
1292
+ const { useLocale } = require("next-intlayer");
1293
+ const Link = require("next/link");
1294
+
1295
+ export const LocaleSwitcher = () => {
1296
+ const { locale, pathWithoutLocale, availableLocales, setLocale } =
1297
+ useLocale();
1298
+
1299
+ return (
1300
+ <div>
1301
+ <button popoverTarget="localePopover">{getLocaleName(locale)}</button>
1302
+ <div id="localePopover" popover="auto">
1303
+ {availableLocales.map((localeItem) => (
1304
+ <Link
1305
+ href={getLocalizedUrl(pathWithoutLocale, localeItem)}
1306
+ key={localeItem}
1307
+ aria-current={locale === localeItem ? "page" : undefined}
1308
+ onClick={() => setLocale(localeItem)}
1309
+ replace // यह सुनिश्चित करेगा कि "वापस जाएं" ब्राउज़र बटन पिछले पृष्ठ पर पुनः निर्देशित हो
1310
+ >
1311
+ <span>
1312
+ {/* लोकल - उदाहरण के लिए FR */}
1313
+ {localeItem}
1314
+ </span>
1315
+ <span>
1316
+ {/* अपनी लोकल में भाषा - उदाहरण के लिए Français */}
1317
+ {getLocaleName(localeItem, locale)}
1318
+ </span>
1319
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
1320
+ {/* वर्तमान लोकल में भाषा - उदाहरण के लिए Francés, जब वर्तमान लोकल Locales.SPANISH सेट हो */}
1321
+ {getLocaleName(localeItem)}
1322
+ </span>
1323
+ <span dir="ltr" lang={Locales.ENGLISH}>
1324
+ {/* अंग्रेज़ी में भाषा - उदाहरण के लिए French */}
1325
+ {getLocaleName(localeItem, Locales.ENGLISH)}
1326
+ </span>
1327
+ </Link>
1328
+ ))}
1329
+ </div>
1330
+ </div>
1331
+ );
1332
+ };
1333
+ ```
1334
+
1335
+ > एक वैकल्पिक तरीका है `useLocale` हुक द्वारा प्रदान किया गया `setLocale` फ़ंक्शन उपयोग करना। यह फ़ंक्शन पेज को प्रीफ़ेच करने की अनुमति नहीं देगा। अधिक जानकारी के लिए [`useLocale` हुक दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/next-intlayer/useLocale.md) देखें।
1336
+
1337
+ > आप `onLocaleChange` विकल्प में एक फ़ंक्शन भी सेट कर सकते हैं ताकि जब लोकल बदलें तो एक कस्टम फ़ंक्शन ट्रिगर हो।
1338
+
1339
+ ```tsx fileName="src/components/LocaleSwitcher.tsx"
1340
+ "use client";
1341
+
1342
+ import { useRouter } from "next/navigation";
1343
+ import { useLocale } from "next-intlayer";
1344
+ import { getLocalizedUrl } from "intlayer";
1345
+
1346
+ // ... कोड का बाकी हिस्सा
1347
+
1348
+ const router = useRouter();
1349
+ const { setLocale } = useLocale({
1350
+ onLocaleChange: (locale) => {
1351
+ router.push(getLocalizedUrl(pathWithoutLocale, locale));
1352
+ },
1353
+ });
1354
+
1355
+ return (
1356
+ <button onClick={() => setLocale(Locales.FRENCH)}>फ्रेंच में बदलें</button>
1357
+ );
1358
+ ```
1359
+
1360
+ > दस्तावेज़ संदर्भ:
1361
+ >
1362
+ > - [`useLocale` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/next-intlayer/useLocale.md)
1363
+ > - [`getLocaleName` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getLocaleName.md)
1364
+ > - [`getLocalizedUrl` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getLocalizedUrl.md)
1365
+ > - [`getHTMLTextDir` हुक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/intlayer/getHTMLTextDir.md)
1366
+ > - [`hrefLang` एट्रिब्यूट](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
1367
+ > - [`lang` एट्रिब्यूट](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
1368
+ > - [`dir` एट्रिब्यूट](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
1369
+ > - [`aria-current` एट्रिब्यूट](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
1370
+
1371
+ ### (वैकल्पिक) चरण 11: एक स्थानीयकृत लिंक कॉम्पोनेंट बनाना
1372
+
1373
+ अपने एप्लिकेशन की नेविगेशन को वर्तमान लोकल का सम्मान करने के लिए, आप एक कस्टम `Link` कॉम्पोनेंट बना सकते हैं। यह कॉम्पोनेंट आंतरिक URL को स्वचालित रूप से वर्तमान भाषा के साथ पूर्वसर्ग करता है। उदाहरण के लिए, जब एक फ्रेंच बोलने वाला उपयोगकर्ता "About" पेज के लिंक पर क्लिक करता है, तो उसे `/about` के बजाय `/fr/about` पर पुनः निर्देशित किया जाता है।
1374
+
1375
+ यह व्यवहार कई कारणों से उपयोगी है:
1376
+
1377
+ - **SEO और उपयोगकर्ता अनुभव**: स्थानीयकृत URL खोज इंजन को भाषा-विशिष्ट पृष्ठों को सही ढंग से अनुक्रमित करने में मदद करते हैं और उपयोगकर्ताओं को उनकी पसंदीदा भाषा में सामग्री प्रदान करते हैं।
1378
+ - **संगति**: अपने एप्लिकेशन में स्थानीयकृत लिंक का उपयोग करके, आप सुनिश्चित करते हैं कि नेविगेशन वर्तमान लोकल के भीतर ही रहता है, जिससे अप्रत्याशित भाषा परिवर्तन से बचा जा सके।
1379
+ - **रखरखाव क्षमता**: स्थानीयकरण लॉजिक को एक ही कंपोनेंट में केंद्रीकृत करने से URL प्रबंधन सरल हो जाता है, जिससे आपका कोडबेस बनाए रखना और बढ़ाना आसान हो जाता है क्योंकि आपका एप्लिकेशन बढ़ता है।
1380
+
1381
+ नीचे TypeScript में एक स्थानीयकृत `Link` कंपोनेंट का कार्यान्वयन दिया गया है:
1382
+
1383
+ ```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
1384
+ "use client";
1385
+
1386
+ import { getLocalizedUrl } from "intlayer";
1387
+ import NextLink, { type LinkProps as NextLinkProps } from "next/link";
1388
+ import { useLocale } from "next-intlayer";
1389
+ import type { PropsWithChildren, FC } from "react";
1390
+
1391
+ /**
1392
+ * उपयोगिता फ़ंक्शन यह जांचने के लिए कि दिया गया URL बाहरी है या नहीं।
1393
+ * यदि URL http:// या https:// से शुरू होता है, तो इसे बाहरी माना जाता है।
1394
+ */
1395
+ export const checkIsExternalLink = (href?: string): boolean =>
1396
+ /**
1397
+ * एक कस्टम Link कॉम्पोनेंट जो वर्तमान locale के आधार पर href attribute को अनुकूलित करता है।
1398
+ * आंतरिक लिंक के लिए, यह `getLocalizedUrl` का उपयोग करता है ताकि URL के आगे locale जोड़ा जा सके (जैसे, /fr/about)।
1399
+ * यह सुनिश्चित करता है कि नेविगेशन उसी locale संदर्भ के भीतर रहे।
1400
+ */
1401
+ export const Link: FC<PropsWithChildren<NextLinkProps>> = ({
1402
+ href,
1403
+ children,
1404
+ ...props
1405
+ }) => {
1406
+ const { locale } = useLocale();
1407
+ const isExternalLink = checkIsExternalLink(href.toString());
1408
+
1409
+ // यदि लिंक आंतरिक है और एक मान्य href प्रदान किया गया है, तो स्थानीयकृत URL प्राप्त करें।
1410
+ const hrefI18n: NextLinkProps["href"] =
1411
+ href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
1412
+
1413
+ return (
1414
+ <NextLink href={hrefI18n} {...props}>
1415
+ {children}
1416
+ </NextLink>
1417
+ );
1418
+ };
1419
+ ```
1420
+
1421
+ ```jsx fileName="src/components/Link.mjx" codeFormat="esm"
1422
+ "use client";
1423
+
1424
+ import { getLocalizedUrl } from "intlayer";
1425
+ import NextLink from "next/link";
1426
+ import { useLocale } from "next-intlayer";
1427
+
1428
+ /**
1429
+ * एक उपयोगिता फ़ंक्शन जो जांचता है कि दिया गया URL बाहरी है या नहीं।
1430
+ * यदि URL http:// या https:// से शुरू होता है, तो इसे बाहरी माना जाता है।
1431
+ */
1432
+ export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
1433
+
1434
+ /**
1435
+ * एक कस्टम Link कॉम्पोनेंट जो वर्तमान लोकल के आधार पर href एट्रिब्यूट को अनुकूलित करता है।
1436
+ * आंतरिक लिंक के लिए, यह `getLocalizedUrl` का उपयोग करता है ताकि URL के साथ लोकल (जैसे /fr/about) जोड़ा जा सके।
1437
+ * यह सुनिश्चित करता है कि नेविगेशन उसी लोकल संदर्भ के भीतर रहे।
1438
+ */
1439
+ export const Link = ({ href, children, ...props }) => {
1440
+ const { locale } = useLocale();
1441
+ const isExternalLink = checkIsExternalLink(href.toString());
1442
+
1443
+ // यदि लिंक आंतरिक है और एक मान्य href प्रदान किया गया है, तो स्थानीयकृत URL प्राप्त करें।
1444
+ const hrefI18n =
1445
+ href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
1446
+
1447
+ return (
1448
+ <NextLink href={hrefI18n} {...props}>
1449
+ {children}
1450
+ </NextLink>
1451
+ );
1452
+ };
1453
+ ```
1454
+
1455
+ ```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
1456
+ "use client";
1457
+
1458
+ const { getLocalizedUrl } = require("intlayer");
1459
+ const NextLink = require("next/link");
1460
+ const { useLocale } = require("next-intlayer");
1461
+
1462
+ /**
1463
+ * उपयोगिता फ़ंक्शन यह जांचने के लिए कि दिया गया URL बाहरी है या नहीं।
1464
+ * यदि URL http:// या https:// से शुरू होता है, तो इसे बाहरी माना जाता है।
1465
+ */
1466
+ const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
1467
+
1468
+ /**
1469
+ * एक कस्टम Link कॉम्पोनेंट जो वर्तमान लोकल के आधार पर href एट्रिब्यूट को अनुकूलित करता है।
1470
+ * आंतरिक लिंक के लिए, यह `getLocalizedUrl` का उपयोग करता है ताकि URL के आगे लोकल जोड़ा जा सके (जैसे, /fr/about)।
1471
+ * यह सुनिश्चित करता है कि नेविगेशन उसी लोकल संदर्भ के भीतर रहे।
1472
+ */
1473
+ const Link = ({ href, children, ...props }) => {
1474
+ const { locale } = useLocale();
1475
+ const isExternalLink = checkIsExternalLink(href.toString());
1476
+
1477
+ // यदि लिंक आंतरिक है और एक वैध href प्रदान किया गया है, तो स्थानीयकृत URL प्राप्त करें।
1478
+ const hrefI18n =
1479
+ href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
1480
+
1481
+ return (
1482
+ <NextLink href={hrefI18n} {...props}>
1483
+ {children}
1484
+ </NextLink>
1485
+ );
1486
+ };
1487
+ ```
1488
+
1489
+ #### यह कैसे काम करता है
1490
+
1491
+ - **बाहरी लिंक का पता लगाना**:
1492
+ सहायक फ़ंक्शन `checkIsExternalLink` यह निर्धारित करता है कि कोई URL बाहरी है या नहीं। बाहरी लिंक को अपरिवर्तित छोड़ दिया जाता है क्योंकि उन्हें स्थानीयकरण की आवश्यकता नहीं होती है।
1493
+
1494
+ - **वर्तमान लोकल प्राप्त करना**:
1495
+ `useLocale` हुक वर्तमान लोकल प्रदान करता है (जैसे, फ्रेंच के लिए `fr`)।
1496
+
1497
+ - **URL का स्थानीयकरण**:
1498
+ आंतरिक लिंक (अर्थात् गैर-बाहरी) के लिए, `getLocalizedUrl` का उपयोग वर्तमान लोकल के साथ URL को स्वचालित रूप से उपसर्गित करने के लिए किया जाता है। इसका मतलब है कि यदि आपका उपयोगकर्ता फ्रेंच में है, तो `href` के रूप में `/about` पास करने पर यह `/fr/about` में परिवर्तित हो जाएगा।
1499
+
1500
+ - **लिंक लौटाना**:
1501
+ यह कंपोनेंट स्थानीयकृत URL के साथ एक `<a>` तत्व लौटाता है, जिससे नेविगेशन लोकल के अनुरूप रहता है।
1502
+
1503
+ अपने एप्लिकेशन में इस `Link` कॉम्पोनेंट को एकीकृत करके, आप एक सुसंगत और भाषा-सचेत उपयोगकर्ता अनुभव बनाए रखते हैं, साथ ही बेहतर SEO और उपयोगिता का लाभ भी उठाते हैं।
1504
+
1505
+ ### (वैकल्पिक) चरण 12: सर्वर एक्शन्स में वर्तमान लोकल प्राप्त करें
1506
+
1507
+ यदि आपको सर्वर एक्शन के अंदर सक्रिय लोकल की आवश्यकता है (जैसे, ईमेल को स्थानीयकृत करने या लोकल-सचेत लॉजिक चलाने के लिए), तो `next-intlayer/server` से `getLocale` कॉल करें:
1508
+
1509
+ ```tsx fileName="src/app/actions/getLocale.ts" codeFormat="typescript"
1510
+ "use server";
1511
+
1512
+ import { getLocale } from "next-intlayer/server";
1513
+
1514
+ export const myServerAction = async () => {
1515
+ const locale = await getLocale();
1516
+
1517
+ // locale के साथ कुछ करें
1518
+ };
1519
+ ```
1520
+
1521
+ > `getLocale` फ़ंक्शन उपयोगकर्ता के लोकल को निर्धारित करने के लिए एक क्रमिक रणनीति का पालन करता है:
1522
+ >
1523
+ > 1. सबसे पहले, यह अनुरोध हेडर में उस लोकल मान की जांच करता है जो प्रॉक्सी द्वारा सेट किया गया हो सकता है
1524
+ > 2. यदि हेडर में कोई लोकल नहीं मिलता है, तो यह कुकीज़ में संग्रहीत लोकल की तलाश करता है
1525
+ > 3. यदि कोई कुकी नहीं मिलती है, तो यह उपयोगकर्ता की पसंदीदा भाषा का पता लगाने का प्रयास करता है जो उनके ब्राउज़र सेटिंग्स से प्राप्त होती है
1526
+ > 4. अंतिम विकल्प के रूप में, यह एप्लिकेशन द्वारा कॉन्फ़िगर किए गए डिफ़ॉल्ट लोकल पर वापस चला जाता है
1527
+ >
1528
+ > यह सुनिश्चित करता है कि उपलब्ध संदर्भ के आधार पर सबसे उपयुक्त लोकल चुना जाए।
1529
+
1530
+ ### (वैकल्पिक) चरण 13: अपने बंडल आकार को अनुकूलित करें
1531
+
1532
+ `next-intlayer` का उपयोग करते समय, डिक्शनरी डिफ़ॉल्ट रूप से हर पेज के लिए बंडल में शामिल होती हैं। बंडल आकार को अनुकूलित करने के लिए, Intlayer एक वैकल्पिक SWC प्लगइन प्रदान करता है जो मैक्रोज़ का उपयोग करके `useIntlayer` कॉल्स को बुद्धिमानी से बदलता है। यह सुनिश्चित करता है कि डिक्शनरी केवल उन पेजों के बंडल में शामिल हों जो वास्तव में उनका उपयोग करते हैं।
1533
+
1534
+ इस अनुकूलन को सक्षम करने के लिए, `@intlayer/swc` पैकेज इंस्टॉल करें। एक बार इंस्टॉल हो जाने पर, `next-intlayer` स्वचालित रूप से इस प्लगइन का पता लगाएगा और उपयोग करेगा:
1535
+
1536
+ ```bash packageManager="npm"
1537
+ npm install @intlayer/swc --save-dev
1538
+ ```
1539
+
1540
+ ```bash packageManager="pnpm"
1541
+ pnpm add @intlayer/swc --save-dev
1542
+ ```
1543
+
1544
+ ```bash packageManager="yarn"
1545
+ yarn add @intlayer/swc --save-dev
1546
+ ```
1547
+
1548
+ > नोट: यह अनुकूलन केवल Next.js 13 और उससे ऊपर के लिए उपलब्ध है।
1549
+
1550
+ > नोट: यह पैकेज डिफ़ॉल्ट रूप से इंस्टॉल नहीं होता क्योंकि SWC प्लगइन्स अभी भी Next.js में प्रयोगात्मक हैं। भविष्य में यह बदल सकता है।
1551
+
1552
+ ### Turbopack पर शब्दकोश परिवर्तनों को देखें
1553
+
1554
+ जब आप `next dev` कमांड के साथ Turbopack को अपने विकास सर्वर के रूप में उपयोग करते हैं, तो शब्दकोश परिवर्तनों का स्वतः पता नहीं चलता।
1555
+
1556
+ यह सीमा इसलिए होती है क्योंकि Turbopack आपके कंटेंट फ़ाइलों में परिवर्तनों की निगरानी के लिए वेबपैक प्लगइन्स को समानांतर में नहीं चला सकता। इस समस्या से बचने के लिए, आपको `intlayer watch` कमांड का उपयोग करना होगा ताकि विकास सर्वर और Intlayer बिल्ड वॉचर दोनों को एक साथ चलाया जा सके।
1557
+
1558
+ ```json5 fileName="package.json"
1559
+ {
1560
+ // ... आपके मौजूदा package.json कॉन्फ़िगरेशन
1561
+ "scripts": {
1562
+ // ... आपके मौजूदा स्क्रिप्ट कॉन्फ़िगरेशन
1563
+ "dev": "intlayer watch --with 'next dev'",
1564
+ },
1565
+ }
1566
+ ```
1567
+
1568
+ > यदि आप next-intlayer@<=6.x.x का उपयोग कर रहे हैं, तो आपको Next.js 16 एप्लिकेशन को Turbopack के साथ सही ढंग से काम करने के लिए `--turbopack` फ्लैग रखना होगा। इस सीमा से बचने के लिए हम next-intlayer@>=7.x.x का उपयोग करने की सलाह देते हैं।
1569
+
1570
+ ### TypeScript कॉन्फ़िगर करें
1571
+
1572
+ Intlayer TypeScript के लाभ प्राप्त करने और आपके कोडबेस को मजबूत बनाने के लिए मॉड्यूल ऑगमेंटेशन का उपयोग करता है।
1573
+
1574
+ ![ऑटोकम्प्लीशन](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1575
+
1576
+ ![अनुवाद त्रुटि](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1577
+
1578
+ सुनिश्चित करें कि आपकी TypeScript कॉन्फ़िगरेशन में ऑटो-जेनरेटेड टाइप्स शामिल हैं।
1579
+
1580
+ ```json5 fileName="tsconfig.json"
1581
+ {
1582
+ // ... आपकी मौजूदा TypeScript कॉन्फ़िगरेशन
1583
+ "include": [
1584
+ // ... आपकी मौजूदा TypeScript कॉन्फ़िगरेशन
1585
+ ".intlayer/**/*.ts", // ऑटो-जनरेटेड टाइप्स को शामिल करें
1586
+ ],
1587
+ }
1588
+ ```
1589
+
1590
+ ### गिट कॉन्फ़िगरेशन
1591
+
1592
+ यह अनुशंसित है कि Intlayer द्वारा जनरेट की गई फाइलों को अनदेखा किया जाए। इससे आप उन्हें अपनी Git रिपॉजिटरी में कमिट करने से बच सकते हैं।
1593
+
1594
+ इसके लिए, आप अपनी `.gitignore` फाइल में निम्नलिखित निर्देश जोड़ सकते हैं:
1595
+
1596
+ ```plaintext fileName=".gitignore"
1597
+ # Intlayer द्वारा जनरेट की गई फाइलों को अनदेखा करें
1598
+ .intlayer
1599
+ ```
1600
+
1601
+ ### VS कोड एक्सटेंशन
1602
+
1603
+ Intlayer के साथ अपने विकास अनुभव को बेहतर बनाने के लिए, आप आधिकारिक **Intlayer VS कोड एक्सटेंशन** इंस्टॉल कर सकते हैं।
1604
+
1605
+ [VS कोड मार्केटप्लेस से इंस्टॉल करें](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
1606
+
1607
+ यह एक्सटेंशन प्रदान करता है:
1608
+
1609
+ - अनुवाद कुंजियों के लिए **ऑटोकंप्लीशन**।
1610
+ - गायब अनुवादों के लिए **रीयल-टाइम त्रुटि पहचान**।
1611
+ - अनुवादित सामग्री के **इनलाइन पूर्वावलोकन**।
1612
+ - अनुवादों को आसानी से बनाने और अपडेट करने के लिए **त्वरित क्रियाएँ**।
1613
+
1614
+ एक्सटेंशन का उपयोग कैसे करें, इसके लिए अधिक विवरण के लिए देखें [Intlayer VS Code एक्सटेंशन दस्तावेज़](https://intlayer.org/doc/vs-code-extension)।
1615
+
1616
+ ### आगे बढ़ें
1617
+
1618
+ आगे बढ़ने के लिए, आप [विज़ुअल एडिटर](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) का उपयोग करके बाहरीकृत कर सकते हैं।