@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,435 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-08-11
|
|
3
|
+
updatedAt: 2025-08-11
|
|
4
|
+
title: Prise en main d'Intlayer avec TanStack Start (React)
|
|
5
|
+
description: Ajoutez l'internationalisation à votre application TanStack Start avec Intlayer — dictionnaires au niveau des composants, URLs localisées et métadonnées optimisées pour le SEO.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internationalisation
|
|
8
|
+
- Documentation
|
|
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
|
+
# Prise en main de l'internationalisation (i18n) avec Intlayer et TanStack Start (React)
|
|
22
|
+
|
|
23
|
+
## Qu'est-ce qu'Intlayer ?
|
|
24
|
+
|
|
25
|
+
**Intlayer** est une boîte à outils open-source d'internationalisation pour les applications React. Elle vous offre :
|
|
26
|
+
|
|
27
|
+
- **Dictionnaires locaux aux composants** avec la sécurité de TypeScript.
|
|
28
|
+
- **Métadonnées et routes dynamiques** (prêtes pour le SEO).
|
|
29
|
+
- **Changement de locale à l'exécution** (et helpers pour détecter/persister les locales).
|
|
30
|
+
- **Plugin Vite** pour les transformations au moment de la build + expérience développeur améliorée.
|
|
31
|
+
|
|
32
|
+
Ce guide montre comment intégrer Intlayer dans un projet **TanStack Start** (qui utilise Vite en interne et TanStack Router pour le routage/SSR).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Étape 1 : Installer les dépendances
|
|
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** : cœur (configuration, dictionnaires, CLI/transformations).
|
|
53
|
+
- **react-intlayer** : `<IntlayerProvider>` + hooks pour React.
|
|
54
|
+
- **vite-intlayer** : plugin Vite, plus middleware optionnel pour la détection/redirection de locale (fonctionne en dev & SSR/preview ; déplacer dans `dependencies` pour le SSR en production).
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Étape 2 : Configurer Intlayer
|
|
59
|
+
|
|
60
|
+
Créez `intlayer.config.ts` à la racine de votre projet :
|
|
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
|
+
// Vous pouvez aussi ajuster : contentDir, contentFileExtensions, options du middleware, etc.
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default config;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Les variantes CommonJS/ESM sont identiques à votre doc originale si vous préférez `cjs`/`mjs`.
|
|
77
|
+
|
|
78
|
+
> Référence complète de la configuration : voir la documentation de configuration d’Intlayer.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Étape 3 : Ajouter le plugin Vite (et middleware optionnel)
|
|
83
|
+
|
|
84
|
+
**TanStack Start utilise Vite**, donc ajoutez le(s) plugin(s) d’Intlayer dans votre `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
|
+
// Optionnel mais recommandé pour la détection de la locale, les cookies et les redirections :
|
|
96
|
+
intLayerMiddlewarePlugin(),
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
> Si vous déployez en SSR, déplacez `vite-intlayer` dans les `dependencies` pour que le middleware fonctionne en production.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Étape 4 : Déclarez Votre Contenu
|
|
106
|
+
|
|
107
|
+
Placez vos dictionnaires n'importe où sous `./src` (contentDir par défaut). Exemple :
|
|
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
|
+
Edit <code>src/routes/index.tsx</code> and save to test HMR
|
|
128
|
+
</>
|
|
129
|
+
),
|
|
130
|
+
fr: (
|
|
131
|
+
<>
|
|
132
|
+
Éditez <code>src/routes/index.tsx</code> et enregistrez pour tester
|
|
133
|
+
HMR
|
|
134
|
+
</>
|
|
135
|
+
),
|
|
136
|
+
es: (
|
|
137
|
+
<>
|
|
138
|
+
Edita <code>src/routes/index.tsx</code> y guarda para probar HMR
|
|
139
|
+
</>
|
|
140
|
+
),
|
|
141
|
+
}),
|
|
142
|
+
readTheDocs: t({
|
|
143
|
+
en: "Cliquez sur les logos pour en savoir plus",
|
|
144
|
+
fr: "Cliquez sur les logos pour en savoir plus",
|
|
145
|
+
es: "Haz clic en los logotipos para saber más",
|
|
146
|
+
}),
|
|
147
|
+
},
|
|
148
|
+
} satisfies Dictionary;
|
|
149
|
+
|
|
150
|
+
export default appContent;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Les variantes JSON/ESM/CJS fonctionnent de la même manière que dans votre document original.
|
|
154
|
+
|
|
155
|
+
> Contenu TSX ? N’oubliez pas `import React from "react"` si votre configuration en a besoin.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Étape 5 : Envelopper TanStack Start avec Intlayer
|
|
160
|
+
|
|
161
|
+
Avec TanStack Start, votre **route racine** est l’endroit idéal pour définir les fournisseurs.
|
|
162
|
+
|
|
163
|
+
```tsx fileName="src/routes/__root.tsx"
|
|
164
|
+
import {
|
|
165
|
+
Outlet,
|
|
166
|
+
createRootRoute,
|
|
167
|
+
Link as RouterLink,
|
|
168
|
+
} from "@tanstack/react-router";
|
|
169
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
170
|
+
|
|
171
|
+
function AppShell() {
|
|
172
|
+
// Exemple d’utilisation d’un dictionnaire au niveau supérieur :
|
|
173
|
+
const content = useIntlayer("app");
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<div>
|
|
177
|
+
<nav className="flex gap-3 p-3">
|
|
178
|
+
<RouterLink to="/">Accueil</RouterLink>
|
|
179
|
+
<RouterLink to="/about">À propos</RouterLink>
|
|
180
|
+
</nav>
|
|
181
|
+
<main className="p-6">
|
|
182
|
+
<h1>{content.title}</h1>
|
|
183
|
+
<Outlet />
|
|
184
|
+
</main>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const Route = createRootRoute({
|
|
190
|
+
component: () => (
|
|
191
|
+
<IntlayerProvider>
|
|
192
|
+
<AppShell />
|
|
193
|
+
</IntlayerProvider>
|
|
194
|
+
),
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Ensuite, utilisez votre contenu dans les pages :
|
|
199
|
+
|
|
200
|
+
```tsx fileName="src/routes/index.tsx"
|
|
201
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
202
|
+
import { useIntlayer } from "react-intlayer";
|
|
203
|
+
import reactLogo from "../assets/react.svg";
|
|
204
|
+
|
|
205
|
+
export const Route = createFileRoute("/")({
|
|
206
|
+
component: () => {
|
|
207
|
+
const content = useIntlayer("app");
|
|
208
|
+
return (
|
|
209
|
+
<>
|
|
210
|
+
<button>{content.count}0</button>
|
|
211
|
+
<p>{content.edit}</p>
|
|
212
|
+
<img
|
|
213
|
+
src={reactLogo}
|
|
214
|
+
alt={content.reactLogo.value}
|
|
215
|
+
width={48}
|
|
216
|
+
height={48}
|
|
217
|
+
/>
|
|
218
|
+
<p className="opacity-70">{content.readTheDocs}</p>
|
|
219
|
+
</>
|
|
220
|
+
);
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
> Les attributs de type chaîne (`alt`, `title`, `aria-label`, …) nécessitent `.value` :
|
|
226
|
+
>
|
|
227
|
+
> ```jsx
|
|
228
|
+
> <img alt={c.reactLogo.value} />
|
|
229
|
+
> ```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## (Optionnel) Étape 6 : Changement de langue (Client)
|
|
234
|
+
|
|
235
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx"
|
|
236
|
+
import { Locales } from "intlayer";
|
|
237
|
+
import { useLocale } from "react-intlayer";
|
|
238
|
+
|
|
239
|
+
export function LocaleSwitcher() {
|
|
240
|
+
const { setLocale } = useLocale();
|
|
241
|
+
return (
|
|
242
|
+
<div className="flex gap-2">
|
|
243
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>English</button>
|
|
244
|
+
<button onClick={() => setLocale(Locales.FRENCH)}>Français</button>
|
|
245
|
+
<button onClick={() => setLocale(Locales.SPANISH)}>Español</button>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## (Optionnel) Étape 7 : Routage localisé (URLs optimisées pour le SEO)
|
|
254
|
+
|
|
255
|
+
Vous avez **deux bons modèles** avec TanStack Start. Choisissez-en un.
|
|
256
|
+
|
|
257
|
+
Créez un dossier de segment dynamique `src/routes/$locale/` pour que vos URLs soient `/:locale/...`. Dans le layout `$locale`, validez le `params.locale`, définissez `<IntlayerProvider locale=...>`, et affichez un `<Outlet />`. Cette approche est simple, mais vous monterez le reste de vos routes sous `$locale`, et vous aurez besoin d’un arbre supplémentaire sans préfixe si vous ne souhaitez pas que la locale par défaut soit préfixée.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## (Optionnel) Étape 8 : Mettre à jour l’URL lors du changement de langue
|
|
262
|
+
|
|
263
|
+
Avec le Modèle A (basepath), changer de langue signifie **naviguer vers un basepath différent** :
|
|
264
|
+
|
|
265
|
+
```tsx fileName="src/components/LocaleSwitcherNavigate.tsx"
|
|
266
|
+
import { useRouter } from "@tanstack/react-router";
|
|
267
|
+
import { Locales, getLocalizedUrl } from "intlayer";
|
|
268
|
+
import { useLocale } from "react-intlayer";
|
|
269
|
+
|
|
270
|
+
export function LocaleSwitcherNavigate() {
|
|
271
|
+
const router = useRouter();
|
|
272
|
+
const { locale, setLocale } = useLocale();
|
|
273
|
+
|
|
274
|
+
const change = async (next: Locales) => {
|
|
275
|
+
if (next === locale) return;
|
|
276
|
+
const nextPath = getLocalizedUrl(
|
|
277
|
+
window.location.pathname + window.location.search,
|
|
278
|
+
next
|
|
279
|
+
);
|
|
280
|
+
await router.navigate({ to: nextPath }); // préserve l’historique
|
|
281
|
+
setLocale(next);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
return (
|
|
285
|
+
<div className="flex gap-2">
|
|
286
|
+
<button onClick={() => change(Locales.ENGLISH)}>English</button>
|
|
287
|
+
<button onClick={() => change(Locales.FRENCH)}>Français</button>
|
|
288
|
+
<button onClick={() => change(Locales.SPANISH)}>Español</button>
|
|
289
|
+
</div>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## (Optionnel) Étape 9 : `<html lang>` et `dir` (Document TanStack Start)
|
|
297
|
+
|
|
298
|
+
TanStack Start expose un **Document** (coquille HTML racine) que vous pouvez personnaliser. Définissez `lang` et `dir` pour l’accessibilité/SEO :
|
|
299
|
+
|
|
300
|
+
```tsx fileName="src/routes/__root.tsx" {4,15}
|
|
301
|
+
import { Outlet, createRootRoute } from "@tanstack/react-router";
|
|
302
|
+
import { IntlayerProvider } from "react.intlayer";
|
|
303
|
+
import { getHTMLTextDir } from "intlayer";
|
|
304
|
+
|
|
305
|
+
function Document({
|
|
306
|
+
locale,
|
|
307
|
+
children,
|
|
308
|
+
}: {
|
|
309
|
+
locale: string;
|
|
310
|
+
children: React.ReactNode;
|
|
311
|
+
}) {
|
|
312
|
+
return (
|
|
313
|
+
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
314
|
+
<head>
|
|
315
|
+
<meta charSet="utf-8" />
|
|
316
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
317
|
+
{/* ... */}
|
|
318
|
+
</head>
|
|
319
|
+
<body>{children}</body>
|
|
320
|
+
</html>
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export const Route = createRootRoute({
|
|
325
|
+
component: () => (
|
|
326
|
+
<IntlayerProvider>
|
|
327
|
+
{/* Si vous calculez la locale côté serveur, transmettez-la dans Document ; sinon le client corrigera après l'hydratation */}
|
|
328
|
+
<Document locale={document?.documentElement?.lang || "en"}>
|
|
329
|
+
<Outlet />
|
|
330
|
+
</Document>
|
|
331
|
+
</IntlayerProvider>
|
|
332
|
+
),
|
|
333
|
+
});
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Pour la correction côté client, vous pouvez aussi conserver votre petit hook :
|
|
337
|
+
|
|
338
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx"
|
|
339
|
+
import { useEffect } from "react";
|
|
340
|
+
import { useLocale } from "react-intlayer";
|
|
341
|
+
import { getHTMLTextDir } from "intlayer";
|
|
342
|
+
|
|
343
|
+
export const useI18nHTMLAttributes = () => {
|
|
344
|
+
const { locale } = useLocale();
|
|
345
|
+
useEffect(() => {
|
|
346
|
+
document.documentElement.lang = locale;
|
|
347
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
348
|
+
}, [locale]);
|
|
349
|
+
};
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## (Optionnel) Étape 10 : Composant Link localisé
|
|
355
|
+
|
|
356
|
+
TanStack Router fournit un `<Link/>`, mais si vous avez besoin d'un simple `<a>` qui préfixe automatiquement les URL internes :
|
|
357
|
+
|
|
358
|
+
```tsx fileName="src/components/Link.tsx"
|
|
359
|
+
import { getLocalizedUrl } from "intlayer";
|
|
360
|
+
import {
|
|
361
|
+
forwardRef,
|
|
362
|
+
type AnchorHTMLAttributes,
|
|
363
|
+
type DetailedHTMLProps,
|
|
364
|
+
} from "react";
|
|
365
|
+
import { useLocale } from "react-intlayer";
|
|
366
|
+
|
|
367
|
+
export interface LinkProps
|
|
368
|
+
extends DetailedHTMLProps<
|
|
369
|
+
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
370
|
+
HTMLAnchorElement
|
|
371
|
+
> {}
|
|
372
|
+
|
|
373
|
+
const isExternal = (href?: string) => /^https?:\/\//.test(href ?? "");
|
|
374
|
+
|
|
375
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
376
|
+
({ href, children, ...props }, ref) => {
|
|
377
|
+
const { locale } = useLocale();
|
|
378
|
+
const hrefI18n =
|
|
379
|
+
href && !isExternal(href) ? getLocalizedUrl(href, locale) : href;
|
|
380
|
+
return (
|
|
381
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
382
|
+
{children}
|
|
383
|
+
</a>
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
Link.displayName = "Link";
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
> Si vous utilisez le Modèle A (basepath), le `<Link to="/about" />` de TanStack résout déjà vers `/fr/about` via `basepath`, donc un lien personnalisé est optionnel.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## TypeScript
|
|
395
|
+
|
|
396
|
+
Inclure les types générés par Intlayer :
|
|
397
|
+
|
|
398
|
+
```json5 fileName="tsconfig.json"
|
|
399
|
+
{
|
|
400
|
+
"include": ["src", ".intlayer/**/*.ts"],
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## Git
|
|
407
|
+
|
|
408
|
+
Ignorer les artefacts générés par Intlayer :
|
|
409
|
+
|
|
410
|
+
```gitignore
|
|
411
|
+
.intlayer
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Extension VS Code
|
|
417
|
+
|
|
418
|
+
- **Extension Intlayer pour VS Code** → autocomplétion, erreurs, aperçus en ligne, actions rapides.
|
|
419
|
+
Marketplace : `intlayer.intlayer-vs-code-extension`
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## Aller Plus Loin
|
|
424
|
+
|
|
425
|
+
- Éditeur Visuel
|
|
426
|
+
- Mode CMS
|
|
427
|
+
- Détection de la locale à la périphérie / adaptateurs
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Historique de la Documentation
|
|
432
|
+
|
|
433
|
+
| Version | Date | Modifications |
|
|
434
|
+
| ------- | ---------- | --------------------------------- |
|
|
435
|
+
| 1.0.0 | 2025-08-11 | Adaptation TanStack Start ajoutée |
|
|
@@ -279,7 +279,6 @@ Le package `next-intlayer` fournit également quelques fonctions pour vous aider
|
|
|
279
279
|
- [`useIntlayer()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/next-intlayer/useIntlayer.md)
|
|
280
280
|
- [`useDictionary()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/next-intlayer/useDictionary.md)
|
|
281
281
|
- [`useLocale()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/next-intlayer/useLocale.md)
|
|
282
|
-
- [`useIntlayerAsync()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/next-intlayer/useIntlayerAsync.md)
|
|
283
282
|
|
|
284
283
|
## Historique de la documentation
|
|
285
284
|
|
|
@@ -273,7 +273,6 @@ Le package `react-intlayer` fournit également plusieurs fonctions pour vous aid
|
|
|
273
273
|
- [`useIntlayer()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/react-intlayer/useIntlayer.md)
|
|
274
274
|
- [`useDictionary()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/react-intlayer/useDictionary.md)
|
|
275
275
|
- [`useLocale()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/react-intlayer/useLocale.md)
|
|
276
|
-
- [`useIntlayerAsync()`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/react-intlayer/useIntlayerAsync.md)
|
|
277
276
|
|
|
278
277
|
## Historique de la documentation
|
|
279
278
|
|
package/docs/hi/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: CI/CD एकीकरण
|
|
5
|
-
description: स्वचालित सामग्री प्रबंधन और परिनियोजन के लिए अपने CI/CD पाइपलाइन में
|
|
5
|
+
description: स्वचालित सामग्री प्रबंधन और परिनियोजन के लिए Intlayer को अपने CI/CD पाइपलाइन में एकीकृत करना सीखें।
|
|
6
6
|
keywords:
|
|
7
7
|
- CI/CD
|
|
8
8
|
- सतत एकीकरण
|
|
@@ -19,13 +19,13 @@ slugs:
|
|
|
19
19
|
|
|
20
20
|
# CI/CD पाइपलाइन में स्वचालित अनुवाद उत्पन्न करें
|
|
21
21
|
|
|
22
|
-
Intlayer
|
|
22
|
+
Intlayer आपके सामग्री घोषणा फ़ाइलों के लिए अनुवादों का स्वचालित उत्पादन करने की अनुमति देता है। आपके कार्यप्रवाह के आधार पर इसे प्राप्त करने के कई तरीके हैं।
|
|
23
23
|
|
|
24
24
|
## CMS का उपयोग करना
|
|
25
25
|
|
|
26
|
-
Intlayer के साथ, आप एक ऐसा कार्यप्रवाह अपना सकते हैं जहाँ केवल एक ही स्थानीय भाषा स्थानीय रूप से घोषित की जाती है, जबकि सभी अनुवाद CMS के माध्यम से दूरस्थ रूप से प्रबंधित किए जाते हैं।
|
|
26
|
+
Intlayer के साथ, आप एक ऐसा कार्यप्रवाह अपना सकते हैं जहाँ केवल एक ही स्थानीय भाषा स्थानीय रूप से घोषित की जाती है, जबकि सभी अनुवाद CMS के माध्यम से दूरस्थ रूप से प्रबंधित किए जाते हैं। यह सामग्री और अनुवादों को कोडबेस से पूरी तरह से अलग करने की अनुमति देता है, जिससे सामग्री संपादकों के लिए अधिक लचीलापन मिलता है और हॉट कंटेंट रीलोडिंग सक्षम होती है (परिवर्तन लागू करने के लिए एप्लिकेशन को पुनः निर्माण करने की आवश्यकता नहीं होती)।
|
|
27
27
|
|
|
28
|
-
### उदाहरण
|
|
28
|
+
### उदाहरण विन्यास
|
|
29
29
|
|
|
30
30
|
```ts fileName="intlayer.config.ts"
|
|
31
31
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -41,11 +41,11 @@ const config: IntlayerConfig = {
|
|
|
41
41
|
|
|
42
42
|
applicationURL: process.env.APPLICATION_URL, // CMS द्वारा उपयोग किया जाने वाला एप्लिकेशन URL
|
|
43
43
|
|
|
44
|
-
clientId: process.env.INTLAYER_CLIENT_ID, // CMS
|
|
44
|
+
clientId: process.env.INTLAYER_CLIENT_ID, // CMS प्रमाणपत्र
|
|
45
45
|
clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
46
46
|
},
|
|
47
47
|
ai: {
|
|
48
|
-
applicationContext: "
|
|
48
|
+
applicationContext: "यह एक परीक्षण एप्लिकेशन है", // सुनिश्चित करता है कि अनुवाद सुसंगत रूप से उत्पन्न हों
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -56,9 +56,9 @@ CMS के बारे में अधिक जानने के लिए,
|
|
|
56
56
|
|
|
57
57
|
## Husky का उपयोग करना
|
|
58
58
|
|
|
59
|
-
आप [Husky](https://typicode.github.io/husky/) का उपयोग करके
|
|
59
|
+
आप अपने स्थानीय Git वर्कफ़्लो में अनुवाद निर्माण को [Husky](https://typicode.github.io/husky/) का उपयोग करके एकीकृत कर सकते हैं।
|
|
60
60
|
|
|
61
|
-
### उदाहरण
|
|
61
|
+
### उदाहरण विन्यास
|
|
62
62
|
|
|
63
63
|
```ts fileName="intlayer.config.ts"
|
|
64
64
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -66,7 +66,7 @@ import { Locales, type IntlayerConfig } from "intlayer";
|
|
|
66
66
|
const config: IntlayerConfig = {
|
|
67
67
|
internationalization: {
|
|
68
68
|
locales: [Locales.ENGLISH, Locales.SPANISH, Locales.FRENCH],
|
|
69
|
-
requiredLocales: [Locales.ENGLISH], // वैकल्पिक
|
|
69
|
+
requiredLocales: [Locales.ENGLISH], // वैकल्पिक लोकल दूरस्थ रूप से संभाले जाते हैं
|
|
70
70
|
defaultLocale: Locales.ENGLISH,
|
|
71
71
|
},
|
|
72
72
|
editor: {
|
|
@@ -75,9 +75,9 @@ const config: IntlayerConfig = {
|
|
|
75
75
|
},
|
|
76
76
|
ai: {
|
|
77
77
|
provider: "openai",
|
|
78
|
-
apiKey: process.env.OPENAI_API_KEY, // अपना API कुंजी उपयोग करें
|
|
78
|
+
apiKey: process.env.OPENAI_API_KEY, // अपना स्वयं का API कुंजी उपयोग करें
|
|
79
79
|
|
|
80
|
-
applicationContext: "
|
|
80
|
+
applicationContext: "यह एक परीक्षण एप्लिकेशन है", // सुनिश्चित करता है कि अनुवाद सुसंगत रूप से उत्पन्न हों
|
|
81
81
|
},
|
|
82
82
|
};
|
|
83
83
|
|
|
@@ -108,61 +108,84 @@ npx intlayer fill --base-dir ./app2 --unpushed --mode fill
|
|
|
108
108
|
Intlayer एक CLI कमांड प्रदान करता है जो शब्दकोश सामग्री को स्वचालित रूप से भरने और समीक्षा करने के लिए है। इसे GitHub Actions का उपयोग करके आपके CI/CD वर्कफ़्लो में एकीकृत किया जा सकता है।
|
|
109
109
|
|
|
110
110
|
```yaml fileName=".github/workflows/intlayer-translate.yml"
|
|
111
|
-
name: Intlayer
|
|
111
|
+
name: Intlayer ऑटो-फिल
|
|
112
|
+
# इस वर्कफ़्लो के लिए ट्रिगर शर्तें
|
|
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
|
+
# चरण 1: रिपॉजिटरी से नवीनतम कोड प्राप्त करें
|
|
136
137
|
- name: ⬇️ रिपॉजिटरी चेकआउट करें
|
|
137
|
-
uses: actions/checkout@
|
|
138
|
+
uses: actions/checkout@v4
|
|
138
139
|
with:
|
|
139
|
-
persist-credentials: true
|
|
140
|
+
persist-credentials: true # PRs बनाने के लिए क्रेडेंशियल्स रखें
|
|
141
|
+
fetch-depth: 0 # डिफ़ एनालिसिस के लिए पूरी गिट हिस्ट्री प्राप्त करें
|
|
140
142
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
# चरण 2: Node.js पर्यावरण सेट करें
|
|
144
|
+
- name: 🟢 Node.js सेट करें
|
|
145
|
+
uses: actions/setup-node@v4
|
|
143
146
|
with:
|
|
144
|
-
node-version: 20
|
|
147
|
+
node-version: 20 # स्थिरता के लिए Node.js 20 LTS का उपयोग करें
|
|
148
|
+
|
|
149
|
+
# चरण 3: प्रोजेक्ट निर्भरताएँ इंस्टॉल करें
|
|
150
|
+
- name: 📦 निर्भरताएँ इंस्टॉल करें
|
|
151
|
+
run: npm install
|
|
145
152
|
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
# चरण 4: अनुवाद प्रबंधन के लिए Intlayer CLI को ग्लोबली इंस्टॉल करें
|
|
154
|
+
- name: 📦 Intlayer इंस्टॉल करें
|
|
155
|
+
run: npm install -g intlayer-cli
|
|
148
156
|
|
|
157
|
+
# चरण 5: अनुवाद फ़ाइलें उत्पन्न करने के लिए Intlayer प्रोजेक्ट बनाएं
|
|
149
158
|
- name: ⚙️ Intlayer प्रोजेक्ट बनाएं
|
|
150
159
|
run: npx intlayer build
|
|
151
160
|
|
|
161
|
+
# चरण 6: AI का उपयोग करके स्वचालित रूप से गायब अनुवाद भरें
|
|
152
162
|
- name: 🤖 गायब अनुवादों को स्वचालित रूप से भरें
|
|
153
|
-
run: npx intlayer fill --git-diff --mode fill
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
run: npx intlayer fill --git-diff --mode fill --provider $AI_PROVIDER --model $AI_MODEL --api-key $AI_API_KEY
|
|
164
|
+
|
|
165
|
+
# चरण 7: जांचें कि क्या कोई परिवर्तन हैं और उन्हें कमिट करें
|
|
166
|
+
- name: � परिवर्तनों के लिए जांच करें
|
|
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
|
+
# चरण 8: यदि कोई परिवर्तन हैं तो उन्हें कमिट और पुश करें
|
|
176
|
+
- name: 📤 परिवर्तन कमिट और पुश करें
|
|
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: गायब अनुवादों को स्वचालित रूप से भरें [skip ci]"
|
|
183
|
+
git push origin HEAD:${{ github.head_ref }}
|
|
163
184
|
```
|
|
164
185
|
|
|
165
|
-
|
|
186
|
+
पर्यावरण चर सेट करने के लिए, GitHub → Settings → Secrets and variables → Actions पर जाएं और सीक्रेट जोड़ें।
|
|
187
|
+
|
|
188
|
+
> Husky के समान, मोनोरिपो के मामले में, आप प्रत्येक ऐप को क्रमिक रूप से संसाधित करने के लिए `--base-dir` तर्क का उपयोग कर सकते हैं।
|
|
166
189
|
|
|
167
190
|
> डिफ़ॉल्ट रूप से, `--git-diff` तर्क उन शब्दकोशों को फ़िल्टर करता है जिनमें बेस (डिफ़ॉल्ट `origin/main`) से वर्तमान शाखा (डिफ़ॉल्ट: `HEAD`) तक के परिवर्तन शामिल होते हैं।
|
|
168
191
|
|
|
@@ -170,4 +193,6 @@ jobs:
|
|
|
170
193
|
|
|
171
194
|
## दस्तावेज़ इतिहास
|
|
172
195
|
|
|
173
|
-
|
|
196
|
+
| संस्करण | दिनांक | परिवर्तन |
|
|
197
|
+
| ------- | ---------- | ------------------- |
|
|
198
|
+
| 5.5.10 | 2025-06-29 | इतिहास प्रारंभ करें |
|