@intlayer/docs 5.7.6 → 5.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/generated/docs.entry.cjs +44 -238
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +44 -238
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -2
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/CI_CD.md +67 -41
- package/docs/ar/intlayer_with_tanstack.md +457 -0
- package/docs/ar/packages/next-intlayer/index.md +0 -1
- package/docs/ar/packages/react-intlayer/index.md +0 -1
- package/docs/de/CI_CD.md +63 -37
- package/docs/de/intlayer_with_tanstack.md +458 -0
- package/docs/de/packages/next-intlayer/index.md +0 -1
- package/docs/de/packages/react-intlayer/index.md +0 -1
- package/docs/en/CI_CD.md +51 -27
- package/docs/en/intlayer_with_tanstack.md +452 -0
- package/docs/en/packages/next-intlayer/index.md +0 -1
- package/docs/en/packages/react-intlayer/index.md +0 -1
- package/docs/en-GB/CI_CD.md +58 -32
- package/docs/en-GB/intlayer_with_tanstack.md +457 -0
- package/docs/en-GB/packages/next-intlayer/index.md +0 -1
- package/docs/en-GB/packages/react-intlayer/index.md +0 -1
- package/docs/es/CI_CD.md +68 -42
- package/docs/es/intlayer_with_tanstack.md +435 -0
- package/docs/es/packages/next-intlayer/index.md +0 -1
- package/docs/es/packages/react-intlayer/index.md +0 -1
- package/docs/fr/intlayer_with_tanstack.md +435 -0
- package/docs/fr/packages/next-intlayer/index.md +0 -1
- package/docs/fr/packages/react-intlayer/index.md +0 -1
- package/docs/hi/CI_CD.md +69 -44
- package/docs/hi/intlayer_with_tanstack.md +438 -0
- package/docs/hi/packages/next-intlayer/index.md +0 -1
- package/docs/hi/packages/react-intlayer/index.md +0 -1
- package/docs/it/CI_CD.md +67 -41
- package/docs/it/intlayer_with_tanstack.md +457 -0
- package/docs/it/packages/next-intlayer/index.md +0 -1
- package/docs/it/packages/react-intlayer/index.md +0 -1
- package/docs/ja/CI_CD.md +67 -41
- package/docs/ja/intlayer_with_tanstack.md +457 -0
- package/docs/ja/packages/next-intlayer/index.md +0 -1
- package/docs/ja/packages/react-intlayer/index.md +0 -1
- package/docs/ko/CI_CD.md +63 -37
- package/docs/ko/intlayer_with_tanstack.md +457 -0
- package/docs/ko/packages/next-intlayer/index.md +0 -1
- package/docs/ko/packages/react-intlayer/index.md +0 -1
- package/docs/pt/CI_CD.md +67 -41
- package/docs/pt/intlayer_with_tanstack.md +457 -0
- package/docs/pt/packages/next-intlayer/index.md +0 -1
- package/docs/pt/packages/react-intlayer/index.md +0 -1
- package/docs/ru/CI_CD.md +70 -44
- package/docs/ru/intlayer_with_tanstack.md +458 -0
- package/docs/ru/packages/next-intlayer/index.md +0 -1
- package/docs/ru/packages/react-intlayer/index.md +0 -1
- package/docs/zh/CI_CD.md +62 -36
- package/docs/zh/intlayer_with_tanstack.md +435 -0
- package/docs/zh/packages/next-intlayer/index.md +0 -1
- package/docs/zh/packages/react-intlayer/index.md +0 -1
- package/package.json +9 -9
- package/src/generated/docs.entry.ts +44 -238
- package/docs/ar/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ar/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/de/packages/next-intlayer/useIntlayerAsync.md +0 -262
- package/docs/de/packages/react-intlayer/useIntlayerAsync.md +0 -256
- package/docs/en/packages/next-intlayer/useIntlayerAsync.md +0 -239
- package/docs/en/packages/react-intlayer/useIntlayerAsync.md +0 -254
- package/docs/en-GB/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/en-GB/packages/react-intlayer/useIntlayerAsync.md +0 -257
- package/docs/es/packages/next-intlayer/useIntlayerAsync.md +0 -240
- package/docs/es/packages/react-intlayer/useIntlayerAsync.md +0 -276
- package/docs/fr/packages/next-intlayer/useIntlayerAsync.md +0 -238
- package/docs/fr/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/hi/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/hi/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/it/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/it/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/ja/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ja/packages/react-intlayer/useIntlayerAsync.md +0 -268
- package/docs/ko/packages/next-intlayer/useIntlayerAsync.md +0 -260
- package/docs/ko/packages/react-intlayer/useIntlayerAsync.md +0 -271
- package/docs/pt/packages/next-intlayer/useIntlayerAsync.md +0 -238
- package/docs/pt/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/ru/packages/next-intlayer/useIntlayerAsync.md +0 -237
- package/docs/ru/packages/react-intlayer/useIntlayerAsync.md +0 -252
- package/docs/zh/packages/next-intlayer/useIntlayerAsync.md +0 -239
- package/docs/zh/packages/react-intlayer/useIntlayerAsync.md +0 -257
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-08-11
|
|
3
|
+
updatedAt: 2025-08-11
|
|
4
|
+
title: TanStack Start (React) में Intlayer के साथ शुरुआत करना
|
|
5
|
+
description: Intlayer का उपयोग करके अपने TanStack Start ऐप में i18n जोड़ें—कंपोनेंट-स्तरीय शब्दकोश, स्थानीयकृत URL, और SEO-अनुकूल मेटाडेटा।
|
|
6
|
+
keywords:
|
|
7
|
+
- अंतरराष्ट्रीयकरण
|
|
8
|
+
- दस्तावेज़ीकरण
|
|
9
|
+
- Intlayer
|
|
10
|
+
- TanStack Start
|
|
11
|
+
- TanStack Router
|
|
12
|
+
- React
|
|
13
|
+
- i18n
|
|
14
|
+
- JavaScript
|
|
15
|
+
slugs:
|
|
16
|
+
- doc
|
|
17
|
+
- environment
|
|
18
|
+
- tanstack-start
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Intlayer और TanStack Start (React) के साथ अंतरराष्ट्रीयकरण (i18n) शुरू करना
|
|
22
|
+
|
|
23
|
+
## Intlayer क्या है?
|
|
24
|
+
|
|
25
|
+
**Intlayer** React ऐप्स के लिए एक ओपन-सोर्स i18n टूलकिट है। यह आपको प्रदान करता है:
|
|
26
|
+
|
|
27
|
+
- **कंपोनेंट-स्थानीय शब्दकोश** TypeScript सुरक्षा के साथ।
|
|
28
|
+
- **डायनामिक मेटाडेटा और रूट्स** (SEO-तैयार)।
|
|
29
|
+
- **रनटाइम लोकल स्विचिंग** (और लोकल का पता लगाने/सहेजने के लिए सहायक)।
|
|
30
|
+
- **Vite प्लगइन** बिल्ड-टाइम ट्रांसफॉर्म और डेवलपर अनुभव (DX) के लिए।
|
|
31
|
+
|
|
32
|
+
यह गाइड दिखाता है कि Intlayer को **TanStack Start** प्रोजेक्ट में कैसे जोड़ा जाए (जो अंतर्निहित रूप से Vite का उपयोग करता है और रूटिंग/SSR के लिए TanStack Router का उपयोग करता है)।
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## चरण 1: निर्भरताएँ स्थापित करें
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# npm
|
|
40
|
+
npm i intlayer react-intlayer
|
|
41
|
+
npm i -D vite-intlayer
|
|
42
|
+
|
|
43
|
+
# pnpm
|
|
44
|
+
pnpm add intlayer react-intlayer
|
|
45
|
+
pnpm add -D vite-intlayer
|
|
46
|
+
|
|
47
|
+
# yarn
|
|
48
|
+
yarn add intlayer react-intlayer
|
|
49
|
+
yarn add -D vite-intlayer
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- **intlayer**: कोर (कॉन्फ़िग, शब्दकोश, CLI/ट्रांसफॉर्म)।
|
|
53
|
+
- **react-intlayer**: `<IntlayerProvider>` + React के लिए हुक्स।
|
|
54
|
+
- **vite-intlayer**: Vite प्लगइन, साथ ही वैकल्पिक मिडलवेयर लोकल डिटेक्शन/रिडायरेक्ट के लिए (डेवलपमेंट और SSR/पूर्वावलोकन में काम करता है; प्रोडक्शन SSR के लिए इसे `dependencies` में ले जाएं)।
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## चरण 2: Intlayer कॉन्फ़िगर करें
|
|
59
|
+
|
|
60
|
+
अपने प्रोजेक्ट रूट पर `intlayer.config.ts` बनाएं:
|
|
61
|
+
|
|
62
|
+
```ts fileName="intlayer.config.ts"
|
|
63
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
64
|
+
|
|
65
|
+
const config: IntlayerConfig = {
|
|
66
|
+
internationalization: {
|
|
67
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
68
|
+
defaultLocale: Locales.ENGLISH,
|
|
69
|
+
},
|
|
70
|
+
// आप contentDir, contentFileExtensions, middleware विकल्प आदि को भी समायोजित कर सकते हैं।
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default config;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
यदि आप `cjs`/`mjs` पसंद करते हैं तो CommonJS/ESM वेरिएंट आपके मूल दस्तावेज़ के समान ही हैं।
|
|
77
|
+
|
|
78
|
+
> पूर्ण कॉन्फ़िग संदर्भ के लिए: Intlayer के कॉन्फ़िगरेशन दस्तावेज़ देखें।
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## चरण 3: Vite प्लगइन (और वैकल्पिक मिडलवेयर) जोड़ें
|
|
83
|
+
|
|
84
|
+
**TanStack Start Vite का उपयोग करता है**, इसलिए Intlayer के प्लगइन को अपने `vite.config.ts` में जोड़ें:
|
|
85
|
+
|
|
86
|
+
```ts fileName="vite.config.ts"
|
|
87
|
+
import { defineConfig } from "vite";
|
|
88
|
+
import react from "@vitejs/plugin-react-swc";
|
|
89
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
90
|
+
|
|
91
|
+
export default defineConfig({
|
|
92
|
+
plugins: [
|
|
93
|
+
react(),
|
|
94
|
+
intlayerPlugin(),
|
|
95
|
+
// वैकल्पिक लेकिन स्थानीय पहचान, कुकीज़ और रीडायरेक्ट के लिए अनुशंसित:
|
|
96
|
+
intLayerMiddlewarePlugin(),
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
> यदि आप SSR तैनात करते हैं, तो `vite-intlayer` को `dependencies` में स्थानांतरित करें ताकि मिडलवेयर उत्पादन में चले।
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## चरण 4: अपनी सामग्री घोषित करें
|
|
106
|
+
|
|
107
|
+
अपने शब्दकोशों को `./src` (डिफ़ॉल्ट `contentDir`) के अंतर्गत कहीं भी रखें। उदाहरण:
|
|
108
|
+
|
|
109
|
+
```tsx fileName="src/app.content.tsx"
|
|
110
|
+
import { t, type Dictionary } from "intlayer";
|
|
111
|
+
import type { ReactNode } from "react";
|
|
112
|
+
|
|
113
|
+
const appContent = {
|
|
114
|
+
key: "app",
|
|
115
|
+
content: {
|
|
116
|
+
viteLogo: t({ en: "Vite logo", fr: "Logo Vite", es: "Logo Vite" }),
|
|
117
|
+
reactLogo: t({ en: "React logo", fr: "Logo React", es: "Logo React" }),
|
|
118
|
+
title: t({
|
|
119
|
+
en: "TanStack Start + React",
|
|
120
|
+
fr: "TanStack Start + React",
|
|
121
|
+
es: "TanStack Start + React",
|
|
122
|
+
}),
|
|
123
|
+
count: t({ en: "count is ", fr: "le compte est ", es: "el recuento es " }),
|
|
124
|
+
edit: t<ReactNode>({
|
|
125
|
+
en: (
|
|
126
|
+
<>
|
|
127
|
+
<code>src/routes/index.tsx</code> को संपादित करें और HMR परीक्षण के
|
|
128
|
+
लिए सहेजें
|
|
129
|
+
</>
|
|
130
|
+
),
|
|
131
|
+
fr: (
|
|
132
|
+
<>
|
|
133
|
+
Éditez <code>src/routes/index.tsx</code> et enregistrez pour tester
|
|
134
|
+
HMR
|
|
135
|
+
</>
|
|
136
|
+
),
|
|
137
|
+
es: (
|
|
138
|
+
<>
|
|
139
|
+
Edita <code>src/routes/index.tsx</code> y guarda para probar HMR
|
|
140
|
+
</>
|
|
141
|
+
),
|
|
142
|
+
}),
|
|
143
|
+
readTheDocs: t({
|
|
144
|
+
en: "लोगो पर क्लिक करके अधिक जानें",
|
|
145
|
+
fr: "Cliquez sur les logos pour en savoir plus",
|
|
146
|
+
es: "Haz clic en los logotipos para saber más",
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
} satisfies Dictionary;
|
|
150
|
+
|
|
151
|
+
export default appContent;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
JSON/ESM/CJS संस्करण आपके मूल दस्तावेज़ की तरह ही काम करते हैं।
|
|
155
|
+
|
|
156
|
+
> TSX सामग्री? यदि आपकी सेटअप को इसकी आवश्यकता है तो `import React from "react"` करना न भूलें।
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## चरण 5: TanStack Start को Intlayer के साथ लपेटें
|
|
161
|
+
|
|
162
|
+
TanStack Start के साथ, आपका **रूट रूट** प्रदाताओं को सेट करने के लिए सही स्थान है।
|
|
163
|
+
|
|
164
|
+
```tsx fileName="src/routes/__root.tsx"
|
|
165
|
+
import {
|
|
166
|
+
Outlet,
|
|
167
|
+
createRootRoute,
|
|
168
|
+
Link as RouterLink,
|
|
169
|
+
} from "@tanstack/react-router";
|
|
170
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
171
|
+
|
|
172
|
+
function AppShell() {
|
|
173
|
+
// शीर्ष स्तर पर एक शब्दकोश का उपयोग करने का उदाहरण:
|
|
174
|
+
const content = useIntlayer("app");
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div>
|
|
178
|
+
<nav className="flex gap-3 p-3">
|
|
179
|
+
<RouterLink to="/">होम</RouterLink>
|
|
180
|
+
<RouterLink to="/about">के बारे में</RouterLink>
|
|
181
|
+
</nav>
|
|
182
|
+
<main className="p-6">
|
|
183
|
+
<h1>{content.title}</h1>
|
|
184
|
+
<Outlet />
|
|
185
|
+
</main>
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export const Route = createRootRoute({
|
|
191
|
+
component: () => (
|
|
192
|
+
<IntlayerProvider>
|
|
193
|
+
<AppShell />
|
|
194
|
+
</IntlayerProvider>
|
|
195
|
+
),
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
फिर अपने पृष्ठों में अपनी सामग्री का उपयोग करें:
|
|
200
|
+
|
|
201
|
+
```tsx fileName="src/routes/index.tsx"
|
|
202
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
203
|
+
import { useIntlayer } from "react-intlayer";
|
|
204
|
+
import reactLogo from "../assets/react.svg";
|
|
205
|
+
|
|
206
|
+
export const Route = createFileRoute("/")({
|
|
207
|
+
component: () => {
|
|
208
|
+
const content = useIntlayer("app");
|
|
209
|
+
return (
|
|
210
|
+
<>
|
|
211
|
+
<button>{content.count}0</button>
|
|
212
|
+
<p>{content.edit}</p>
|
|
213
|
+
<img
|
|
214
|
+
src={reactLogo}
|
|
215
|
+
alt={content.reactLogo.value}
|
|
216
|
+
width={48}
|
|
217
|
+
height={48}
|
|
218
|
+
/>
|
|
219
|
+
<p className="opacity-70">{content.readTheDocs}</p>
|
|
220
|
+
</>
|
|
221
|
+
);
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
> स्ट्रिंग गुण (`alt`, `title`, `aria-label`, …) को `.value` की आवश्यकता होती है:
|
|
227
|
+
>
|
|
228
|
+
> ```jsx
|
|
229
|
+
> <img alt={c.reactLogo.value} />
|
|
230
|
+
> ```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## (वैकल्पिक) चरण 6: भाषा स्विचिंग (क्लाइंट)
|
|
235
|
+
|
|
236
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx"
|
|
237
|
+
import { Locales } from "intlayer";
|
|
238
|
+
import { useLocale } from "react-intlayer";
|
|
239
|
+
|
|
240
|
+
export function LocaleSwitcher() {
|
|
241
|
+
const { setLocale } = useLocale();
|
|
242
|
+
return (
|
|
243
|
+
<div className="flex gap-2">
|
|
244
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>अंग्रेज़ी</button>
|
|
245
|
+
<button onClick={() => setLocale(Locales.FRENCH)}>फ्रेंच</button>
|
|
246
|
+
<button onClick={() => setLocale(Locales.SPANISH)}>स्पेनिश</button>
|
|
247
|
+
</div>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## (वैकल्पिक) चरण 7: स्थानीयकृत रूटिंग (SEO-अनुकूल URL)
|
|
255
|
+
|
|
256
|
+
TanStack Start के साथ आपके पास **दो अच्छे पैटर्न** हैं। एक चुनें।
|
|
257
|
+
|
|
258
|
+
`src/routes/$locale/` नामक एक डायनेमिक सेगमेंट फ़ोल्डर बनाएं ताकि आपके URL `/:locale/...` हों। `$locale` लेआउट में, `params.locale` को मान्य करें, `<IntlayerProvider locale=...>` सेट करें, और एक `<Outlet />` रेंडर करें। यह तरीका सीधा है, लेकिन आप अपने बाकी रूट्स को `$locale` के नीचे माउंट करेंगे, और यदि आप डिफ़ॉल्ट लोकल को प्रीफिक्स नहीं करना चाहते हैं तो आपको एक अतिरिक्त गैर-प्रिफिक्स्ड ट्री की आवश्यकता होगी।
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## (वैकल्पिक) चरण 8: लोकैल बदलते समय URL अपडेट करें
|
|
263
|
+
|
|
264
|
+
पैटर्न A (basepath) के साथ, लोकैल बदलना मतलब है **एक अलग basepath पर नेविगेट करना**:
|
|
265
|
+
|
|
266
|
+
```tsx fileName="src/components/LocaleSwitcherNavigate.tsx"
|
|
267
|
+
import { useRouter } from "@tanstack/react-router";
|
|
268
|
+
import { Locales, getLocalizedUrl } from "intlayer";
|
|
269
|
+
import { useLocale } from "react-intlayer";
|
|
270
|
+
|
|
271
|
+
export function LocaleSwitcherNavigate() {
|
|
272
|
+
const router = useRouter();
|
|
273
|
+
const { locale, setLocale } = useLocale();
|
|
274
|
+
|
|
275
|
+
const change = async (next: Locales) => {
|
|
276
|
+
if (next === locale) return;
|
|
277
|
+
const nextPath = getLocalizedUrl(
|
|
278
|
+
window.location.pathname + window.location.search,
|
|
279
|
+
next
|
|
280
|
+
);
|
|
281
|
+
await router.navigate({ to: nextPath }); // इतिहास को संरक्षित करता है
|
|
282
|
+
setLocale(next);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<div className="flex gap-2">
|
|
287
|
+
<button onClick={() => change(Locales.ENGLISH)}>अंग्रेज़ी</button>
|
|
288
|
+
<button onClick={() => change(Locales.FRENCH)}>फ्रेंच</button>
|
|
289
|
+
<button onClick={() => change(Locales.SPANISH)}>स्पेनिश</button>
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## (वैकल्पिक) चरण 9: `<html lang>` और `dir` (TanStack Start Document)
|
|
298
|
+
|
|
299
|
+
TanStack Start एक **Document** (रूट HTML शेल) प्रदान करता है जिसे आप अनुकूलित कर सकते हैं। पहुँच/SEO के लिए `lang` और `dir` सेट करें:
|
|
300
|
+
|
|
301
|
+
```tsx fileName="src/routes/__root.tsx" {4,15}
|
|
302
|
+
import { Outlet, createRootRoute } from "@tanstack/react-router";
|
|
303
|
+
import { IntlayerProvider } from "react-intlayer";
|
|
304
|
+
import { getHTMLTextDir } from "intlayer";
|
|
305
|
+
|
|
306
|
+
function Document({
|
|
307
|
+
locale,
|
|
308
|
+
children,
|
|
309
|
+
}: {
|
|
310
|
+
locale: string;
|
|
311
|
+
children: React.ReactNode;
|
|
312
|
+
}) {
|
|
313
|
+
return (
|
|
314
|
+
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
315
|
+
<head>
|
|
316
|
+
<meta charSet="utf-8" />
|
|
317
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
318
|
+
{/* ... */}
|
|
319
|
+
</head>
|
|
320
|
+
<body>{children}</body>
|
|
321
|
+
</html>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export const Route = createRootRoute({
|
|
326
|
+
component: () => (
|
|
327
|
+
<IntlayerProvider>
|
|
328
|
+
{/* यदि आप सर्वर पर locale की गणना करते हैं, तो इसे Document में पास करें; अन्यथा क्लाइंट पोस्ट-हाइड्रेशन के बाद सही कर देगा */}
|
|
329
|
+
<Document locale={document?.documentElement?.lang || "en"}>
|
|
330
|
+
<Outlet />
|
|
331
|
+
</Document>
|
|
332
|
+
</IntlayerProvider>
|
|
333
|
+
),
|
|
334
|
+
});
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
क्लाइंट-साइड सुधार के लिए, आप अपना छोटा हुक भी रख सकते हैं:
|
|
338
|
+
|
|
339
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx"
|
|
340
|
+
import { useEffect } from "react";
|
|
341
|
+
import { useLocale } from "react-intlayer";
|
|
342
|
+
import { getHTMLTextDir } from "intlayer";
|
|
343
|
+
|
|
344
|
+
export const useI18nHTMLAttributes = () => {
|
|
345
|
+
const { locale } = useLocale();
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
document.documentElement.lang = locale;
|
|
348
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
349
|
+
}, [locale]);
|
|
350
|
+
};
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## (वैकल्पिक) चरण 10: स्थानीयकृत लिंक कॉम्पोनेंट
|
|
356
|
+
|
|
357
|
+
TanStack Router एक `<Link/>` प्रदान करता है, लेकिन यदि आपको कभी एक साधारण `<a>` की आवश्यकता हो जो आंतरिक URL को स्वचालित रूप से प्रीफिक्स करे:
|
|
358
|
+
|
|
359
|
+
```tsx fileName="src/components/Link.tsx"
|
|
360
|
+
import { getLocalizedUrl } from "intlayer";
|
|
361
|
+
import {
|
|
362
|
+
forwardRef,
|
|
363
|
+
type AnchorHTMLAttributes,
|
|
364
|
+
type DetailedHTMLProps,
|
|
365
|
+
} from "react";
|
|
366
|
+
import { useLocale } from "react-intlayer";
|
|
367
|
+
|
|
368
|
+
export interface LinkProps
|
|
369
|
+
extends DetailedHTMLProps<
|
|
370
|
+
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
371
|
+
HTMLAnchorElement
|
|
372
|
+
> {}
|
|
373
|
+
|
|
374
|
+
const isExternal = (href?: string) => /^https?:\/\//.test(href ?? "");
|
|
375
|
+
|
|
376
|
+
// बाहरी URL की जांच करने के लिए फ़ंक्शन
|
|
377
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
378
|
+
({ href, children, ...props }, ref) => {
|
|
379
|
+
const { locale } = useLocale();
|
|
380
|
+
// यदि href आंतरिक URL है, तो इसे स्थानीयकृत URL में बदलें
|
|
381
|
+
const hrefI18n =
|
|
382
|
+
href && !isExternal(href) ? getLocalizedUrl(href, locale) : href;
|
|
383
|
+
return (
|
|
384
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
385
|
+
{children}
|
|
386
|
+
</a>
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
Link.displayName = "Link";
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
> यदि आप पैटर्न A (basepath) का उपयोग करते हैं, तो TanStack का `<Link to="/about" />` पहले से ही `basepath` के माध्यम से `/fr/about` को हल करता है, इसलिए एक कस्टम लिंक वैकल्पिक है।
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## TypeScript
|
|
398
|
+
|
|
399
|
+
Intlayer द्वारा उत्पन्न प्रकारों को शामिल करें:
|
|
400
|
+
|
|
401
|
+
```json5 fileName="tsconfig.json"
|
|
402
|
+
{
|
|
403
|
+
"include": ["src", ".intlayer/**/*.ts"],
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## Git
|
|
410
|
+
|
|
411
|
+
Intlayer द्वारा उत्पन्न आर्टिफैक्ट्स को अनदेखा करें:
|
|
412
|
+
|
|
413
|
+
```gitignore
|
|
414
|
+
.intlayer
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## VS कोड एक्सटेंशन
|
|
420
|
+
|
|
421
|
+
- **Intlayer VS कोड एक्सटेंशन** → ऑटोकंप्लीशन, त्रुटियाँ, इनलाइन प्रीव्यू, त्वरित क्रियाएँ।
|
|
422
|
+
मार्केटप्लेस: `intlayer.intlayer-vs-code-extension`
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## आगे बढ़ें
|
|
427
|
+
|
|
428
|
+
- विज़ुअल एडिटर
|
|
429
|
+
- CMS मोड
|
|
430
|
+
- एज / एडाप्टर पर लोकल डिटेक्शन
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## दस्तावेज़ इतिहास
|
|
435
|
+
|
|
436
|
+
| संस्करण | तिथि | परिवर्तन |
|
|
437
|
+
| ------- | ---------- | ---------------------------------- |
|
|
438
|
+
| 1.0.0 | 2025-08-11 | TanStack स्टार्ट अनुकूलन जोड़ा गया |
|
|
@@ -280,7 +280,6 @@ Intlayer आपके Next.js एप्लिकेशन को अंतरर
|
|
|
280
280
|
- [`useIntlayer()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/next-intlayer/useIntlayer.md)
|
|
281
281
|
- [`useDictionary()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/next-intlayer/useDictionary.md)
|
|
282
282
|
- [`useLocale()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/next-intlayer/useLocale.md)
|
|
283
|
-
- [`useIntlayerAsync()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/next-intlayer/useIntlayerAsync.md)
|
|
284
283
|
|
|
285
284
|
## दस्तावेज़ इतिहास
|
|
286
285
|
|
|
@@ -273,7 +273,6 @@ Intlayer आपके React एप्लिकेशन को अंतरर
|
|
|
273
273
|
- [`useIntlayer()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/react-intlayer/useIntlayer.md)
|
|
274
274
|
- [`useDictionary()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/react-intlayer/useDictionary.md)
|
|
275
275
|
- [`useLocale()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/react-intlayer/useLocale.md)
|
|
276
|
-
- [`useIntlayerAsync()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/packages/react-intlayer/useIntlayerAsync.md)
|
|
277
276
|
|
|
278
277
|
## दस्तावेज़ इतिहास
|
|
279
278
|
|
package/docs/it/CI_CD.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-05-20
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-08-13
|
|
4
4
|
title: Integrazione CI/CD
|
|
5
|
-
description: Scopri come integrare Intlayer nella tua pipeline CI/CD per la gestione e il deployment
|
|
5
|
+
description: Scopri come integrare Intlayer nella tua pipeline CI/CD per la gestione e il deployment automatizzato dei contenuti.
|
|
6
6
|
keywords:
|
|
7
7
|
- CI/CD
|
|
8
8
|
- Integrazione Continua
|
|
@@ -19,13 +19,13 @@ slugs:
|
|
|
19
19
|
|
|
20
20
|
# Generazione Automatica delle Traduzioni in una Pipeline CI/CD
|
|
21
21
|
|
|
22
|
-
Intlayer consente la generazione automatica delle traduzioni per i tuoi file di dichiarazione dei contenuti. Ci sono diversi modi per
|
|
22
|
+
Intlayer consente la generazione automatica delle traduzioni per i tuoi file di dichiarazione dei contenuti. Ci sono diversi modi per raggiungere questo obiettivo a seconda del tuo flusso di lavoro.
|
|
23
23
|
|
|
24
24
|
## Utilizzo del CMS
|
|
25
25
|
|
|
26
|
-
Con Intlayer, puoi adottare un flusso di lavoro in cui viene dichiarata localmente una sola lingua, mentre tutte le traduzioni sono gestite da remoto tramite il CMS. Questo permette che
|
|
26
|
+
Con Intlayer, puoi adottare un flusso di lavoro in cui viene dichiarata localmente una sola lingua, mentre tutte le traduzioni sono gestite da remoto tramite il CMS. Questo permette che contenuti e traduzioni siano completamente separati dal codice, offrendo maggiore flessibilità agli editor di contenuti e abilitando il caricamento dinamico dei contenuti (senza bisogno di ricostruire l'applicazione per applicare le modifiche).
|
|
27
27
|
|
|
28
|
-
### Configurazione di
|
|
28
|
+
### Configurazione di Esempio
|
|
29
29
|
|
|
30
30
|
```ts fileName="intlayer.config.ts"
|
|
31
31
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -58,7 +58,7 @@ Per saperne di più sul CMS, consulta la [documentazione ufficiale](https://gith
|
|
|
58
58
|
|
|
59
59
|
Puoi integrare la generazione delle traduzioni nel tuo flusso di lavoro Git locale usando [Husky](https://typicode.github.io/husky/).
|
|
60
60
|
|
|
61
|
-
### Configurazione di
|
|
61
|
+
### Configurazione di Esempio
|
|
62
62
|
|
|
63
63
|
```ts fileName="intlayer.config.ts"
|
|
64
64
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -91,7 +91,7 @@ npx intlayer fill --unpushed --mode fill # Riempie solo i contenuti mancanti,
|
|
|
91
91
|
|
|
92
92
|
> Per maggiori informazioni sui comandi CLI di Intlayer e sul loro utilizzo, consulta la [documentazione CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_cli.md).
|
|
93
93
|
|
|
94
|
-
> Se hai più app nel tuo repository che utilizzano istanze
|
|
94
|
+
> Se hai più app nel tuo repository che utilizzano istanze separate di Intlayer, puoi usare l'argomento `--base-dir` in questo modo:
|
|
95
95
|
|
|
96
96
|
```bash fileName=".husky/pre-push"
|
|
97
97
|
# App 1
|
|
@@ -103,70 +103,96 @@ npx intlayer build --base-dir ./app2
|
|
|
103
103
|
npx intlayer fill --base-dir ./app2 --unpushed --mode fill
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
##
|
|
106
|
+
## Utilizzo di GitHub Actions
|
|
107
107
|
|
|
108
108
|
Intlayer fornisce un comando CLI per l'autocompletamento e la revisione del contenuto del dizionario. Questo può essere integrato nel tuo flusso di lavoro CI/CD utilizzando GitHub Actions.
|
|
109
109
|
|
|
110
110
|
```yaml fileName=".github/workflows/intlayer-translate.yml"
|
|
111
|
-
name: Intlayer
|
|
111
|
+
name: Compilazione Automatica Intlayer
|
|
112
|
+
# Condizioni di attivazione per questo workflow
|
|
112
113
|
on:
|
|
113
|
-
push:
|
|
114
|
-
branches: [ main ]
|
|
115
|
-
paths:
|
|
116
|
-
- 'src/**'
|
|
117
114
|
pull_request:
|
|
118
|
-
branches:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
branches:
|
|
116
|
+
- "main"
|
|
117
|
+
|
|
118
|
+
permissions:
|
|
119
|
+
contents: write
|
|
120
|
+
pull-requests: write
|
|
122
121
|
|
|
123
122
|
concurrency:
|
|
124
|
-
group:
|
|
123
|
+
group: "autofill-${{ github.ref }}"
|
|
125
124
|
cancel-in-progress: true
|
|
126
125
|
|
|
127
126
|
jobs:
|
|
128
127
|
autofill:
|
|
129
128
|
runs-on: ubuntu-latest
|
|
130
129
|
env:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
# OpenAI
|
|
131
|
+
AI_MODEL: openai
|
|
132
|
+
AI_PROVIDER: gpt-5-mini
|
|
133
|
+
AI_API_KEY: ${{ secrets.AI_API_KEY }}
|
|
134
134
|
|
|
135
135
|
steps:
|
|
136
|
+
# Passo 1: Recupera l'ultima versione del codice dal repository
|
|
136
137
|
- name: ⬇️ Checkout repository
|
|
137
|
-
uses: actions/checkout@
|
|
138
|
+
uses: actions/checkout@v4
|
|
138
139
|
with:
|
|
139
|
-
persist-credentials: true
|
|
140
|
+
persist-credentials: true # Mantieni le credenziali per la creazione delle PR
|
|
141
|
+
fetch-depth: 0 # Ottieni tutta la cronologia git per l'analisi delle differenze
|
|
140
142
|
|
|
143
|
+
# Passo 2: Configura l'ambiente Node.js
|
|
141
144
|
- name: 🟢 Configura Node.js
|
|
142
|
-
uses: actions/setup-node@
|
|
145
|
+
uses: actions/setup-node@v4
|
|
143
146
|
with:
|
|
144
|
-
node-version: 20
|
|
147
|
+
node-version: 20 # Usa Node.js 20 LTS per stabilità
|
|
148
|
+
|
|
149
|
+
# Passo 3: Installa le dipendenze del progetto
|
|
150
|
+
- name: 📦 Installa dipendenze
|
|
151
|
+
run: npm install
|
|
145
152
|
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
# Passo 4: Installa globalmente Intlayer CLI per la gestione delle traduzioni
|
|
154
|
+
- name: 📦 Installa Intlayer
|
|
155
|
+
run: npm install -g intlayer-cli
|
|
148
156
|
|
|
149
|
-
|
|
157
|
+
# Passo 5: Compila il progetto Intlayer per generare i file di traduzione
|
|
158
|
+
- name: ⚙️ Compila progetto Intlayer
|
|
150
159
|
run: npx intlayer build
|
|
151
160
|
|
|
161
|
+
# Passo 6: Usa l'IA per compilare automaticamente le traduzioni mancanti
|
|
152
162
|
- name: 🤖 Compila automaticamente le traduzioni mancanti
|
|
153
|
-
run: npx intlayer fill --git-diff --mode fill
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
run: npx intlayer fill --git-diff --mode fill --provider $AI_PROVIDER --model $AI_MODEL --api-key $AI_API_KEY
|
|
164
|
+
|
|
165
|
+
# Passo 7: Controlla se ci sono modifiche e committale
|
|
166
|
+
- name: � Controlla modifiche
|
|
167
|
+
id: check-changes
|
|
168
|
+
run: |
|
|
169
|
+
if [ -n "$(git status --porcelain)" ]; then
|
|
170
|
+
echo "has-changes=true" >> $GITHUB_OUTPUT
|
|
171
|
+
else
|
|
172
|
+
echo "has-changes=false" >> $GITHUB_OUTPUT
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
# Passo 8: Commit e push delle modifiche se presenti
|
|
176
|
+
- name: 📤 Commit e push delle modifiche
|
|
177
|
+
if: steps.check-changes.outputs.has-changes == 'true'
|
|
178
|
+
run: |
|
|
179
|
+
git config --local user.email "action@github.com"
|
|
180
|
+
git config --local user.name "GitHub Action"
|
|
181
|
+
git add .
|
|
182
|
+
git commit -m "chore: compila automaticamente le traduzioni mancanti [skip ci]"
|
|
183
|
+
git push origin HEAD:${{ github.head_ref }}
|
|
162
184
|
```
|
|
163
185
|
|
|
164
|
-
|
|
186
|
+
Per configurare le variabili d'ambiente, vai su GitHub → Impostazioni → Segreti e variabili → Azioni e aggiungi il segreto .
|
|
187
|
+
|
|
188
|
+
> Come per Husky, nel caso di un monorepo, puoi usare l'argomento `--base-dir` per trattare sequenzialmente ogni app.
|
|
165
189
|
|
|
166
|
-
> Per impostazione predefinita, l'argomento `--git-diff` filtra i dizionari che includono modifiche dalla base (default `origin/main`) al
|
|
190
|
+
> Per impostazione predefinita, l'argomento `--git-diff` filtra i dizionari che includono modifiche dalla base (default `origin/main`) al ramo corrente (default: `HEAD`).
|
|
167
191
|
|
|
168
192
|
> Per maggiori informazioni sui comandi CLI di Intlayer e sul loro utilizzo, consulta la [documentazione CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_cli.md).
|
|
169
193
|
|
|
170
|
-
## Cronologia
|
|
194
|
+
## Cronologia del documento
|
|
171
195
|
|
|
172
|
-
|
|
196
|
+
| Versione | Data | Modifiche |
|
|
197
|
+
| -------- | ---------- | ------------------------- |
|
|
198
|
+
| 5.5.10 | 2025-06-29 | Inizializza la cronologia |
|