@intlayer/docs 7.5.9 → 7.5.10
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/README.md +9 -2
- package/dist/cjs/generated/docs.entry.cjs +19 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +19 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/cli/push.md +1 -1
- package/docs/ar/configuration.md +3 -3
- package/docs/ar/interest_of_intlayer.md +1 -1
- package/docs/ar/intlayer_CMS.md +5 -5
- package/docs/ar/intlayer_with_express.md +1 -0
- package/docs/ar/intlayer_with_fastify.md +516 -0
- package/docs/ar/readme.md +1 -1
- package/docs/de/cli/push.md +1 -1
- package/docs/de/configuration.md +3 -3
- package/docs/de/interest_of_intlayer.md +1 -1
- package/docs/de/intlayer_CMS.md +5 -5
- package/docs/de/intlayer_with_express.md +1 -0
- package/docs/de/intlayer_with_fastify.md +449 -0
- package/docs/de/readme.md +1 -1
- package/docs/en/cli/push.md +1 -1
- package/docs/en/configuration.md +3 -3
- package/docs/en/interest_of_intlayer.md +1 -1
- package/docs/en/intlayer_CMS.md +5 -5
- package/docs/en/intlayer_with_express.md +1 -0
- package/docs/en/intlayer_with_fastify.md +439 -0
- package/docs/en/readme.md +3 -1
- package/docs/en-GB/cli/push.md +1 -1
- package/docs/en-GB/configuration.md +3 -3
- package/docs/en-GB/interest_of_intlayer.md +1 -1
- package/docs/en-GB/intlayer_CMS.md +5 -5
- package/docs/en-GB/intlayer_with_express.md +1 -0
- package/docs/en-GB/intlayer_with_fastify.md +445 -0
- package/docs/en-GB/readme.md +3 -1
- package/docs/es/cli/push.md +1 -1
- package/docs/es/configuration.md +3 -3
- package/docs/es/interest_of_intlayer.md +1 -1
- package/docs/es/intlayer_CMS.md +5 -5
- package/docs/es/intlayer_with_express.md +1 -0
- package/docs/es/intlayer_with_fastify.md +480 -0
- package/docs/es/readme.md +1 -1
- package/docs/fr/cli/push.md +1 -1
- package/docs/fr/configuration.md +3 -3
- package/docs/fr/interest_of_intlayer.md +1 -1
- package/docs/fr/intlayer_CMS.md +5 -5
- package/docs/fr/intlayer_with_express.md +1 -0
- package/docs/fr/intlayer_with_fastify.md +439 -0
- package/docs/fr/readme.md +1 -1
- package/docs/hi/cli/push.md +1 -1
- package/docs/hi/configuration.md +3 -3
- package/docs/hi/interest_of_intlayer.md +1 -1
- package/docs/hi/intlayer_CMS.md +5 -5
- package/docs/hi/intlayer_with_express.md +1 -0
- package/docs/hi/intlayer_with_fastify.md +540 -0
- package/docs/hi/readme.md +1 -1
- package/docs/id/cli/push.md +1 -1
- package/docs/id/configuration.md +3 -3
- package/docs/id/interest_of_intlayer.md +1 -1
- package/docs/id/intlayer_CMS.md +5 -5
- package/docs/id/intlayer_with_express.md +1 -0
- package/docs/id/intlayer_with_fastify.md +470 -0
- package/docs/id/readme.md +1 -1
- package/docs/it/cli/push.md +1 -1
- package/docs/it/configuration.md +3 -3
- package/docs/it/interest_of_intlayer.md +1 -1
- package/docs/it/intlayer_CMS.md +5 -5
- package/docs/it/intlayer_with_express.md +1 -0
- package/docs/it/intlayer_with_fastify.md +445 -0
- package/docs/it/readme.md +1 -1
- package/docs/ja/cli/push.md +1 -1
- package/docs/ja/configuration.md +3 -3
- package/docs/ja/interest_of_intlayer.md +1 -1
- package/docs/ja/intlayer_CMS.md +5 -5
- package/docs/ja/intlayer_with_express.md +1 -0
- package/docs/ja/intlayer_with_fastify.md +516 -0
- package/docs/ja/readme.md +1 -1
- package/docs/ko/cli/push.md +1 -1
- package/docs/ko/configuration.md +3 -3
- package/docs/ko/interest_of_intlayer.md +1 -1
- package/docs/ko/intlayer_CMS.md +5 -5
- package/docs/ko/intlayer_with_express.md +1 -0
- package/docs/ko/intlayer_with_fastify.md +463 -0
- package/docs/ko/readme.md +1 -1
- package/docs/pl/cli/push.md +1 -1
- package/docs/pl/configuration.md +3 -3
- package/docs/pl/interest_of_intlayer.md +1 -1
- package/docs/pl/intlayer_CMS.md +5 -5
- package/docs/pl/intlayer_with_express.md +1 -0
- package/docs/pl/intlayer_with_fastify.md +457 -0
- package/docs/pl/readme.md +1 -1
- package/docs/pt/cli/push.md +1 -1
- package/docs/pt/configuration.md +3 -3
- package/docs/pt/interest_of_intlayer.md +1 -1
- package/docs/pt/intlayer_CMS.md +5 -5
- package/docs/pt/intlayer_with_express.md +1 -0
- package/docs/pt/intlayer_with_fastify.md +502 -0
- package/docs/pt/readme.md +1 -1
- package/docs/ru/cli/push.md +1 -1
- package/docs/ru/configuration.md +3 -3
- package/docs/ru/interest_of_intlayer.md +1 -1
- package/docs/ru/intlayer_CMS.md +5 -5
- package/docs/ru/intlayer_with_express.md +1 -0
- package/docs/ru/intlayer_with_fastify.md +468 -0
- package/docs/ru/readme.md +1 -1
- package/docs/tr/cli/push.md +1 -1
- package/docs/tr/configuration.md +3 -3
- package/docs/tr/interest_of_intlayer.md +1 -1
- package/docs/tr/intlayer_CMS.md +5 -5
- package/docs/tr/intlayer_with_express.md +1 -0
- package/docs/tr/intlayer_with_fastify.md +471 -0
- package/docs/tr/readme.md +1 -1
- package/docs/vi/cli/push.md +1 -1
- package/docs/vi/configuration.md +3 -3
- package/docs/vi/interest_of_intlayer.md +1 -1
- package/docs/vi/intlayer_CMS.md +5 -5
- package/docs/vi/intlayer_with_express.md +1 -0
- package/docs/vi/intlayer_with_fastify.md +490 -0
- package/docs/vi/readme.md +1 -1
- package/docs/zh/cli/push.md +1 -1
- package/docs/zh/configuration.md +3 -3
- package/docs/zh/interest_of_intlayer.md +1 -1
- package/docs/zh/intlayer_CMS.md +5 -5
- package/docs/zh/intlayer_with_express.md +1 -0
- package/docs/zh/intlayer_with_fastify.md +451 -0
- package/docs/zh/readme.md +1 -1
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +19 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-12-30
|
|
3
|
+
updatedAt: 2025-12-30
|
|
4
|
+
title: Comment traduire votre backend Fastify – guide i18n 2026
|
|
5
|
+
description: Découvrez comment rendre votre backend Fastify multilingue. Suivez la documentation pour internationaliser (i18n) et traduire.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internationalisation
|
|
8
|
+
- Documentation
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Fastify
|
|
11
|
+
- JavaScript
|
|
12
|
+
- Backend
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- environment
|
|
16
|
+
- fastify
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-fastify-template
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.6.0
|
|
20
|
+
date: 2025-12-31
|
|
21
|
+
changes: Ajout de la commande init
|
|
22
|
+
- version: 7.6.0
|
|
23
|
+
date: 2025-12-31
|
|
24
|
+
changes: Historique initial
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Traduire votre backend Fastify avec Intlayer | Internationalisation (i18n)
|
|
28
|
+
|
|
29
|
+
`fastify-intlayer` est un puissant plugin d'internationalisation (i18n) pour les applications Fastify, conçu pour rendre vos services backend accessibles à l'international en fournissant des réponses localisées selon les préférences du client.
|
|
30
|
+
|
|
31
|
+
### Cas d'utilisation pratiques
|
|
32
|
+
|
|
33
|
+
- **Afficher les erreurs backend dans la langue de l'utilisateur** : Lorsqu'une erreur survient, afficher des messages dans la langue maternelle de l'utilisateur améliore la compréhension et réduit la frustration. Cela est particulièrement utile pour les messages d'erreur dynamiques qui peuvent être affichés dans des composants frontend tels que des toasts ou des modals.
|
|
34
|
+
- **Récupération de contenu multilingue** : Pour les applications récupérant du contenu depuis une base de données, l'internationalisation garantit que vous pouvez servir ce contenu en plusieurs langues. Ceci est crucial pour des plateformes comme les sites e-commerce ou les systèmes de gestion de contenu qui doivent afficher des descriptions de produits, des articles et autres contenus dans la langue préférée de l'utilisateur.
|
|
35
|
+
- **Envoi d'e-mails multilingues** : Qu'il s'agisse d'e-mails transactionnels, de campagnes marketing ou de notifications, l'envoi d'e-mails dans la langue du destinataire peut augmenter significativement l'engagement et l'efficacité.
|
|
36
|
+
- **Notifications push multilingues** : Pour les applications mobiles, l'envoi de push notifications dans la langue préférée de l'utilisateur peut améliorer l'interaction et la rétention. Cette touche personnelle peut rendre les notifications plus pertinentes et plus engageantes.
|
|
37
|
+
- **Autres communications** : Toute forme de communication émanant du backend, comme les SMS, les alertes système ou les mises à jour de l'interface utilisateur, bénéficie d'être dans la langue de l'utilisateur, garantissant la clarté et améliorant l'expérience utilisateur globale.
|
|
38
|
+
|
|
39
|
+
En internationalisant le backend, votre application non seulement respecte les différences culturelles mais s'aligne également mieux sur les besoins du marché mondial, ce qui en fait une étape clé pour étendre vos services à l'échelle mondiale.
|
|
40
|
+
|
|
41
|
+
## Prise en main
|
|
42
|
+
|
|
43
|
+
### Installation
|
|
44
|
+
|
|
45
|
+
Pour commencer à utiliser `fastify-intlayer`, installez le package en utilisant npm :
|
|
46
|
+
|
|
47
|
+
```bash packageManager="npm"
|
|
48
|
+
npm install intlayer fastify-intlayer
|
|
49
|
+
npx intlayer init
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```bash packageManager="pnpm"
|
|
54
|
+
pnpm add intlayer fastify-intlayer
|
|
55
|
+
pnpm intlayer init
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```bash packageManager="yarn"
|
|
60
|
+
yarn add intlayer fastify-intlayer
|
|
61
|
+
yarn intlayer init
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```bash packageManager="bun"
|
|
66
|
+
bun add intlayer fastify-intlayer
|
|
67
|
+
bunx intlayer init
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Configuration
|
|
72
|
+
|
|
73
|
+
Configurez les paramètres d'internationalisation en créant un fichier `intlayer.config.ts` à la racine de votre projet :
|
|
74
|
+
|
|
75
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
76
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
77
|
+
|
|
78
|
+
const config: IntlayerConfig = {
|
|
79
|
+
internationalization: {
|
|
80
|
+
locales: [
|
|
81
|
+
Locales.ENGLISH,
|
|
82
|
+
Locales.FRENCH,
|
|
83
|
+
Locales.SPANISH_MEXICO,
|
|
84
|
+
Locales.SPANISH_SPAIN,
|
|
85
|
+
],
|
|
86
|
+
defaultLocale: Locales.ENGLISH,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default config;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
94
|
+
import { Locales } from "intlayer";
|
|
95
|
+
|
|
96
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
97
|
+
const config = {
|
|
98
|
+
internationalization: {
|
|
99
|
+
locales: [
|
|
100
|
+
Locales.ENGLISH,
|
|
101
|
+
Locales.FRENCH,
|
|
102
|
+
Locales.SPANISH_MEXICO,
|
|
103
|
+
Locales.SPANISH_SPAIN,
|
|
104
|
+
],
|
|
105
|
+
defaultLocale: Locales.ENGLISH,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default config;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
113
|
+
const { Locales } = require("intlayer");
|
|
114
|
+
|
|
115
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
116
|
+
const config = {
|
|
117
|
+
internationalization: {
|
|
118
|
+
locales: [
|
|
119
|
+
Locales.ENGLISH,
|
|
120
|
+
Locales.FRENCH,
|
|
121
|
+
Locales.SPANISH_MEXICO,
|
|
122
|
+
Locales.SPANISH_SPAIN,
|
|
123
|
+
],
|
|
124
|
+
defaultLocale: Locales.ENGLISH,
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
module.exports = config;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Déclarez votre contenu
|
|
132
|
+
|
|
133
|
+
Créez et gérez vos déclarations de contenu pour stocker les traductions :
|
|
134
|
+
|
|
135
|
+
```typescript fileName="src/index.content.ts" contentDeclarationFormat="typescript"
|
|
136
|
+
import { t, type Dictionary } from "intlayer";
|
|
137
|
+
|
|
138
|
+
const indexContent = {
|
|
139
|
+
key: "index",
|
|
140
|
+
content: {
|
|
141
|
+
exampleOfContent: t({
|
|
142
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
143
|
+
en: "Example of returned content in English",
|
|
144
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
145
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
146
|
+
}),
|
|
147
|
+
},
|
|
148
|
+
} satisfies Dictionary;
|
|
149
|
+
|
|
150
|
+
export default indexContent;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
```javascript fileName="src/index.content.mjs" contentDeclarationFormat="esm"
|
|
154
|
+
import { t } from "intlayer";
|
|
155
|
+
|
|
156
|
+
/** @type {import('intlayer').Dictionary} */
|
|
157
|
+
const indexContent = {
|
|
158
|
+
key: "index",
|
|
159
|
+
content: {
|
|
160
|
+
exampleOfContent: t({
|
|
161
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
162
|
+
en: "Example of returned content in English",
|
|
163
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
164
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
165
|
+
}),
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export default indexContent;
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```javascript fileName="src/index.content.cjs" contentDeclarationFormat="commonjs"
|
|
173
|
+
const { t } = require("intlayer");
|
|
174
|
+
|
|
175
|
+
/** @type {import('intlayer').Dictionary} */
|
|
176
|
+
const indexContent = {
|
|
177
|
+
key: "index",
|
|
178
|
+
content: {
|
|
179
|
+
exampleOfContent: t({
|
|
180
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
181
|
+
en: "Example of returned content in English",
|
|
182
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
183
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
184
|
+
}),
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
module.exports = indexContent;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
```json fileName="src/index.content.json" contentDeclarationFormat="json"
|
|
192
|
+
{
|
|
193
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
194
|
+
"key": "index",
|
|
195
|
+
"content": {
|
|
196
|
+
"exampleOfContent": {
|
|
197
|
+
"nodeType": "translation",
|
|
198
|
+
"translation": {
|
|
199
|
+
"en": "Example of returned content in English",
|
|
200
|
+
"fr": "Exemple de contenu renvoyé en français",
|
|
201
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
202
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
> Vos déclarations de contenu peuvent être définies n'importe où dans votre application dès qu'elles sont incluses dans le répertoire `contentDir` (par défaut, `./src`). Et doivent correspondre à l'extension de fichier des déclarations de contenu (par défaut, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
210
|
+
|
|
211
|
+
> Pour plus de détails, référez-vous à la [documentation sur les déclarations de contenu](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/content_file.md).
|
|
212
|
+
|
|
213
|
+
### Configuration de l'application Fastify
|
|
214
|
+
|
|
215
|
+
Configurez votre application Fastify pour utiliser `fastify-intlayer` :
|
|
216
|
+
|
|
217
|
+
```typescript fileName="src/index.ts" codeFormat="typescript"
|
|
218
|
+
import Fastify from "fastify";
|
|
219
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
220
|
+
import dictionaryExample from "./index.content";
|
|
221
|
+
|
|
222
|
+
const fastify = Fastify({ logger: true });
|
|
223
|
+
|
|
224
|
+
// Charger le plugin d'internationalisation
|
|
225
|
+
await fastify.register(intlayer);
|
|
226
|
+
|
|
227
|
+
// Routes
|
|
228
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
229
|
+
return t({
|
|
230
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
231
|
+
en: "Example of returned content in English",
|
|
232
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
233
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
238
|
+
return getIntlayer("index").exampleOfContent;
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
242
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Démarrer le serveur
|
|
246
|
+
const start = async () => {
|
|
247
|
+
try {
|
|
248
|
+
await fastify.listen({ port: 3000 });
|
|
249
|
+
} catch (err) {
|
|
250
|
+
fastify.log.error(err);
|
|
251
|
+
process.exit(1);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
start();
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
```javascript fileName="src/index.mjs" codeFormat="esm"
|
|
259
|
+
import Fastify from "fastify";
|
|
260
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
261
|
+
import dictionaryExample from "./index.content";
|
|
262
|
+
|
|
263
|
+
const fastify = Fastify({ logger: true });
|
|
264
|
+
|
|
265
|
+
// Charger le plugin d'internationalisation
|
|
266
|
+
await fastify.register(intlayer);
|
|
267
|
+
|
|
268
|
+
// Définition des routes
|
|
269
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
270
|
+
return t({
|
|
271
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
272
|
+
en: "Example of returned content in English",
|
|
273
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
274
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
279
|
+
return getIntlayer("index").exampleOfContent;
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
283
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// Démarrer le serveur
|
|
287
|
+
const start = async () => {
|
|
288
|
+
try {
|
|
289
|
+
await fastify.listen({ port: 3000 });
|
|
290
|
+
} catch (err) {
|
|
291
|
+
fastify.log.error(err);
|
|
292
|
+
process.exit(1);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
start();
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
```javascript fileName="src/index.cjs" codeFormat="commonjs"
|
|
300
|
+
const Fastify = require("fastify");
|
|
301
|
+
const { intlayer, t, getDictionary, getIntlayer } = require("fastify-intlayer");
|
|
302
|
+
const dictionaryExample = require("./index.content");
|
|
303
|
+
|
|
304
|
+
const fastify = Fastify({ logger: true });
|
|
305
|
+
|
|
306
|
+
// Wrapper de démarrage du serveur pour async/await
|
|
307
|
+
const start = async () => {
|
|
308
|
+
try {
|
|
309
|
+
// Charger le plugin d'internationalisation
|
|
310
|
+
await fastify.register(intlayer);
|
|
311
|
+
|
|
312
|
+
// Routes
|
|
313
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
314
|
+
return t({
|
|
315
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
316
|
+
en: "Example of returned content in English",
|
|
317
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
318
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
323
|
+
return getIntlayer("index").exampleOfContent;
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
327
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
await fastify.listen({ port: 3000 });
|
|
331
|
+
} catch (err) {
|
|
332
|
+
fastify.log.error(err);
|
|
333
|
+
process.exit(1);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
start();
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Compatibilité
|
|
341
|
+
|
|
342
|
+
`fastify-intlayer` est entièrement compatible avec :
|
|
343
|
+
|
|
344
|
+
- [`react-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/react-intlayer/index.md) pour les applications React
|
|
345
|
+
- [`next-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/next-intlayer/index.md) pour les applications Next.js
|
|
346
|
+
- [`vite-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/packages/vite-intlayer/index.md) pour les applications Vite
|
|
347
|
+
|
|
348
|
+
Il fonctionne également de manière transparente avec n'importe quelle solution d'internationalisation dans divers environnements, y compris les navigateurs et les requêtes d'API. Vous pouvez personnaliser le middleware pour détecter la locale via les en-têtes ou les cookies :
|
|
349
|
+
|
|
350
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
351
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
352
|
+
|
|
353
|
+
const config: IntlayerConfig = {
|
|
354
|
+
// ... Autres options de configuration
|
|
355
|
+
middleware: {
|
|
356
|
+
headerName: "my-locale-header",
|
|
357
|
+
cookieName: "my-locale-cookie",
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export default config;
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
365
|
+
import { Locales } from "intlayer";
|
|
366
|
+
|
|
367
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
368
|
+
const config = {
|
|
369
|
+
// ... Autres options de configuration
|
|
370
|
+
middleware: {
|
|
371
|
+
headerName: "my-locale-header",
|
|
372
|
+
cookieName: "my-locale-cookie",
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export default config;
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
380
|
+
const { Locales } = require("intlayer");
|
|
381
|
+
|
|
382
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
383
|
+
const config = {
|
|
384
|
+
// ... Autres options de configuration
|
|
385
|
+
middleware: {
|
|
386
|
+
headerName: "my-locale-header",
|
|
387
|
+
cookieName: "my-locale-cookie",
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
module.exports = config;
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Par défaut, `fastify-intlayer` interprétera l'en-tête `Accept-Language` pour déterminer la langue préférée du client.
|
|
395
|
+
|
|
396
|
+
> Pour plus d'informations sur la configuration et les sujets avancés, consultez notre [documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/configuration.md).
|
|
397
|
+
|
|
398
|
+
### Configurer TypeScript
|
|
399
|
+
|
|
400
|
+
`fastify-intlayer` exploite les capacités robustes de TypeScript pour améliorer le processus d'internationalisation. Le typage statique de TypeScript garantit que chaque clé de traduction est prise en compte, réduisant le risque de traductions manquantes et améliorant la maintenabilité.
|
|
401
|
+
|
|
402
|
+
Assurez-vous que les types autogénérés (par défaut dans ./types/intlayer.d.ts) sont inclus dans votre fichier tsconfig.json.
|
|
403
|
+
|
|
404
|
+
```json5 fileName="tsconfig.json"
|
|
405
|
+
{
|
|
406
|
+
// ... Vos configurations TypeScript existantes
|
|
407
|
+
"include": [
|
|
408
|
+
// ... Vos configurations TypeScript existantes
|
|
409
|
+
".intlayer/**/*.ts", // Inclure les types générés automatiquement
|
|
410
|
+
],
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### Extension VS Code
|
|
415
|
+
|
|
416
|
+
Pour améliorer votre expérience de développement avec Intlayer, vous pouvez installer l'extension officielle **Intlayer VS Code**.
|
|
417
|
+
|
|
418
|
+
[Installer depuis le Marketplace VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
419
|
+
|
|
420
|
+
Cette extension fournit :
|
|
421
|
+
|
|
422
|
+
- **Autocomplétion** pour les clés de traduction.
|
|
423
|
+
- **Détection d'erreurs en temps réel** pour les traductions manquantes.
|
|
424
|
+
- **Aperçus en ligne** du contenu traduit.
|
|
425
|
+
- **Actions rapides** pour créer et mettre à jour facilement les traductions.
|
|
426
|
+
|
|
427
|
+
Pour plus de détails sur l'utilisation de l'extension, référez-vous à la [documentation de l'extension Intlayer pour VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
428
|
+
|
|
429
|
+
### Configuration Git
|
|
430
|
+
|
|
431
|
+
Il est recommandé d'ignorer les fichiers générés par Intlayer. Cela vous permet d'éviter de les inclure dans votre dépôt Git.
|
|
432
|
+
|
|
433
|
+
Pour ce faire, vous pouvez ajouter les instructions suivantes à votre fichier `.gitignore` :
|
|
434
|
+
|
|
435
|
+
```plaintext fileName=".gitignore"
|
|
436
|
+
# Ignorer les fichiers générés par Intlayer
|
|
437
|
+
.intlayer
|
|
438
|
+
|
|
439
|
+
```
|
package/docs/fr/readme.md
CHANGED
|
@@ -50,7 +50,7 @@ Avec des **fichiers de contenu par locale**, une **autocomplétion TypeScript**,
|
|
|
50
50
|
| Fonctionnalité | Description |
|
|
51
51
|
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
52
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Fonctionnalité" width="700"> | **Support Multi-Frameworks**<br><br>Intlayer est compatible avec tous les principaux frameworks et bibliothèques, y compris Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, et bien d'autres. |
|
|
53
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.
|
|
53
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Fonctionnalité" width="700"> | **Gestion de contenu propulsée par JavaScript**<br><br>Exploitez la flexibilité de JavaScript pour définir et gérer efficacement votre contenu. <br><br> - [Déclaration de contenu](https://intlayer.org/doc/concept/content) |
|
|
54
54
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Fonctionnalité" width="700"> | **Fichier de déclaration de contenu par locale**<br><br>Accélérez votre développement en déclarant votre contenu une seule fois, avant la génération automatique.<br><br> - [Fichier de déclaration de contenu par locale](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
55
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Fonctionnalité" width="700"> | **Environnement avec typage sécurisé**<br><br>Exploitez TypeScript pour garantir que vos définitions de contenu et votre code sont sans erreur, tout en bénéficiant de l'autocomplétion dans votre IDE.<br><br> - [Configuration TypeScript](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
56
56
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Fonctionnalité" width="700"> | **Configuration simplifiée**<br><br>Démarrez rapidement avec une configuration minimale. Ajustez facilement les paramètres pour l'internationalisation, le routage, l'IA, la construction et la gestion du contenu.<br><br> - [Découvrez l'intégration Next.js](https://intlayer.org/doc/environment/nextjs) |
|
package/docs/hi/cli/push.md
CHANGED
|
@@ -23,7 +23,7 @@ slugs:
|
|
|
23
23
|
npx intlayer dictionary push
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
यदि [intlayer संपादक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_visual_editor.md) स्थापित है, तो आप शब्दकोशों को संपादक में भी पुश कर सकते हैं। यह कमांड शब्दकोशों को [संपादक](https://intlayer.org/
|
|
26
|
+
यदि [intlayer संपादक](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/intlayer_visual_editor.md) स्थापित है, तो आप शब्दकोशों को संपादक में भी पुश कर सकते हैं। यह कमांड शब्दकोशों को [संपादक](https://app.intlayer.org/) के लिए उपलब्ध कराएगा। इस तरह, आप अपने शब्दकोशों को अपनी टीम के साथ साझा कर सकते हैं और अपने एप्लिकेशन के कोड को संपादित किए बिना अपनी सामग्री को संपादित कर सकते हैं।
|
|
27
27
|
|
|
28
28
|
## उपनाम:
|
|
29
29
|
|
package/docs/hi/configuration.md
CHANGED
|
@@ -242,14 +242,14 @@ module.exports = config;
|
|
|
242
242
|
- **clientId**:
|
|
243
243
|
- _प्रकार_: `string` | `undefined`
|
|
244
244
|
- _डिफ़ॉल्ट_: `undefined`
|
|
245
|
-
- _विवरण_: clientId और clientSecret intlayer पैकेजों को oAuth2 प्रमाणीकरण का उपयोग करके बैकएंड के साथ प्रमाणीकरण करने की अनुमति देते हैं। एक एक्सेस टोकन का उपयोग परियोजना से संबंधित उपयोगकर्ता को प्रमाणित करने के लिए किया जाता है। एक्सेस टोकन प्राप्त करने के लिए, https://intlayer.org/
|
|
245
|
+
- _विवरण_: clientId और clientSecret intlayer पैकेजों को oAuth2 प्रमाणीकरण का उपयोग करके बैकएंड के साथ प्रमाणीकरण करने की अनुमति देते हैं। एक एक्सेस टोकन का उपयोग परियोजना से संबंधित उपयोगकर्ता को प्रमाणित करने के लिए किया जाता है। एक्सेस टोकन प्राप्त करने के लिए, https://app.intlayer.org/project पर जाएं और एक खाता बनाएं।
|
|
246
246
|
- _उदाहरण_: `true`
|
|
247
247
|
- _नोट_: महत्वपूर्ण: clientId और clientSecret को गोपनीय रखा जाना चाहिए और सार्वजनिक रूप से साझा नहीं किया जाना चाहिए। कृपया इन्हें सुरक्षित स्थान पर रखें, जैसे कि पर्यावरण चर (environment variables) में।
|
|
248
248
|
|
|
249
249
|
- **clientSecret**:
|
|
250
250
|
- _प्रकार_: `string` | `undefined`
|
|
251
251
|
- _डिफ़ॉल्ट_: `undefined`
|
|
252
|
-
- _विवरण_: clientId और clientSecret intlayer पैकेजों को oAuth2 प्रमाणीकरण का उपयोग करके बैकएंड के साथ प्रमाणीकरण करने की अनुमति देते हैं। एक एक्सेस टोकन का उपयोग परियोजना से संबंधित उपयोगकर्ता को प्रमाणित करने के लिए किया जाता है। एक्सेस टोकन प्राप्त करने के लिए, https://intlayer.org/
|
|
252
|
+
- _विवरण_: clientId और clientSecret intlayer पैकेजों को oAuth2 प्रमाणीकरण का उपयोग करके बैकएंड के साथ प्रमाणीकरण करने की अनुमति देते हैं। एक एक्सेस टोकन का उपयोग परियोजना से संबंधित उपयोगकर्ता को प्रमाणित करने के लिए किया जाता है। एक्सेस टोकन प्राप्त करने के लिए, https://app.intlayer.org/project पर जाएं और एक खाता बनाएं।
|
|
253
253
|
- _उदाहरण_: `true`
|
|
254
254
|
- _नोट_: महत्वपूर्ण: clientId और clientSecret को गोपनीय रखा जाना चाहिए और सार्वजनिक रूप से साझा नहीं किया जाना चाहिए। कृपया इन्हें सुरक्षित स्थान पर रखें, जैसे कि पर्यावरण चर।
|
|
255
255
|
|
|
@@ -465,7 +465,7 @@ module.exports = config;
|
|
|
465
465
|
|
|
466
466
|
सेटिंग्स जो Intlayer की एआई विशेषताओं को नियंत्रित करती हैं, जिसमें प्रदाता, मॉडल, और API कुंजी शामिल हैं।
|
|
467
467
|
|
|
468
|
-
यह कॉन्फ़िगरेशन वैकल्पिक है यदि आप [Intlayer डैशबोर्ड](https://intlayer.org/
|
|
468
|
+
यह कॉन्फ़िगरेशन वैकल्पिक है यदि आप [Intlayer डैशबोर्ड](https://app.intlayer.org/project) पर एक एक्सेस कुंजी का उपयोग करके पंजीकृत हैं। Intlayer स्वचालित रूप से आपकी आवश्यकताओं के लिए सबसे कुशल और लागत-प्रभावी एआई समाधान का प्रबंधन करेगा। डिफ़ॉल्ट विकल्पों का उपयोग करने से बेहतर दीर्घकालिक रखरखाव सुनिश्चित होता है क्योंकि Intlayer लगातार सबसे प्रासंगिक मॉडलों का उपयोग करने के लिए अपडेट होता रहता है।
|
|
469
469
|
|
|
470
470
|
यदि आप अपनी स्वयं की API कुंजी या विशिष्ट मॉडल का उपयोग करना पसंद करते हैं, तो आप अपनी कस्टम एआई कॉन्फ़िगरेशन परिभाषित कर सकते हैं।
|
|
471
471
|
यह AI कॉन्फ़िगरेशन आपके Intlayer पर्यावरण में वैश्विक रूप से उपयोग किया जाएगा। CLI कमांड इन सेटिंग्स का उपयोग कमांड्स (जैसे `fill`) के लिए डिफ़ॉल्ट के रूप में करेंगे, साथ ही SDK, विज़ुअल एडिटर, और CMS भी इनका उपयोग करेंगे। आप कमांड पैरामीटर का उपयोग करके विशिष्ट उपयोग मामलों के लिए इन डिफ़ॉल्ट मानों को ओवरराइड कर सकते हैं।
|
|
@@ -226,7 +226,7 @@ const ComponentExample = () => {
|
|
|
226
226
|
| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
227
227
|
| ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
228
228
|
|  | **क्रॉस-फ्रेमवर्क समर्थन**<br><br>Intlayer सभी प्रमुख फ्रेमवर्क और लाइब्रेरी के साथ संगत है, जिनमें Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, और अन्य शामिल हैं। |
|
|
229
|
-
|  | **जावास्क्रिप्ट-संचालित सामग्री प्रबंधन**<br><br>अपने कंटेंट को प्रभावी ढंग से परिभाषित और प्रबंधित करने के लिए जावास्क्रिप्ट की लचीलापन का उपयोग करें। <br><br> - [सामग्री घोषणा](https://intlayer.org/doc/concept/content) |
|
|
230
230
|
|  | **प्रति-स्थान सामग्री घोषणा फ़ाइल**<br><br>स्वचालित जनरेशन से पहले अपनी सामग्री को एक बार घोषित करके अपने विकास को तेज़ करें।<br><br> - [प्रति-स्थान सामग्री घोषणा फ़ाइल](https://intlayer.org/doc/concept/per-locale-file) |
|
|
231
231
|
|  | **टाइप-सेफ वातावरण**<br><br>TypeScript का उपयोग करें ताकि आपकी सामग्री परिभाषाएँ और कोड त्रुटि-मुक्त हों, साथ ही IDE ऑटोकंप्लीशन का लाभ भी प्राप्त करें।<br><br> - [TypeScript कॉन्फ़िगरेशन](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
232
232
|
|  | **सरल सेटअप**<br><br>न्यूनतम कॉन्फ़िगरेशन के साथ जल्दी से शुरू करें। अंतरराष्ट्रीयकरण, रूटिंग, AI, बिल्ड, और सामग्री प्रबंधन के लिए सेटिंग्स को आसानी से समायोजित करें। <br><br> - [Next.js एकीकरण का अन्वेषण करें](https://intlayer.org/doc/environment/nextjs) |
|
package/docs/hi/intlayer_CMS.md
CHANGED
|
@@ -92,7 +92,7 @@ const config: IntlayerConfig = {
|
|
|
92
92
|
*
|
|
93
93
|
* एडिटर को सक्षम करने के लिए क्लाइंट ID और क्लाइंट सीक्रेट आवश्यक हैं।
|
|
94
94
|
* ये उपयोगकर्ता की पहचान करने की अनुमति देते हैं जो सामग्री संपादित कर रहा है।
|
|
95
|
-
* इन्हें Intlayer डैशबोर्ड - प्रोजेक्ट्स (https://intlayer.org/
|
|
95
|
+
* इन्हें Intlayer डैशबोर्ड - प्रोजेक्ट्स (https://app.intlayer.org/projects) में नया क्लाइंट बनाकर प्राप्त किया जा सकता है।
|
|
96
96
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
97
97
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
98
98
|
*/
|
|
@@ -142,7 +142,7 @@ const config = {
|
|
|
142
142
|
*
|
|
143
143
|
* एडिटर को सक्षम करने के लिए क्लाइंट ID और क्लाइंट सीक्रेट आवश्यक हैं।
|
|
144
144
|
* ये उपयोगकर्ता की पहचान करने की अनुमति देते हैं जो सामग्री संपादित कर रहा है।
|
|
145
|
-
* इन्हें Intlayer डैशबोर्ड - प्रोजेक्ट्स (https://intlayer.org/
|
|
145
|
+
* इन्हें Intlayer डैशबोर्ड - प्रोजेक्ट्स (https://app.intlayer.org/projects) में नया क्लाइंट बनाकर प्राप्त किया जा सकता है।
|
|
146
146
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
147
147
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
148
148
|
*/
|
|
@@ -192,7 +192,7 @@ const config = {
|
|
|
192
192
|
*
|
|
193
193
|
* एडिटर को सक्षम करने के लिए क्लाइंट ID और क्लाइंट सीक्रेट आवश्यक हैं।
|
|
194
194
|
* ये उपयोगकर्ता की पहचान करने की अनुमति देते हैं जो सामग्री संपादित कर रहा है।
|
|
195
|
-
* इन्हें Intlayer डैशबोर्ड - प्रोजेक्ट्स (https://intlayer.org/
|
|
195
|
+
* इन्हें Intlayer डैशबोर्ड - प्रोजेक्ट्स (https://app.intlayer.org/projects) में नया क्लाइंट बनाकर प्राप्त किया जा सकता है।
|
|
196
196
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
197
197
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
198
198
|
*/
|
|
@@ -224,7 +224,7 @@ const config = {
|
|
|
224
224
|
module.exports = config;
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
> यदि आपके पास क्लाइंट ID और क्लाइंट सीक्रेट नहीं है, तो आप इन्हें [Intlayer डैशबोर्ड - प्रोजेक्ट्स](https://intlayer.org/
|
|
227
|
+
> यदि आपके पास क्लाइंट ID और क्लाइंट सीक्रेट नहीं है, तो आप इन्हें [Intlayer डैशबोर्ड - प्रोजेक्ट्स](https://app.intlayer.org/projects) में नया क्लाइंट बनाकर प्राप्त कर सकते हैं।
|
|
228
228
|
|
|
229
229
|
> सभी उपलब्ध पैरामीटर देखने के लिए, [कॉन्फ़िगरेशन दस्तावेज़](https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/configuration.md) देखें।
|
|
230
230
|
|
|
@@ -264,7 +264,7 @@ npx intlayer dictionary push -d my-first-dictionary-key --env production
|
|
|
264
264
|
|
|
265
265
|
### शब्दकोश संपादित करें
|
|
266
266
|
|
|
267
|
-
फिर आप अपने शब्दकोश को [Intlayer CMS](https://intlayer.org/
|
|
267
|
+
फिर आप अपने शब्दकोश को [Intlayer CMS](https://app.intlayer.org/content) में देख और प्रबंधित कर सकेंगे।
|
|
268
268
|
|
|
269
269
|
## लाइव सिंक
|
|
270
270
|
|