@intlayer/docs 7.0.4-canary.0 → 7.0.4
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/blog/ar/intlayer_with_i18next.md +68 -106
- package/blog/ar/intlayer_with_next-i18next.md +84 -288
- package/blog/ar/intlayer_with_next-intl.md +58 -337
- package/blog/ar/intlayer_with_react-i18next.md +68 -290
- package/blog/ar/intlayer_with_react-intl.md +63 -266
- package/blog/de/intlayer_with_i18next.md +77 -97
- package/blog/de/intlayer_with_next-i18next.md +69 -296
- package/blog/de/intlayer_with_next-intl.md +59 -340
- package/blog/de/intlayer_with_react-i18next.md +68 -290
- package/blog/de/intlayer_with_react-intl.md +62 -264
- package/blog/en/intlayer_with_i18next.md +36 -1638
- package/blog/en/intlayer_with_next-i18next.md +22 -847
- package/blog/en/intlayer_with_next-intl.md +32 -1053
- package/blog/en/intlayer_with_react-i18next.md +38 -764
- package/blog/en/intlayer_with_react-intl.md +42 -1018
- package/blog/en-GB/intlayer_with_i18next.md +67 -103
- package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
- package/blog/en-GB/intlayer_with_next-intl.md +58 -337
- package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
- package/blog/en-GB/intlayer_with_react-intl.md +61 -264
- package/blog/es/intlayer_with_i18next.md +67 -103
- package/blog/es/intlayer_with_next-i18next.md +71 -296
- package/blog/es/intlayer_with_next-intl.md +57 -338
- package/blog/es/intlayer_with_react-i18next.md +68 -290
- package/blog/es/intlayer_with_react-intl.md +62 -265
- package/blog/fr/intlayer_with_i18next.md +66 -104
- package/blog/fr/intlayer_with_next-i18next.md +82 -285
- package/blog/fr/intlayer_with_next-intl.md +57 -338
- package/blog/fr/intlayer_with_react-i18next.md +67 -289
- package/blog/fr/intlayer_with_react-intl.md +61 -264
- package/blog/hi/intlayer_with_i18next.md +68 -104
- package/blog/hi/intlayer_with_next-i18next.md +74 -299
- package/blog/hi/intlayer_with_next-intl.md +57 -239
- package/blog/hi/intlayer_with_react-i18next.md +69 -291
- package/blog/hi/intlayer_with_react-intl.md +65 -268
- package/blog/id/intlayer_with_i18next.md +126 -0
- package/blog/id/intlayer_with_next-i18next.md +142 -0
- package/blog/id/intlayer_with_next-intl.md +113 -0
- package/blog/id/intlayer_with_react-i18next.md +124 -0
- package/blog/id/intlayer_with_react-intl.md +122 -0
- package/blog/it/intlayer_with_i18next.md +67 -103
- package/blog/it/intlayer_with_next-i18next.md +71 -296
- package/blog/it/intlayer_with_next-intl.md +57 -338
- package/blog/it/intlayer_with_react-i18next.md +68 -290
- package/blog/it/intlayer_with_react-intl.md +62 -265
- package/blog/ja/intlayer_with_i18next.md +68 -103
- package/blog/ja/intlayer_with_next-i18next.md +85 -283
- package/blog/ja/intlayer_with_next-intl.md +58 -336
- package/blog/ja/intlayer_with_react-i18next.md +68 -290
- package/blog/ja/intlayer_with_react-intl.md +62 -264
- package/blog/ko/intlayer_with_i18next.md +80 -96
- package/blog/ko/intlayer_with_next-i18next.md +85 -287
- package/blog/ko/intlayer_with_next-intl.md +68 -327
- package/blog/ko/intlayer_with_react-i18next.md +68 -290
- package/blog/ko/intlayer_with_react-intl.md +64 -266
- package/blog/pl/intlayer_with_i18next.md +126 -0
- package/blog/pl/intlayer_with_next-i18next.md +142 -0
- package/blog/pl/intlayer_with_next-intl.md +111 -0
- package/blog/pl/intlayer_with_react-i18next.md +124 -0
- package/blog/pl/intlayer_with_react-intl.md +122 -0
- package/blog/pt/intlayer_with_i18next.md +67 -103
- package/blog/pt/intlayer_with_next-i18next.md +72 -293
- package/blog/pt/intlayer_with_next-intl.md +57 -256
- package/blog/pt/intlayer_with_react-i18next.md +104 -78
- package/blog/pt/intlayer_with_react-intl.md +62 -266
- package/blog/ru/intlayer_with_i18next.md +66 -104
- package/blog/ru/intlayer_with_next-i18next.md +71 -296
- package/blog/ru/intlayer_with_next-intl.md +58 -337
- package/blog/ru/intlayer_with_react-i18next.md +68 -290
- package/blog/ru/intlayer_with_react-intl.md +62 -265
- package/blog/tr/intlayer_with_i18next.md +71 -107
- package/blog/tr/intlayer_with_next-i18next.md +72 -297
- package/blog/tr/intlayer_with_next-intl.md +58 -339
- package/blog/tr/intlayer_with_react-i18next.md +69 -291
- package/blog/tr/intlayer_with_react-intl.md +63 -285
- package/blog/vi/intlayer_with_i18next.md +126 -0
- package/blog/vi/intlayer_with_next-i18next.md +142 -0
- package/blog/vi/intlayer_with_next-intl.md +111 -0
- package/blog/vi/intlayer_with_react-i18next.md +124 -0
- package/blog/vi/intlayer_with_react-intl.md +122 -0
- package/blog/zh/intlayer_with_i18next.md +67 -102
- package/blog/zh/intlayer_with_next-i18next.md +72 -296
- package/blog/zh/intlayer_with_next-intl.md +58 -336
- package/blog/zh/intlayer_with_react-i18next.md +68 -290
- package/blog/zh/intlayer_with_react-intl.md +63 -106
- package/docs/ar/plugins/sync-json.md +244 -0
- package/docs/de/plugins/sync-json.md +244 -0
- package/docs/en/intlayer_cli.md +25 -0
- package/docs/en/intlayer_with_nextjs_14.md +2 -0
- package/docs/en/intlayer_with_nextjs_15.md +2 -0
- package/docs/en/intlayer_with_nextjs_16.md +2 -0
- package/docs/en/plugins/sync-json.md +1 -1
- package/docs/en-GB/plugins/sync-json.md +244 -0
- package/docs/es/plugins/sync-json.md +244 -0
- package/docs/fr/plugins/sync-json.md +244 -0
- package/docs/hi/plugins/sync-json.md +244 -0
- package/docs/id/plugins/sync-json.md +244 -0
- package/docs/it/plugins/sync-json.md +244 -0
- package/docs/ja/plugins/sync-json.md +244 -0
- package/docs/ko/plugins/sync-json.md +244 -0
- package/docs/pl/plugins/sync-json.md +244 -0
- package/docs/pt/plugins/sync-json.md +244 -0
- package/docs/ru/plugins/sync-json.md +244 -0
- package/docs/tr/plugins/sync-json.md +245 -0
- package/docs/vi/plugins/sync-json.md +244 -0
- package/docs/zh/plugins/sync-json.md +244 -0
- package/package.json +14 -14
|
@@ -1,346 +1,124 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-01-02
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title:
|
|
5
|
-
description:
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
|
+
title: Wie Sie Ihre react-i18next JSON-Übersetzungen mit Intlayer automatisieren
|
|
5
|
+
description: Automatisieren Sie Ihre JSON-Übersetzungen mit Intlayer und react-i18next für eine verbesserte Internationalisierung in React-Anwendungen.
|
|
6
6
|
keywords:
|
|
7
7
|
- react-i18next
|
|
8
8
|
- i18next
|
|
9
9
|
- Intlayer
|
|
10
10
|
- Internationalisierung
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- JavaScript
|
|
11
|
+
- i18n
|
|
12
|
+
- Blog
|
|
14
13
|
- React
|
|
14
|
+
- JavaScript
|
|
15
|
+
- TypeScript
|
|
16
|
+
- Content Management
|
|
15
17
|
slugs:
|
|
16
18
|
- blog
|
|
17
19
|
- intlayer-with-react-i18next
|
|
20
|
+
history:
|
|
21
|
+
- version: 7.0.0
|
|
22
|
+
date: 2025-10-29
|
|
23
|
+
changes: Wechsel zum syncJSON-Plugin
|
|
18
24
|
---
|
|
19
25
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
## Übersicht
|
|
23
|
-
|
|
24
|
-
- **Intlayer** hilft Ihnen, Übersetzungen über **komponentenbasierte** Inhaltsdeklarationsdateien zu verwalten.
|
|
25
|
-
- **react-i18next** ist eine beliebte React-Integration für **i18next**, die Hooks wie `useTranslation` bereitstellt, um lokalisierte Strings in Ihren Komponenten abzurufen.
|
|
26
|
-
|
|
27
|
-
In Kombination kann Intlayer **Wörterbücher** im **i18next-kompatiblen JSON** exportieren, sodass react-i18next sie zur Laufzeit **verbrauchen** kann.
|
|
28
|
-
|
|
29
|
-
## Warum Intlayer mit react-i18next verwenden?
|
|
30
|
-
|
|
31
|
-
Die Inhaltsdeklarationsdateien von **Intlayer** bieten ein besseres Entwicklererlebnis, da sie:
|
|
32
|
-
|
|
33
|
-
1. **Flexibel in der Dateiplatzierung sind**
|
|
34
|
-
Platzieren Sie jede Inhaltsdeklarationsdatei direkt neben der Komponente, die sie benötigt. Diese Struktur ermöglicht es Ihnen, Übersetzungen lokal zusammenzuhalten und verhindert verwaiste Übersetzungen, wenn Komponenten verschoben oder gelöscht werden.
|
|
35
|
-
|
|
36
|
-
```bash codeFormat="typescript"
|
|
37
|
-
.
|
|
38
|
-
└── src
|
|
39
|
-
└── components
|
|
40
|
-
└── MyComponent
|
|
41
|
-
├── index.content.ts # Inhaltsdeklarationsdatei
|
|
42
|
-
└── index.tsx
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
```bash codeFormat="esm"
|
|
46
|
-
.
|
|
47
|
-
└── src
|
|
48
|
-
└── components
|
|
49
|
-
└── MyComponent
|
|
50
|
-
├── index.content.mjs # Inhaltsdeklarationsdatei
|
|
51
|
-
└── index.mjx
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
```bash codeFormat="cjs"
|
|
55
|
-
.
|
|
56
|
-
└── src
|
|
57
|
-
└── components
|
|
58
|
-
└── MyComponent
|
|
59
|
-
├── index.content.cjs # Inhaltsdeklarationsdatei
|
|
60
|
-
└── index.cjx
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
```bash codeFormat="json"
|
|
64
|
-
.
|
|
65
|
-
└── src
|
|
66
|
-
└── components
|
|
67
|
-
└── MyComponent
|
|
68
|
-
├── index.content.json # Inhaltsdeklarationsdatei
|
|
69
|
-
└── index.jsx
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
2. **Zentralisierte Übersetzungen**
|
|
73
|
-
Eine einzelne Inhaltsdeklarationsdatei sammelt alle notwendigen Übersetzungen für eine Komponente, was fehlende Übersetzungen leichter erkennbar macht.
|
|
74
|
-
Mit TypeScript erhalten Sie sogar zur Kompilierzeit Fehler, wenn Übersetzungen fehlen.
|
|
75
|
-
|
|
76
|
-
## Installation
|
|
77
|
-
|
|
78
|
-
In einem Create React App-Projekt installieren Sie diese Abhängigkeiten:
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
# Mit npm
|
|
82
|
-
npm install intlayer react-i18next i18next i18next-resources-to-backend
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
# Mit yarn
|
|
87
|
-
yarn add intlayer react-i18next i18next i18next-resources-to-backend
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# Mit pnpm
|
|
92
|
-
pnpm add intlayer react-i18next i18next i18next-resources-to-backend
|
|
93
|
-
```
|
|
26
|
+
# Wie Sie Ihre react-i18next JSON-Übersetzungen mit Intlayer automatisieren
|
|
94
27
|
|
|
95
|
-
|
|
28
|
+
## Was ist Intlayer?
|
|
96
29
|
|
|
97
|
-
|
|
98
|
-
- **react-intlayer** – React-spezifische Integration für Intlayer, die einige Skripte zur Automatisierung des Aufbaus von Wörterbüchern bereitstellt.
|
|
99
|
-
- **react-i18next** – React-spezifische Integrationsbibliothek für i18next, einschließlich des `useTranslation`-Hooks.
|
|
100
|
-
- **i18next** – Das zugrunde liegende Framework für die Übersetzungsbearbeitung.
|
|
101
|
-
- **i18next-resources-to-backend** – Ein i18next-Backend, das JSON-Ressourcen dynamisch importiert.
|
|
30
|
+
**Intlayer** ist eine innovative, Open-Source-Internationalisierungsbibliothek, die entwickelt wurde, um die Schwächen traditioneller i18n-Lösungen zu beheben. Sie bietet einen modernen Ansatz für das Content-Management in React-Anwendungen.
|
|
102
31
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
Erstellen (oder aktualisieren) Sie Ihre `intlayer.config.ts` im Root Ihres Projekts:
|
|
106
|
-
|
|
107
|
-
```typescript title="intlayer.config.ts"
|
|
108
|
-
import { Locales, type IntlayerConfig } from "intlayer";
|
|
109
|
-
|
|
110
|
-
const config: IntlayerConfig = {
|
|
111
|
-
internationalization: {
|
|
112
|
-
// Fügen Sie so viele Sprachen hinzu, wie Sie möchten
|
|
113
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
114
|
-
defaultLocale: Locales.ENGLISH,
|
|
115
|
-
},
|
|
116
|
-
content: {
|
|
117
|
-
// Sagen Sie Intlayer, dass es i18next-kompatibles JSON erstellen soll
|
|
118
|
-
dictionaryOutput: ["i18next"],
|
|
32
|
+
Siehe einen konkreten Vergleich mit react-i18next in unserem Blogbeitrag [react-i18next vs. react-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/de/react-i18next_vs_react-intl_vs_intlayer.md).
|
|
119
33
|
|
|
120
|
-
|
|
121
|
-
// Dieses Verzeichnis wird erstellt, wenn es noch nicht existiert.
|
|
122
|
-
i18nextResourcesDir: "./i18next/resources",
|
|
123
|
-
},
|
|
124
|
-
};
|
|
34
|
+
## Warum Intlayer mit react-i18next kombinieren?
|
|
125
35
|
|
|
126
|
-
|
|
127
|
-
```
|
|
36
|
+
Während Intlayer eine hervorragende eigenständige i18n-Lösung bietet (siehe unseren [React-Integrationsleitfaden](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/intlayer_with_vite+react.md)), möchten Sie es möglicherweise aus mehreren Gründen mit react-i18next kombinieren:
|
|
128
37
|
|
|
129
|
-
|
|
38
|
+
1. **Bestehender Codebestand**: Sie haben eine etablierte react-i18next-Implementierung und möchten schrittweise auf die verbesserte Entwicklererfahrung von Intlayer migrieren.
|
|
39
|
+
2. **Altsystem-Anforderungen**: Ihr Projekt erfordert Kompatibilität mit bestehenden react-i18next-Plugins oder Workflows.
|
|
40
|
+
3. **Teamvertrautheit**: Ihr Team ist mit react-i18next vertraut, möchte jedoch ein besseres Content-Management.
|
|
130
41
|
|
|
131
|
-
|
|
42
|
+
**Dafür kann Intlayer als Adapter für react-i18next implementiert werden, um Ihre JSON-Übersetzungen in CLI- oder CI/CD-Pipelines zu automatisieren, Ihre Übersetzungen zu testen und mehr.**
|
|
132
43
|
|
|
133
|
-
|
|
44
|
+
Dieser Leitfaden zeigt Ihnen, wie Sie das überlegene Content-Deklarationssystem von Intlayer nutzen und gleichzeitig die Kompatibilität mit react-i18next beibehalten.
|
|
134
45
|
|
|
135
|
-
|
|
136
|
-
# Mit npm
|
|
137
|
-
npx run intlayer build
|
|
138
|
-
```
|
|
46
|
+
## Inhaltsverzeichnis
|
|
139
47
|
|
|
140
|
-
|
|
141
|
-
# Mit yarn
|
|
142
|
-
yarn intlayer build
|
|
143
|
-
```
|
|
48
|
+
<TOC/>
|
|
144
49
|
|
|
145
|
-
|
|
146
|
-
# Mit pnpm
|
|
147
|
-
pnpm intlayer build
|
|
148
|
-
```
|
|
50
|
+
## Schritt-für-Schritt-Anleitung zur Einrichtung von Intlayer mit react-i18next
|
|
149
51
|
|
|
150
|
-
|
|
52
|
+
### Schritt 1: Abhängigkeiten installieren
|
|
151
53
|
|
|
152
|
-
|
|
54
|
+
Installieren Sie die notwendigen Pakete:
|
|
153
55
|
|
|
154
|
-
```bash
|
|
155
|
-
|
|
156
|
-
└── i18next
|
|
157
|
-
└── resources
|
|
158
|
-
├── de
|
|
159
|
-
│ └── my-content.json
|
|
160
|
-
├── fr
|
|
161
|
-
│ └── my-content.json
|
|
162
|
-
└── es
|
|
163
|
-
└── my-content.json
|
|
56
|
+
```bash packageManager="npm"
|
|
57
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
164
58
|
```
|
|
165
59
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
## Wörterbücher in Ihre react-i18next-Konfiguration importieren
|
|
169
|
-
|
|
170
|
-
Um diese Ressourcen zur Laufzeit dynamisch zu laden, verwenden Sie [`i18next-resources-to-backend`](https://www.npmjs.com/package/i18next-resources-to-backend). Erstellen Sie beispielsweise eine Datei `i18n.ts` (oder `.js`) in Ihrem Projekt:
|
|
171
|
-
|
|
172
|
-
```typescript title="i18n.ts"
|
|
173
|
-
import i18next from "i18next";
|
|
174
|
-
import { initReactI18next } from "react-i18next";
|
|
175
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
176
|
-
|
|
177
|
-
i18next
|
|
178
|
-
// react-i18next-Plugin
|
|
179
|
-
.use(initReactI18next)
|
|
180
|
-
// Ressourcen dynamisch laden
|
|
181
|
-
.use(
|
|
182
|
-
resourcesToBackend((language: string, namespace: string) => {
|
|
183
|
-
// Passen Sie den Importpfad zu Ihrem Ressourcenverzeichnis an
|
|
184
|
-
return import(`../i18next/resources/${language}/${namespace}.json`);
|
|
185
|
-
})
|
|
186
|
-
)
|
|
187
|
-
// Initialize i18next
|
|
188
|
-
.init({
|
|
189
|
-
// Fallback-Sprache
|
|
190
|
-
fallbackLng: "de",
|
|
191
|
-
|
|
192
|
-
// Sie können hier andere i18next-Konfigurationsoptionen hinzufügen, siehe:
|
|
193
|
-
// https://www.i18next.com/overview/configuration-options
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
export default i18next;
|
|
60
|
+
```bash packageManager="pnpm"
|
|
61
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
197
62
|
```
|
|
198
63
|
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
import { initReactI18next } from "react-i18next";
|
|
202
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
203
|
-
|
|
204
|
-
i18next
|
|
205
|
-
.use(initReactI18next)
|
|
206
|
-
.use(
|
|
207
|
-
resourcesToBackend(
|
|
208
|
-
(language, namespace) =>
|
|
209
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
210
|
-
)
|
|
211
|
-
)
|
|
212
|
-
.init({
|
|
213
|
-
fallbackLng: "de",
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
export default i18next;
|
|
64
|
+
```bash packageManager="yarn"
|
|
65
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
217
66
|
```
|
|
218
67
|
|
|
219
|
-
|
|
68
|
+
**Paketbeschreibungen:**
|
|
220
69
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
import ReactDOM from "react-dom/client";
|
|
224
|
-
// Initialisieren Sie i18n vor allem anderen
|
|
225
|
-
import "./i18n";
|
|
226
|
-
import App from "./App";
|
|
70
|
+
- **intlayer**: Kernbibliothek für Internationalisierungsmanagement, Content-Deklaration und Build-Prozesse
|
|
71
|
+
- **@intlayer/sync-json-plugin**: Plugin zum Exportieren von Intlayer-Content-Deklarationen in ein mit react-i18next kompatibles JSON-Format
|
|
227
72
|
|
|
228
|
-
|
|
229
|
-
<React.StrictMode>
|
|
230
|
-
<App />
|
|
231
|
-
</React.StrictMode>
|
|
232
|
-
);
|
|
233
|
-
```
|
|
73
|
+
### Schritt 2: Implementieren Sie das Intlayer-Plugin zum Verpacken des JSON
|
|
234
74
|
|
|
235
|
-
|
|
75
|
+
Erstellen Sie eine Intlayer-Konfigurationsdatei, um Ihre unterstützten Sprachen zu definieren:
|
|
236
76
|
|
|
237
|
-
|
|
238
|
-
Hier ist ein minimales Beispiel in TypeScript:
|
|
77
|
+
**Wenn Sie auch JSON-Wörterbücher für react-i18next exportieren möchten**, fügen Sie das `syncJSON`-Plugin hinzu:
|
|
239
78
|
|
|
240
|
-
```typescript
|
|
241
|
-
import {
|
|
79
|
+
```typescript fileName="intlayer.config.ts"
|
|
80
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
81
|
+
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
242
82
|
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// Jeder "t"-Aufruf ist ein separater Übersetzungs-Knoten
|
|
248
|
-
heading: t({
|
|
249
|
-
de: "Hallo Welt",
|
|
250
|
-
fr: "Bonjour le monde",
|
|
251
|
-
es: "Hola Mundo",
|
|
252
|
-
}),
|
|
253
|
-
description: t({
|
|
254
|
-
de: "Mein i18n Beschreibungstext...",
|
|
255
|
-
fr: "Ma description en i18n...",
|
|
256
|
-
es: "Mi descripción en i18n...",
|
|
257
|
-
}),
|
|
83
|
+
const config: IntlayerConfig = {
|
|
84
|
+
internationalization: {
|
|
85
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
86
|
+
defaultLocale: Locales.ENGLISH,
|
|
258
87
|
},
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
Wenn Sie JSON, `.cjs` oder `.mjs` bevorzugen, siehe die [Intlayer-Dokumentation](https://intlayer.org/en/doc/concept/content).
|
|
265
|
-
|
|
266
|
-
> Standardmäßig entsprechen gültige Inhaltsdeklarationen dem Dateiendungsmuster:
|
|
267
|
-
|
|
268
|
-
> `*.content.{ts,tsx,js,jsx,mjs,mjx,cjs,cjx,json}`
|
|
269
|
-
|
|
270
|
-
## Verwendung der Übersetzungen in React-Komponenten
|
|
271
|
-
|
|
272
|
-
Nachdem Sie Ihre Intlayer-Ressourcen **gebaut** und react-i18next konfiguriert haben, können Sie direkt den `useTranslation`-Hook von **react-i18next** verwenden.
|
|
273
|
-
Zum Beispiel:
|
|
274
|
-
|
|
275
|
-
```tsx title="src/components/MyComponent/MyComponent.tsx"
|
|
276
|
-
import type { FC } from "react";
|
|
277
|
-
import { useTranslation } from "react-i18next";
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Der i18next "Namensraum" ist der Intlayer `key` aus "MyComponent.content.ts"
|
|
281
|
-
* also übergeben wir "my-component" an useTranslation().
|
|
282
|
-
*/
|
|
283
|
-
const MyComponent: FC = () => {
|
|
284
|
-
const { t } = useTranslation("my-component");
|
|
285
|
-
|
|
286
|
-
return (
|
|
287
|
-
<div>
|
|
288
|
-
<h1>{t("heading")}</h1>
|
|
289
|
-
<p>{t("description")}</p>
|
|
290
|
-
</div>
|
|
291
|
-
);
|
|
88
|
+
plugins: [
|
|
89
|
+
syncJSON({
|
|
90
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
292
93
|
};
|
|
293
94
|
|
|
294
|
-
export default
|
|
95
|
+
export default config;
|
|
295
96
|
```
|
|
296
97
|
|
|
297
|
-
|
|
98
|
+
Das `syncJSON`-Plugin umschließt das JSON automatisch. Es liest und schreibt die JSON-Dateien, ohne die Inhaltsarchitektur zu verändern.
|
|
298
99
|
|
|
299
|
-
|
|
100
|
+
Wenn Sie möchten, dass dieses JSON zusammen mit Intlayer-Content-Deklarationsdateien (`.content`-Dateien) koexistiert, geht Intlayer folgendermaßen vor:
|
|
300
101
|
|
|
301
|
-
|
|
102
|
+
1. Lade sowohl JSON- als auch Inhaltsdeklarationsdateien und transformiere sie in ein Intlayer-Wörterbuch.
|
|
103
|
+
2. Wenn es Konflikte zwischen den JSON- und den Inhaltsdeklarationsdateien gibt, wird Intlayer alle Wörterbücher zusammenführen. Dies hängt von der Priorität der Plugins und der Inhaltsdeklarationsdatei ab (alle sind konfigurierbar).
|
|
302
104
|
|
|
303
|
-
|
|
304
|
-
```bash
|
|
305
|
-
npm install react-intlayer --save-dev
|
|
306
|
-
```
|
|
307
|
-
2. **Passen Sie Ihre `package.json`-Skripte** an, um `react-intlayer`-Skripte zu verwenden:
|
|
105
|
+
Wenn Änderungen über die CLI zur Übersetzung des JSON vorgenommen werden oder das CMS verwendet wird, aktualisiert Intlayer die JSON-Datei mit den neuen Übersetzungen.
|
|
308
106
|
|
|
309
|
-
|
|
310
|
-
"scripts": {
|
|
311
|
-
"start": "react-intlayer start",
|
|
312
|
-
"build": "react-intlayer build",
|
|
313
|
-
"transpile": "intlayer build"
|
|
314
|
-
}
|
|
315
|
-
```
|
|
107
|
+
Für weitere Details zum `syncJSON`-Plugin siehe bitte die [syncJSON Plugin-Dokumentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/plugins/sync-json.md).
|
|
316
108
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
Nun löst das Ausführen von `npm run build`, `yarn build` oder `pnpm build` sowohl die Intlayer- als auch die CRA-Bauten aus.
|
|
320
|
-
|
|
321
|
-
## TypeScript-Konfiguration
|
|
109
|
+
## Git-Konfiguration
|
|
322
110
|
|
|
323
|
-
|
|
111
|
+
Es wird empfohlen, automatisch generierte Intlayer-Dateien zu ignorieren:
|
|
324
112
|
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
// ...
|
|
329
|
-
},
|
|
330
|
-
"include": ["src", "types"],
|
|
331
|
-
}
|
|
113
|
+
```plaintext fileName=".gitignore"
|
|
114
|
+
# Ignoriere automatisch generierte Intlayer-Dateien
|
|
115
|
+
.intlayer
|
|
332
116
|
```
|
|
333
117
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
## Git-Konfiguration
|
|
118
|
+
Diese Dateien können während Ihres Build-Prozesses neu generiert werden und müssen nicht in die Versionskontrolle übernommen werden.
|
|
337
119
|
|
|
338
|
-
|
|
120
|
+
### VS Code Erweiterung
|
|
339
121
|
|
|
340
|
-
|
|
341
|
-
# Ignoriere die von Intlayer generierten Dateien
|
|
342
|
-
.intlayer
|
|
343
|
-
i18next
|
|
344
|
-
```
|
|
122
|
+
Für eine verbesserte Entwicklererfahrung installieren Sie die offizielle **Intlayer VS Code Erweiterung**:
|
|
345
123
|
|
|
346
|
-
|
|
124
|
+
[Installation aus dem VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|