@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,449 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-12-30
|
|
3
|
+
updatedAt: 2025-12-30
|
|
4
|
+
title: So übersetzen Sie Ihr Fastify-Backend – i18n-Leitfaden 2026
|
|
5
|
+
description: Erfahren Sie, wie Sie Ihr Fastify-Backend mehrsprachig machen. Folgen Sie der Dokumentation, um es zu internationalisieren (i18n) und zu übersetzen.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internationalisierung
|
|
8
|
+
- Dokumentation
|
|
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: Init-Befehl hinzugefügt
|
|
22
|
+
- version: 7.6.0
|
|
23
|
+
date: 2025-12-31
|
|
24
|
+
changes: History initialisiert
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Übersetzen Sie Ihre Fastify-Backend-Website mit Intlayer | Internationalisierung (i18n)
|
|
28
|
+
|
|
29
|
+
`fastify-intlayer` ist ein leistungsfähiges Internationalisierungs-Plugin (i18n) für Fastify-Anwendungen, das entwickelt wurde, um Ihre Backend-Services global zugänglich zu machen, indem es lokalisierte Antworten basierend auf den Präferenzen des Clients bereitstellt.
|
|
30
|
+
|
|
31
|
+
### Praktische Anwendungsfälle
|
|
32
|
+
|
|
33
|
+
- **Anzeige von Backend-Fehlern in der Sprache des Nutzers**: Wenn ein Fehler auftritt, verbessert die Anzeige von Meldungen in der Muttersprache des Nutzers das Verständnis und reduziert Frustration. Dies ist besonders nützlich für dynamische Fehlermeldungen, die in Frontend-Komponenten wie Toasts oder Modals angezeigt werden können.
|
|
34
|
+
- **Abrufen mehrsprachiger Inhalte**: Für Anwendungen, die Inhalte aus einer Datenbank abrufen, stellt Internationalisierung sicher, dass Sie diese Inhalte in mehreren Sprachen bereitstellen können. Dies ist entscheidend für Plattformen wie E‑Commerce-Websites oder Content-Management-Systeme, die Produktbeschreibungen, Artikel und andere Inhalte in der vom Nutzer bevorzugten Sprache anzeigen müssen.
|
|
35
|
+
- **Versenden mehrsprachiger E-Mails**: Ob Transaktions-E-Mails, Marketingkampagnen oder Benachrichtigungen – das Versenden von E-Mails in der Sprache des Empfängers kann das Engagement und die Effektivität deutlich steigern.
|
|
36
|
+
- **Mehrsprachige Push-Benachrichtigungen**: Für mobile Anwendungen können Push-Benachrichtigungen in der bevorzugten Sprache des Nutzers die Interaktion und Bindung verbessern. Diese persönliche Note kann Benachrichtigungen relevanter erscheinen lassen und eher zu konkreten Aktionen anregen.
|
|
37
|
+
- **Andere Kommunikation**: Jede Form der Kommunikation vom Backend, wie SMS-Nachrichten, Systemwarnungen oder Benutzeroberflächen-Aktualisierungen, profitiert davon, in der Sprache des Nutzers verfügbar zu sein. Dies sorgt für Klarheit und verbessert das gesamte Benutzererlebnis.
|
|
38
|
+
|
|
39
|
+
Durch die Internationalisierung des Backends respektiert Ihre Anwendung nicht nur kulturelle Unterschiede, sondern passt sich auch besser den Anforderungen des globalen Marktes an und wird so zu einem wichtigen Schritt beim weltweiten Skalieren Ihrer Dienste.
|
|
40
|
+
|
|
41
|
+
## Erste Schritte
|
|
42
|
+
|
|
43
|
+
### Installation
|
|
44
|
+
|
|
45
|
+
Um `fastify-intlayer` zu verwenden, installieren Sie das Paket mit 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
|
+
### Einrichtung
|
|
72
|
+
|
|
73
|
+
Konfigurieren Sie die Internationalisierungseinstellungen, indem Sie eine `intlayer.config.ts` im Stammverzeichnis Ihres Projekts erstellen:
|
|
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
|
+
### Deklarieren Sie Ihre Inhalte
|
|
132
|
+
|
|
133
|
+
Erstellen und verwalten Sie Ihre Content-Deklarationen, um Übersetzungen zu speichern:
|
|
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
|
+
de: "Beispiel eines zurückgegebenen Inhalts auf Englisch",
|
|
143
|
+
en: "Example of returned content in English",
|
|
144
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
145
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
146
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
} satisfies Dictionary;
|
|
150
|
+
|
|
151
|
+
export default indexContent;
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```javascript fileName="src/index.content.mjs" contentDeclarationFormat="esm"
|
|
155
|
+
import { t } from "intlayer";
|
|
156
|
+
|
|
157
|
+
/** @type {import('intlayer').Dictionary} */
|
|
158
|
+
const indexContent = {
|
|
159
|
+
key: "index",
|
|
160
|
+
content: {
|
|
161
|
+
exampleOfContent: t({
|
|
162
|
+
de: "Beispiel für zurückgegebenen Inhalt auf Englisch",
|
|
163
|
+
en: "Example of returned content in English",
|
|
164
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
165
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
166
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
167
|
+
}),
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export default indexContent;
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```javascript fileName="src/index.content.cjs" contentDeclarationFormat="commonjs"
|
|
175
|
+
const { t } = require("intlayer");
|
|
176
|
+
|
|
177
|
+
/** @type {import('intlayer').Dictionary} */
|
|
178
|
+
const indexContent = {
|
|
179
|
+
key: "index",
|
|
180
|
+
content: {
|
|
181
|
+
exampleOfContent: t({
|
|
182
|
+
de: "Beispiel für zurückgegebenen Inhalt auf Englisch",
|
|
183
|
+
en: "Example of returned content in English",
|
|
184
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
185
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
186
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
187
|
+
}),
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
module.exports = indexContent;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
```json fileName="src/index.content.json" contentDeclarationFormat="json"
|
|
195
|
+
{
|
|
196
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
197
|
+
"key": "index",
|
|
198
|
+
"content": {
|
|
199
|
+
"exampleOfContent": {
|
|
200
|
+
"nodeType": "translation",
|
|
201
|
+
"translation": {
|
|
202
|
+
"de": "Beispiel für zurückgegebenen Inhalt auf Englisch",
|
|
203
|
+
"en": "Example of returned content in English",
|
|
204
|
+
"fr": "Exemple de contenu renvoyé en français",
|
|
205
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
206
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
> Ihre Content-Deklarationen können überall in Ihrer Anwendung definiert werden, solange sie im Verzeichnis `contentDir` (standardmäßig `./src`) enthalten sind. Und die Dateiendung der Content-Deklaration muss übereinstimmen (standardmäßig `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
214
|
+
|
|
215
|
+
> Für weitere Details siehe die [Dokumentation zur Content-Deklaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/dictionary/content_file.md).
|
|
216
|
+
|
|
217
|
+
### Fastify-Anwendung einrichten
|
|
218
|
+
|
|
219
|
+
Konfigurieren Sie Ihre Fastify-Anwendung, um `fastify-intlayer` zu verwenden:
|
|
220
|
+
|
|
221
|
+
```typescript fileName="src/index.ts" codeFormat="typescript"
|
|
222
|
+
import Fastify from "fastify";
|
|
223
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
224
|
+
import dictionaryExample from "./index.content";
|
|
225
|
+
|
|
226
|
+
const fastify = Fastify({ logger: true });
|
|
227
|
+
|
|
228
|
+
typescript fileName="src/index.ts" codeFormat="typescript"
|
|
229
|
+
// Internationalisierungs-Plugin laden
|
|
230
|
+
await fastify.register(intlayer);
|
|
231
|
+
|
|
232
|
+
// Routen
|
|
233
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
234
|
+
return t({
|
|
235
|
+
de: "Beispiel für zurückgegebenen Inhalt auf Deutsch",
|
|
236
|
+
en: "Example of returned content in English",
|
|
237
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
238
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
239
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
244
|
+
return getIntlayer("index").exampleOfContent;
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
248
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// Server starten
|
|
252
|
+
const start = async () => {
|
|
253
|
+
try {
|
|
254
|
+
await fastify.listen({ port: 3000 });
|
|
255
|
+
} catch (err) {
|
|
256
|
+
fastify.log.error(err);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
start();
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
```javascript fileName="src/index.mjs" codeFormat="esm"
|
|
265
|
+
import Fastify from "fastify";
|
|
266
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
267
|
+
import dictionaryExample from "./index.content";
|
|
268
|
+
|
|
269
|
+
const fastify = Fastify({ logger: true });
|
|
270
|
+
|
|
271
|
+
// Internationalisierungs-Plugin laden
|
|
272
|
+
await fastify.register(intlayer);
|
|
273
|
+
|
|
274
|
+
// Routen
|
|
275
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
276
|
+
return t({
|
|
277
|
+
de: "Beispiel für zurückgegebenen Inhalt auf Deutsch",
|
|
278
|
+
en: "Example of returned content in English",
|
|
279
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
280
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
281
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
286
|
+
return getIntlayer("index").exampleOfContent;
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
290
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Server starten
|
|
294
|
+
const start = async () => {
|
|
295
|
+
try {
|
|
296
|
+
await fastify.listen({ port: 3000 });
|
|
297
|
+
} catch (err) {
|
|
298
|
+
fastify.log.error(err);
|
|
299
|
+
process.exit(1);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
start();
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
```javascript fileName="src/index.cjs" codeFormat="commonjs"
|
|
307
|
+
const Fastify = require("fastify");
|
|
308
|
+
const { intlayer, t, getDictionary, getIntlayer } = require("fastify-intlayer");
|
|
309
|
+
const dictionaryExample = require("./index.content");
|
|
310
|
+
|
|
311
|
+
const fastify = Fastify({ logger: true });
|
|
312
|
+
|
|
313
|
+
// Wrapper zum Starten des Servers für async/await
|
|
314
|
+
const start = async () => {
|
|
315
|
+
try {
|
|
316
|
+
// Internationalisierungs-Plugin laden
|
|
317
|
+
await fastify.register(intlayer);
|
|
318
|
+
|
|
319
|
+
// Routen
|
|
320
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
321
|
+
return t({
|
|
322
|
+
de: "Beispiel für zurückgegebenen Inhalt auf Englisch",
|
|
323
|
+
en: "Example of returned content in English",
|
|
324
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
325
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
326
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
331
|
+
return getIntlayer("index").exampleOfContent;
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
335
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
await fastify.listen({ port: 3000 });
|
|
339
|
+
} catch (err) {
|
|
340
|
+
fastify.log.error(err);
|
|
341
|
+
process.exit(1);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
start();
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Kompatibilität
|
|
349
|
+
|
|
350
|
+
`fastify-intlayer` ist vollständig kompatibel mit:
|
|
351
|
+
|
|
352
|
+
- [`react-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/react-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/react-intlayer/index.md)>) für React-Anwendungen
|
|
353
|
+
- [`next-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/next-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/next-intlayer/index.md)>) für Next.js-Anwendungen
|
|
354
|
+
|
|
355
|
+
- [`react-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/react-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/react-intlayer/index.md)>) für React-Anwendungen
|
|
356
|
+
- [`next-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/next-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/next-intlayer/index.md)>) für Next.js-Anwendungen
|
|
357
|
+
- [`vite-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/vite-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/packages/vite-intlayer/index.md)>) für Vite-Anwendungen
|
|
358
|
+
|
|
359
|
+
Es funktioniert auch nahtlos mit jeder Internationalisierungslösung in verschiedenen Umgebungen, einschließlich Browsern und API-Anfragen. Sie können die Middleware anpassen, um die Locale über Header oder Cookies zu erkennen:
|
|
360
|
+
|
|
361
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
362
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
363
|
+
|
|
364
|
+
const config: IntlayerConfig = {
|
|
365
|
+
// ... Weitere Konfigurationsoptionen
|
|
366
|
+
middleware: {
|
|
367
|
+
headerName: "my-locale-header",
|
|
368
|
+
cookieName: "my-locale-cookie",
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export default config;
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
376
|
+
import { Locales } from "intlayer";
|
|
377
|
+
|
|
378
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
379
|
+
const config = {
|
|
380
|
+
// ... Weitere Konfigurationsoptionen
|
|
381
|
+
middleware: {
|
|
382
|
+
headerName: "my-locale-header",
|
|
383
|
+
cookieName: "my-locale-cookie",
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export default config;
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
391
|
+
const { Locales } = require("intlayer");
|
|
392
|
+
|
|
393
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
394
|
+
const config = {
|
|
395
|
+
// ... Weitere Konfigurationsoptionen
|
|
396
|
+
middleware: {
|
|
397
|
+
headerName: "my-locale-header",
|
|
398
|
+
cookieName: "my-locale-cookie",
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
module.exports = config;
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Standardmäßig interpretiert `fastify-intlayer` den `Accept-Language`-Header, um die bevorzugte Sprache des Clients zu bestimmen.
|
|
406
|
+
|
|
407
|
+
> Für weitere Informationen zur Konfiguration und zu erweiterten Themen, besuchen Sie unsere [Dokumentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/configuration.md).
|
|
408
|
+
|
|
409
|
+
### TypeScript konfigurieren
|
|
410
|
+
|
|
411
|
+
`fastify-intlayer` nutzt die leistungsstarken Möglichkeiten von TypeScript, um den Internationalisierungsprozess zu verbessern. Die statische Typisierung von TypeScript stellt sicher, dass jeder Übersetzungsschlüssel berücksichtigt wird, reduziert das Risiko fehlender Übersetzungen und verbessert die Wartbarkeit.
|
|
412
|
+
|
|
413
|
+
Stellen Sie sicher, dass die automatisch generierten Typen (standardmäßig unter ./types/intlayer.d.ts) in Ihrer tsconfig.json-Datei enthalten sind.
|
|
414
|
+
|
|
415
|
+
```json5 fileName="tsconfig.json"
|
|
416
|
+
{
|
|
417
|
+
// ... Ihre bestehenden TypeScript-Konfigurationen
|
|
418
|
+
"include": [
|
|
419
|
+
// ... Ihre bestehenden TypeScript-Konfigurationen
|
|
420
|
+
".intlayer/**/*.ts", // Automatisch generierte Typen einbeziehen
|
|
421
|
+
],
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### VS Code-Erweiterung
|
|
426
|
+
|
|
427
|
+
Um Ihre Entwicklungserfahrung mit Intlayer zu verbessern, können Sie die offizielle **Intlayer VS Code-Erweiterung** installieren.
|
|
428
|
+
|
|
429
|
+
[Installieren im VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
430
|
+
|
|
431
|
+
Diese Erweiterung bietet:
|
|
432
|
+
|
|
433
|
+
- **Autovervollständigung** für Übersetzungsschlüssel.
|
|
434
|
+
- **Echtzeit-Fehlererkennung** für fehlende Übersetzungen.
|
|
435
|
+
- **Inline-Vorschauen** des übersetzten Inhalts.
|
|
436
|
+
- **Schnellaktionen**, um Übersetzungen einfach zu erstellen und zu aktualisieren.
|
|
437
|
+
|
|
438
|
+
Weitere Details zur Verwendung der Erweiterung finden Sie in der [Dokumentation der Intlayer VS Code-Erweiterung](https://intlayer.org/doc/vs-code-extension).
|
|
439
|
+
|
|
440
|
+
### Git-Konfiguration
|
|
441
|
+
|
|
442
|
+
Es wird empfohlen, die von Intlayer generierten Dateien zu ignorieren. So vermeiden Sie, diese in Ihr Git-Repository zu committen.
|
|
443
|
+
|
|
444
|
+
Dazu können Sie die folgenden Einträge in Ihre `.gitignore`-Datei aufnehmen:
|
|
445
|
+
|
|
446
|
+
```plaintext fileName=".gitignore"
|
|
447
|
+
# Ignoriere die von Intlayer generierten Dateien
|
|
448
|
+
.intlayer
|
|
449
|
+
```
|
package/docs/de/readme.md
CHANGED
|
@@ -50,7 +50,7 @@ Mit **pro-Locale Inhaltsdateien**, **TypeScript-Autovervollständigung**, **baum
|
|
|
50
50
|
| Funktion | Beschreibung |
|
|
51
51
|
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
52
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Feature" width="700"> | **Unterstützung für mehrere Frameworks**<br><br>Intlayer ist kompatibel mit allen wichtigen Frameworks und Bibliotheken, einschließlich Next.js, React, Vite, Vue.js, Nuxt, Preact, Express und mehr. |
|
|
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="Feature" width="700"> | **JavaScript-gesteuertes Content-Management**<br><br>Nutzen Sie die Flexibilität von JavaScript, um Ihre Inhalte effizient zu definieren und zu verwalten. <br><br> - [Inhaltsdeklaration](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="Feature" width="700"> | **Pro-Lokale Inhaltsdeklarationsdatei**<br><br>Beschleunigen Sie Ihre Entwicklung, indem Sie Ihre Inhalte einmalig deklarieren, bevor die automatische Generierung erfolgt.<br><br> - [Pro-Lokale Inhaltsdeklarationsdatei](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="Feature" width="700"> | **Typsicheres Umfeld**<br><br>Nutzen Sie TypeScript, um sicherzustellen, dass Ihre Inhaltsdefinitionen und Ihr Code fehlerfrei sind, und profitieren Sie gleichzeitig von der Autovervollständigung in Ihrer IDE.<br><br> - [TypeScript-Konfiguration](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="Feature" width="700"> | **Vereinfachte Einrichtung**<br><br>Starten Sie schnell mit minimaler Konfiguration. Passen Sie mühelos Einstellungen für Internationalisierung, Routing, KI, Build und Inhaltsverwaltung an. <br><br> - [Next.js-Integration erkunden](https://intlayer.org/doc/environment/nextjs) |
|
package/docs/en/cli/push.md
CHANGED
|
@@ -23,7 +23,7 @@ slugs:
|
|
|
23
23
|
npx intlayer dictionary push
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
If [intlayer editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) is installed, you can also push dictionaries to the editor. This command will allow to make the dictionaries available to [the editor](https://intlayer.org/
|
|
26
|
+
If [intlayer editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) is installed, you can also push dictionaries to the editor. This command will allow to make the dictionaries available to [the editor](https://app.intlayer.org/). By this way, you can share your dictionaries with your team and edit your content without editing the code of your application.
|
|
27
27
|
|
|
28
28
|
## Aliases:
|
|
29
29
|
|
package/docs/en/configuration.md
CHANGED
|
@@ -269,14 +269,14 @@ Defines settings related to the integrated editor, including server port and act
|
|
|
269
269
|
- **clientId**:
|
|
270
270
|
- _Type_: `string` | `undefined`
|
|
271
271
|
- _Default_: `undefined`
|
|
272
|
-
- _Description_: clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication. An access token is used to authenticate the user related to the project. To get an access token, go to https://intlayer.org/
|
|
272
|
+
- _Description_: clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication. An access token is used to authenticate the user related to the project. To get an access token, go to https://app.intlayer.org/project and create an account.
|
|
273
273
|
- _Example_: `true`
|
|
274
274
|
- _Note_: Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
|
|
275
275
|
|
|
276
276
|
- **clientSecret**:
|
|
277
277
|
- _Type_: `string` | `undefined`
|
|
278
278
|
- _Default_: `undefined`
|
|
279
|
-
- _Description_: clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication. An access token is used to authenticate the user related to the project. To get an access token, go to https://intlayer.org/
|
|
279
|
+
- _Description_: clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication. An access token is used to authenticate the user related to the project. To get an access token, go to https://app.intlayer.org/project and create an account.
|
|
280
280
|
- _Example_: `true`
|
|
281
281
|
- _Note_: Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
|
|
282
282
|
|
|
@@ -608,7 +608,7 @@ Settings that control the logger, including the prefix to use.
|
|
|
608
608
|
|
|
609
609
|
Settings that control the AI features of Intlayer, including the provider, model, and API key.
|
|
610
610
|
|
|
611
|
-
This configuration is optional if you're registered on the [Intlayer Dashboard](https://intlayer.org/
|
|
611
|
+
This configuration is optional if you're registered on the [Intlayer Dashboard](https://app.intlayer.org/project) using an access key. Intlayer will automatically manage the most efficient and cost-effective AI solution for your needs. Using the default options ensures better long-term maintainability as Intlayer continuously updates to use the most relevant models.
|
|
612
612
|
|
|
613
613
|
If you prefer to use your own API key or specific model, you can define your custom AI configuration.
|
|
614
614
|
This AI configuration will be used globally across your Intlayer environment. CLI commands will use these settings as defaults for the commands (e.g. `fill`), as well as the SDK, Visual Editor, and CMS. You can override these default values for specific use cases using command parameters.
|
|
@@ -231,7 +231,7 @@ This approach allows you to:
|
|
|
231
231
|
| Feature | Description |
|
|
232
232
|
| ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
233
233
|
|  | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
|
|
234
|
-
|  | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
|
|
235
235
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.jpg?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
|
|
236
236
|
|  | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
|
|
237
237
|
|  | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
package/docs/en/intlayer_CMS.md
CHANGED
|
@@ -98,7 +98,7 @@ const config: IntlayerConfig = {
|
|
|
98
98
|
*
|
|
99
99
|
* Client ID and client secret are required to enable the editor.
|
|
100
100
|
* They allow the identify the user who is editing the content.
|
|
101
|
-
* They can be obtained by creating a new client in the Intlayer Dashboard - Projects (https://intlayer.org/
|
|
101
|
+
* They can be obtained by creating a new client in the Intlayer Dashboard - Projects (https://app.intlayer.org/projects).
|
|
102
102
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
103
103
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
104
104
|
*/
|
|
@@ -148,7 +148,7 @@ const config = {
|
|
|
148
148
|
*
|
|
149
149
|
* Client ID and client secret are required to enable the editor.
|
|
150
150
|
* They allow the identify the user who is editing the content.
|
|
151
|
-
* They can be obtained by creating a new client in the Intlayer Dashboard - Projects (https://intlayer.org/
|
|
151
|
+
* They can be obtained by creating a new client in the Intlayer Dashboard - Projects (https://app.intlayer.org/projects).
|
|
152
152
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
153
153
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
154
154
|
*/
|
|
@@ -198,7 +198,7 @@ const config = {
|
|
|
198
198
|
*
|
|
199
199
|
* Client ID and client secret are required to enable the editor.
|
|
200
200
|
* They allow the identify the user who is editing the content.
|
|
201
|
-
* They can be obtained by creating a new client in the Intlayer Dashboard - Projects (https://intlayer.org/
|
|
201
|
+
* They can be obtained by creating a new client in the Intlayer Dashboard - Projects (https://app.intlayer.org/projects).
|
|
202
202
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
203
203
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
204
204
|
*/
|
|
@@ -230,7 +230,7 @@ const config = {
|
|
|
230
230
|
module.exports = config;
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
-
> If you don't have a client ID and client secret, you can obtain them by creating a new client in the [Intlayer Dashboard - Projects](https://intlayer.org/
|
|
233
|
+
> If you don't have a client ID and client secret, you can obtain them by creating a new client in the [Intlayer Dashboard - Projects](https://app.intlayer.org/projects).
|
|
234
234
|
|
|
235
235
|
> To see all available parameters, refer to the [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md).
|
|
236
236
|
|
|
@@ -270,7 +270,7 @@ This command uploads your initial content dictionaries, making them available fo
|
|
|
270
270
|
|
|
271
271
|
### Edit the dictionary
|
|
272
272
|
|
|
273
|
-
Then you will be able to see and manage your dictionary in the [Intlayer CMS](https://intlayer.org/
|
|
273
|
+
Then you will be able to see and manage your dictionary in the [Intlayer CMS](https://app.intlayer.org/content).
|
|
274
274
|
|
|
275
275
|
## Live sync
|
|
276
276
|
|