@intlayer/docs 6.1.5 → 6.1.6
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/next-i18next_vs_next-intl_vs_intlayer.md +404 -173
- package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +262 -113
- package/blog/en/intlayer_with_next-i18next.mdx +431 -0
- package/blog/en/intlayer_with_next-intl.mdx +335 -0
- package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +463 -209
- package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +185 -71
- package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +36 -28
- package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/dist/cjs/generated/docs.entry.cjs +32 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +32 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +2 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/component_i18n.md +186 -0
- package/docs/ar/intlayer_with_angular.md +2 -2
- package/docs/ar/intlayer_with_astro.md +246 -0
- package/docs/ar/intlayer_with_create_react_app.md +3 -2
- package/docs/ar/intlayer_with_express.md +2 -2
- package/docs/ar/intlayer_with_nestjs.md +2 -2
- package/docs/ar/intlayer_with_nextjs_14.md +2 -2
- package/docs/ar/intlayer_with_nextjs_15.md +2 -2
- package/docs/ar/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ar/intlayer_with_nuxt.md +2 -2
- package/docs/ar/intlayer_with_react_native+expo.md +11 -20
- package/docs/ar/intlayer_with_react_router_v7.md +195 -241
- package/docs/ar/intlayer_with_tanstack.md +198 -272
- package/docs/ar/intlayer_with_vite+preact.md +9 -9
- package/docs/ar/intlayer_with_vite+react.md +7 -7
- package/docs/ar/intlayer_with_vite+vue.md +9 -9
- package/docs/ar/vs_code_extension.md +48 -109
- package/docs/de/component_i18n.md +186 -0
- package/docs/de/intlayer_with_angular.md +2 -2
- package/docs/de/intlayer_with_astro.md +246 -0
- package/docs/de/intlayer_with_create_react_app.md +2 -2
- package/docs/de/intlayer_with_express.md +2 -2
- package/docs/de/intlayer_with_nestjs.md +2 -2
- package/docs/de/intlayer_with_nextjs_14.md +2 -2
- package/docs/de/intlayer_with_nextjs_15.md +2 -2
- package/docs/de/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/de/intlayer_with_nuxt.md +2 -2
- package/docs/de/intlayer_with_react_native+expo.md +11 -20
- package/docs/de/intlayer_with_react_router_v7.md +193 -242
- package/docs/de/intlayer_with_tanstack.md +194 -266
- package/docs/de/intlayer_with_vite+preact.md +9 -9
- package/docs/de/intlayer_with_vite+react.md +9 -9
- package/docs/de/intlayer_with_vite+vue.md +11 -11
- package/docs/de/packages/vite-intlayer/index.md +3 -3
- package/docs/de/vs_code_extension.md +46 -107
- package/docs/en/component_i18n.md +186 -0
- package/docs/en/how_works_intlayer.md +1 -1
- package/docs/en/index.md +1 -1
- package/docs/en/intlayer_cli.md +1 -1
- package/docs/en/intlayer_with_angular.md +4 -4
- package/docs/en/intlayer_with_astro.md +246 -0
- package/docs/en/intlayer_with_create_react_app.md +4 -4
- package/docs/en/intlayer_with_express.md +3 -3
- package/docs/en/intlayer_with_lynx+react.md +1 -1
- package/docs/en/intlayer_with_nestjs.md +2 -2
- package/docs/en/intlayer_with_nextjs_14.md +31 -5
- package/docs/en/intlayer_with_nextjs_15.md +31 -5
- package/docs/en/intlayer_with_nextjs_page_router.md +5 -5
- package/docs/en/intlayer_with_nuxt.md +4 -4
- package/docs/en/intlayer_with_react_native+expo.md +46 -24
- package/docs/en/intlayer_with_react_router_v7.md +164 -211
- package/docs/en/intlayer_with_tanstack.md +166 -241
- package/docs/en/intlayer_with_vite+preact.md +12 -12
- package/docs/en/intlayer_with_vite+react.md +12 -12
- package/docs/en/intlayer_with_vite+solid.md +2 -2
- package/docs/en/intlayer_with_vite+svelte.md +2 -2
- package/docs/en/intlayer_with_vite+vue.md +12 -12
- package/docs/en/introduction.md +1 -1
- package/docs/en/packages/next-intlayer/useDictionary.md +1 -1
- package/docs/en/packages/next-intlayer/useIntlayer.md +1 -1
- package/docs/en/packages/react-intlayer/useDictionary.md +1 -1
- package/docs/en/packages/react-intlayer/useI18n.md +1 -1
- package/docs/en/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/en/releases/v6.md +1 -0
- package/docs/en/roadmap.md +1 -1
- package/docs/en/vs_code_extension.md +24 -114
- package/docs/en-GB/component_i18n.md +186 -0
- package/docs/en-GB/intlayer_with_angular.md +3 -3
- package/docs/en-GB/intlayer_with_astro.md +246 -0
- package/docs/en-GB/intlayer_with_create_react_app.md +5 -4
- package/docs/en-GB/intlayer_with_express.md +2 -2
- package/docs/en-GB/intlayer_with_nestjs.md +2 -2
- package/docs/en-GB/intlayer_with_nextjs_14.md +4 -4
- package/docs/en-GB/intlayer_with_nextjs_15.md +2 -2
- package/docs/en-GB/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/en-GB/intlayer_with_nuxt.md +2 -2
- package/docs/en-GB/intlayer_with_react_native+expo.md +11 -20
- package/docs/en-GB/intlayer_with_react_router_v7.md +171 -220
- package/docs/en-GB/intlayer_with_tanstack.md +174 -248
- package/docs/en-GB/intlayer_with_vite+preact.md +9 -9
- package/docs/en-GB/intlayer_with_vite+react.md +9 -9
- package/docs/en-GB/intlayer_with_vite+vue.md +11 -11
- package/docs/en-GB/packages/next-intlayer/useIntlayer.md +1 -1
- package/docs/en-GB/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/en-GB/vs_code_extension.md +42 -103
- package/docs/es/component_i18n.md +182 -0
- package/docs/es/intlayer_with_angular.md +2 -2
- package/docs/es/intlayer_with_astro.md +246 -0
- package/docs/es/intlayer_with_create_react_app.md +3 -2
- package/docs/es/intlayer_with_express.md +2 -2
- package/docs/es/intlayer_with_nextjs_14.md +2 -2
- package/docs/es/intlayer_with_nextjs_15.md +2 -2
- package/docs/es/intlayer_with_react_native+expo.md +11 -20
- package/docs/es/intlayer_with_react_router_v7.md +188 -232
- package/docs/es/intlayer_with_tanstack.md +203 -273
- package/docs/es/intlayer_with_vite+preact.md +7 -7
- package/docs/es/intlayer_with_vite+react.md +7 -7
- package/docs/es/intlayer_with_vite+vue.md +9 -9
- package/docs/es/vs_code_extension.md +53 -114
- package/docs/fr/component_i18n.md +186 -0
- package/docs/fr/intlayer_with_angular.md +2 -2
- package/docs/fr/intlayer_with_astro.md +246 -0
- package/docs/fr/intlayer_with_create_react_app.md +3 -2
- package/docs/fr/intlayer_with_express.md +2 -2
- package/docs/fr/intlayer_with_nestjs.md +2 -2
- package/docs/fr/intlayer_with_nextjs_14.md +2 -2
- package/docs/fr/intlayer_with_react_native+expo.md +11 -20
- package/docs/fr/intlayer_with_react_router_v7.md +188 -248
- package/docs/fr/intlayer_with_tanstack.md +192 -265
- package/docs/fr/intlayer_with_vite+preact.md +7 -7
- package/docs/fr/intlayer_with_vite+react.md +7 -7
- package/docs/fr/intlayer_with_vite+vue.md +9 -9
- package/docs/fr/vs_code_extension.md +50 -111
- package/docs/hi/component_i18n.md +186 -0
- package/docs/hi/intlayer_cli.md +1 -4
- package/docs/hi/intlayer_with_angular.md +2 -2
- package/docs/hi/intlayer_with_astro.md +246 -0
- package/docs/hi/intlayer_with_create_react_app.md +2 -2
- package/docs/hi/intlayer_with_express.md +2 -2
- package/docs/hi/intlayer_with_nestjs.md +2 -2
- package/docs/hi/intlayer_with_nextjs_14.md +2 -2
- package/docs/hi/intlayer_with_nextjs_15.md +2 -2
- package/docs/hi/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/hi/intlayer_with_nuxt.md +2 -2
- package/docs/hi/intlayer_with_react_native+expo.md +11 -20
- package/docs/hi/intlayer_with_react_router_v7.md +199 -243
- package/docs/hi/intlayer_with_tanstack.md +210 -285
- package/docs/hi/intlayer_with_vite+preact.md +9 -9
- package/docs/hi/intlayer_with_vite+react.md +9 -9
- package/docs/hi/intlayer_with_vite+solid.md +1 -1
- package/docs/hi/intlayer_with_vite+vue.md +11 -11
- package/docs/hi/vs_code_extension.md +49 -110
- package/docs/it/component_i18n.md +186 -0
- package/docs/it/intlayer_with_angular.md +2 -2
- package/docs/it/intlayer_with_astro.md +246 -0
- package/docs/it/intlayer_with_create_react_app.md +3 -2
- package/docs/it/intlayer_with_express.md +2 -2
- package/docs/it/intlayer_with_nestjs.md +2 -2
- package/docs/it/intlayer_with_nextjs_14.md +2 -2
- package/docs/it/intlayer_with_nextjs_15.md +2 -2
- package/docs/it/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/it/intlayer_with_nuxt.md +2 -2
- package/docs/it/intlayer_with_react_native+expo.md +11 -21
- package/docs/it/intlayer_with_react_router_v7.md +195 -242
- package/docs/it/intlayer_with_tanstack.md +203 -267
- package/docs/it/intlayer_with_vite+preact.md +9 -9
- package/docs/it/intlayer_with_vite+react.md +13 -11
- package/docs/it/intlayer_with_vite+vue.md +11 -11
- package/docs/it/vs_code_extension.md +50 -111
- package/docs/ja/component_i18n.md +186 -0
- package/docs/ja/intlayer_with_angular.md +2 -2
- package/docs/ja/intlayer_with_astro.md +246 -0
- package/docs/ja/intlayer_with_create_react_app.md +3 -2
- package/docs/ja/intlayer_with_express.md +2 -2
- package/docs/ja/intlayer_with_nestjs.md +2 -2
- package/docs/ja/intlayer_with_nextjs_14.md +2 -2
- package/docs/ja/intlayer_with_nextjs_15.md +2 -2
- package/docs/ja/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ja/intlayer_with_nuxt.md +2 -2
- package/docs/ja/intlayer_with_react_native+expo.md +18 -29
- package/docs/ja/intlayer_with_react_router_v7.md +204 -250
- package/docs/ja/intlayer_with_tanstack.md +218 -286
- package/docs/ja/intlayer_with_vite+preact.md +9 -9
- package/docs/ja/intlayer_with_vite+react.md +11 -11
- package/docs/ja/intlayer_with_vite+vue.md +11 -11
- package/docs/ja/vs_code_extension.md +50 -111
- package/docs/ko/component_i18n.md +186 -0
- package/docs/ko/intlayer_with_angular.md +2 -2
- package/docs/ko/intlayer_with_astro.md +246 -0
- package/docs/ko/intlayer_with_create_react_app.md +3 -2
- package/docs/ko/intlayer_with_express.md +2 -2
- package/docs/ko/intlayer_with_nestjs.md +2 -2
- package/docs/ko/intlayer_with_nextjs_14.md +2 -2
- package/docs/ko/intlayer_with_nextjs_15.md +2 -2
- package/docs/ko/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ko/intlayer_with_nuxt.md +2 -2
- package/docs/ko/intlayer_with_react_native+expo.md +19 -28
- package/docs/ko/intlayer_with_react_router_v7.md +190 -244
- package/docs/ko/intlayer_with_tanstack.md +200 -270
- package/docs/ko/intlayer_with_vite+preact.md +9 -9
- package/docs/ko/intlayer_with_vite+react.md +9 -9
- package/docs/ko/intlayer_with_vite+vue.md +11 -11
- package/docs/ko/vs_code_extension.md +48 -109
- package/docs/pt/component_i18n.md +186 -0
- package/docs/pt/intlayer_with_angular.md +2 -2
- package/docs/pt/intlayer_with_astro.md +246 -0
- package/docs/pt/intlayer_with_create_react_app.md +3 -2
- package/docs/pt/intlayer_with_express.md +2 -2
- package/docs/pt/intlayer_with_nestjs.md +2 -2
- package/docs/pt/intlayer_with_nextjs_14.md +2 -2
- package/docs/pt/intlayer_with_nextjs_15.md +2 -2
- package/docs/pt/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/pt/intlayer_with_nuxt.md +2 -2
- package/docs/pt/intlayer_with_react_native+expo.md +11 -20
- package/docs/pt/intlayer_with_react_router_v7.md +7 -13
- package/docs/pt/intlayer_with_tanstack.md +183 -258
- package/docs/pt/intlayer_with_vite+preact.md +9 -9
- package/docs/pt/intlayer_with_vite+react.md +9 -9
- package/docs/pt/intlayer_with_vite+vue.md +9 -9
- package/docs/pt/vs_code_extension.md +46 -107
- package/docs/ru/component_i18n.md +186 -0
- package/docs/ru/intlayer_with_angular.md +2 -2
- package/docs/ru/intlayer_with_astro.md +246 -0
- package/docs/ru/intlayer_with_create_react_app.md +3 -2
- package/docs/ru/intlayer_with_express.md +2 -2
- package/docs/ru/intlayer_with_nestjs.md +2 -2
- package/docs/ru/intlayer_with_nextjs_14.md +2 -2
- package/docs/ru/intlayer_with_nextjs_15.md +2 -2
- package/docs/ru/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ru/intlayer_with_nuxt.md +2 -2
- package/docs/ru/intlayer_with_react_native+expo.md +11 -20
- package/docs/ru/intlayer_with_react_router_v7.md +192 -238
- package/docs/ru/intlayer_with_tanstack.md +197 -269
- package/docs/ru/intlayer_with_vite+preact.md +9 -9
- package/docs/ru/intlayer_with_vite+react.md +9 -9
- package/docs/ru/intlayer_with_vite+vue.md +11 -11
- package/docs/ru/vs_code_extension.md +48 -109
- package/docs/tr/component_i18n.md +186 -0
- package/docs/tr/how_works_intlayer.md +1 -1
- package/docs/tr/index.md +1 -1
- package/docs/tr/intlayer_cli.md +1 -1
- package/docs/tr/intlayer_with_angular.md +4 -4
- package/docs/tr/intlayer_with_astro.md +246 -0
- package/docs/tr/intlayer_with_create_react_app.md +4 -4
- package/docs/tr/intlayer_with_express.md +3 -3
- package/docs/tr/intlayer_with_lynx+react.md +1 -1
- package/docs/tr/intlayer_with_nestjs.md +2 -2
- package/docs/tr/intlayer_with_nextjs_14.md +2 -2
- package/docs/tr/intlayer_with_nextjs_15.md +4 -4
- package/docs/tr/intlayer_with_nextjs_page_router.md +5 -5
- package/docs/tr/intlayer_with_nuxt.md +4 -4
- package/docs/tr/intlayer_with_react_native+expo.md +12 -21
- package/docs/tr/intlayer_with_react_router_v7.md +222 -267
- package/docs/tr/intlayer_with_tanstack.md +400 -303
- package/docs/tr/intlayer_with_vite+preact.md +12 -12
- package/docs/tr/intlayer_with_vite+react.md +12 -12
- package/docs/tr/intlayer_with_vite+solid.md +2 -2
- package/docs/tr/intlayer_with_vite+svelte.md +2 -2
- package/docs/tr/intlayer_with_vite+vue.md +12 -12
- package/docs/tr/introduction.md +1 -1
- package/docs/tr/packages/react-intlayer/useDictionary.md +1 -1
- package/docs/tr/packages/react-intlayer/useI18n.md +1 -1
- package/docs/tr/roadmap.md +1 -1
- package/docs/tr/vs_code_extension.md +54 -115
- package/docs/zh/component_i18n.md +186 -0
- package/docs/zh/intlayer_with_angular.md +2 -2
- package/docs/zh/intlayer_with_astro.md +246 -0
- package/docs/zh/intlayer_with_create_react_app.md +3 -2
- package/docs/zh/intlayer_with_express.md +2 -2
- package/docs/zh/intlayer_with_nestjs.md +2 -2
- package/docs/zh/intlayer_with_nextjs_14.md +2 -2
- package/docs/zh/intlayer_with_nextjs_15.md +2 -2
- package/docs/zh/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/zh/intlayer_with_nuxt.md +2 -2
- package/docs/zh/intlayer_with_react_native+expo.md +19 -28
- package/docs/zh/intlayer_with_react_router_v7.md +200 -248
- package/docs/zh/intlayer_with_tanstack.md +208 -283
- package/docs/zh/intlayer_with_vite+preact.md +9 -9
- package/docs/zh/intlayer_with_vite+react.md +9 -9
- package/docs/zh/intlayer_with_vite+vue.md +9 -9
- package/docs/zh/vs_code_extension.md +51 -105
- package/package.json +10 -10
- package/src/generated/docs.entry.ts +32 -0
|
@@ -19,6 +19,8 @@ slugs:
|
|
|
19
19
|
|
|
20
20
|
# next-i18next VS next-intl VS intlayer | Next.js Internationalisierung (i18n)
|
|
21
21
|
|
|
22
|
+

|
|
23
|
+
|
|
22
24
|
Werfen wir einen Blick auf die Gemeinsamkeiten und Unterschiede zwischen drei i18n-Optionen für Next.js: next-i18next, next-intl und Intlayer.
|
|
23
25
|
|
|
24
26
|
Dies ist kein vollständiges Tutorial. Es ist ein Vergleich, der Ihnen bei der Auswahl helfen soll.
|
|
@@ -173,9 +175,9 @@ Im Fall von `next-intl` und `next-i18next` erfordert die Bibliothek das Laden de
|
|
|
173
175
|
|
|
174
176
|
Hier ein Beispiel für die Auswirkung der Bundle-Größenoptimierung mit `intlayer` in einer vite + react Anwendung:
|
|
175
177
|
|
|
176
|
-
| Optimiertes Bundle
|
|
177
|
-
|
|
|
178
|
-
|  |  |
|
|
178
|
+
| Optimiertes Bundle | Nicht optimiertes Bundle |
|
|
179
|
+
| ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
180
|
+
|  |  |
|
|
179
181
|
|
|
180
182
|
---
|
|
181
183
|
|
|
@@ -348,25 +350,25 @@ Die App-Struktur ist wichtig, um eine gute Wartbarkeit Ihres Codes sicherzustell
|
|
|
348
350
|
|
|
349
351
|
```bash
|
|
350
352
|
.
|
|
351
|
-
├──
|
|
352
|
-
│ └── locales
|
|
353
|
-
│ ├── en
|
|
354
|
-
│ │ ├── home.json
|
|
355
|
-
│ │ └── navbar.json
|
|
356
|
-
│ ├── fr
|
|
357
|
-
│ │ ├── home.json
|
|
358
|
-
│ │ └── navbar.json
|
|
359
|
-
│ └── es
|
|
360
|
-
│ ├── home.json
|
|
361
|
-
│ └── navbar.json
|
|
362
|
-
├── next-i18next.config.js
|
|
353
|
+
├── i18n.config.ts
|
|
363
354
|
└── src
|
|
364
|
-
├──
|
|
355
|
+
├── locales
|
|
356
|
+
│ ├── en
|
|
357
|
+
│ │ ├── common.json
|
|
358
|
+
│ │ └── about.json
|
|
359
|
+
│ └── fr
|
|
360
|
+
│ ├── common.json
|
|
361
|
+
│ └── about.json
|
|
365
362
|
├── app
|
|
366
|
-
│
|
|
363
|
+
│ ├── i18n
|
|
364
|
+
│ │ └── server.ts
|
|
365
|
+
│ └── [locale]
|
|
366
|
+
│ ├── layout.tsx
|
|
367
|
+
│ └── about.tsx
|
|
367
368
|
└── components
|
|
368
|
-
|
|
369
|
-
|
|
369
|
+
├── I18nProvider.tsx
|
|
370
|
+
├── ClientComponent.tsx
|
|
371
|
+
└── ServerComponent.tsx
|
|
370
372
|
```
|
|
371
373
|
|
|
372
374
|
</TabItem>
|
|
@@ -374,6 +376,7 @@ Die App-Struktur ist wichtig, um eine gute Wartbarkeit Ihres Codes sicherzustell
|
|
|
374
376
|
|
|
375
377
|
```bash
|
|
376
378
|
.
|
|
379
|
+
├── i18n.ts
|
|
377
380
|
├── locales
|
|
378
381
|
│ ├── en
|
|
379
382
|
│ │ ├── home.json
|
|
@@ -384,11 +387,13 @@ Die App-Struktur ist wichtig, um eine gute Wartbarkeit Ihres Codes sicherzustell
|
|
|
384
387
|
│ └── es
|
|
385
388
|
│ ├── home.json
|
|
386
389
|
│ └── navbar.json
|
|
387
|
-
├── i18n.ts
|
|
388
390
|
└── src
|
|
389
391
|
├── middleware.ts
|
|
390
392
|
├── app
|
|
391
|
-
│
|
|
393
|
+
│ ├── i18n
|
|
394
|
+
│ │ └── server.ts
|
|
395
|
+
│ └── [locale]
|
|
396
|
+
│ └── home.tsx
|
|
392
397
|
└── components
|
|
393
398
|
└── Navbar
|
|
394
399
|
└── index.tsx
|
|
@@ -403,9 +408,11 @@ Die App-Struktur ist wichtig, um eine gute Wartbarkeit Ihres Codes sicherzustell
|
|
|
403
408
|
└── src
|
|
404
409
|
├── middleware.ts
|
|
405
410
|
├── app
|
|
406
|
-
│ └──
|
|
407
|
-
│
|
|
408
|
-
│ └──
|
|
411
|
+
│ └── [locale]
|
|
412
|
+
│ ├── layout.tsx
|
|
413
|
+
│ └── home
|
|
414
|
+
│ ├── index.tsx
|
|
415
|
+
│ └── index.content.ts
|
|
409
416
|
└── components
|
|
410
417
|
└── Navbar
|
|
411
418
|
├── index.tsx
|
|
@@ -428,155 +435,294 @@ Wie die Bibliothek das Laden von Inhalten handhabt, ist wichtig.
|
|
|
428
435
|
<Tab defaultTab="next-intl" group='techno'>
|
|
429
436
|
<TabItem label="next-i18next" value="next-i18next">
|
|
430
437
|
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
},
|
|
437
|
-
};
|
|
438
|
-
```
|
|
438
|
+
```ts fileName="i18n.config.ts"
|
|
439
|
+
export const locales = ["en", "fr"] as const;
|
|
440
|
+
export type Locale = (typeof locales)[number];
|
|
441
|
+
|
|
442
|
+
export const defaultLocale: Locale = "en";
|
|
439
443
|
|
|
440
|
-
|
|
441
|
-
|
|
444
|
+
export const rtlLocales = ["ar", "he", "fa", "ur"] as const;
|
|
445
|
+
export const isRtl = (locale: string) =>
|
|
446
|
+
(rtlLocales as readonly string[]).includes(locale);
|
|
442
447
|
|
|
443
|
-
|
|
448
|
+
export function localizedPath(locale: string, path: string) {
|
|
449
|
+
return locale === defaultLocale ? path : "/" + locale + path;
|
|
450
|
+
}
|
|
444
451
|
|
|
445
|
-
|
|
452
|
+
const ORIGIN = "https://example.com";
|
|
453
|
+
export function abs(locale: string, path: string) {
|
|
454
|
+
return ORIGIN + localizedPath(locale, path);
|
|
455
|
+
}
|
|
446
456
|
```
|
|
447
457
|
|
|
448
|
-
```
|
|
449
|
-
import type { GetStaticProps } from "next";
|
|
450
|
-
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
|
451
|
-
import { useTranslation } from "next-i18next";
|
|
452
|
-
import { I18nextProvider, initReactI18next } from "react-i18next";
|
|
458
|
+
```ts fileName="src/app/i18n/server.ts"
|
|
453
459
|
import { createInstance } from "i18next";
|
|
454
|
-
import {
|
|
460
|
+
import { initReactI18next } from "react-i18next/initReactI18next";
|
|
461
|
+
import resourcesToBackend from "i18next-resources-to-backend";
|
|
462
|
+
import { defaultLocale } from "@/i18n.config";
|
|
463
|
+
|
|
464
|
+
// Load JSON resources from src/locales/<locale>/<namespace>.json
|
|
465
|
+
const backend = resourcesToBackend(
|
|
466
|
+
(locale: string, namespace: string) =>
|
|
467
|
+
import(`../../locales/${locale}/${namespace}.json`)
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
export async function initI18next(
|
|
471
|
+
locale: string,
|
|
472
|
+
namespaces: string[] = ["common"]
|
|
473
|
+
) {
|
|
474
|
+
const i18n = createInstance();
|
|
475
|
+
await i18n
|
|
476
|
+
.use(initReactI18next)
|
|
477
|
+
.use(backend)
|
|
478
|
+
.init({
|
|
479
|
+
lng: locale,
|
|
480
|
+
fallbackLng: defaultLocale,
|
|
481
|
+
ns: namespaces,
|
|
482
|
+
defaultNS: "common",
|
|
483
|
+
interpolation: { escapeValue: false },
|
|
484
|
+
react: { useSuspense: false },
|
|
485
|
+
});
|
|
486
|
+
return i18n;
|
|
487
|
+
}
|
|
488
|
+
```
|
|
455
489
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const resources = await loadMessagesFor(locale); // dein Loader (JSON, etc.)
|
|
490
|
+
```tsx fileName="src/components/I18nProvider.tsx"
|
|
491
|
+
"use client";
|
|
459
492
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
493
|
+
import * as React from "react";
|
|
494
|
+
import { I18nextProvider } from "react-i18next";
|
|
495
|
+
import { createInstance } from "i18next";
|
|
496
|
+
import { initReactI18next } from "react-i18next/initReactI18next";
|
|
497
|
+
import resourcesToBackend from "i18next-resources-to-backend";
|
|
498
|
+
import { defaultLocale } from "@/i18n.config";
|
|
499
|
+
|
|
500
|
+
const backend = resourcesToBackend(
|
|
501
|
+
(locale: string, namespace: string) =>
|
|
502
|
+
import(`../../locales/${locale}/${namespace}.json`)
|
|
503
|
+
);
|
|
504
|
+
|
|
505
|
+
type Props = {
|
|
506
|
+
locale: string;
|
|
507
|
+
namespaces?: string[];
|
|
508
|
+
resources?: Record<string, any>; // { ns: bundle }
|
|
509
|
+
children: React.ReactNode;
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
export default function I18nProvider({
|
|
513
|
+
locale,
|
|
514
|
+
namespaces = ["common"],
|
|
515
|
+
resources,
|
|
516
|
+
children,
|
|
517
|
+
}: Props) {
|
|
518
|
+
const [i18n] = React.useState(() => {
|
|
519
|
+
const i = createInstance();
|
|
520
|
+
|
|
521
|
+
i.use(initReactI18next)
|
|
522
|
+
.use(backend)
|
|
523
|
+
.init({
|
|
524
|
+
lng: locale,
|
|
525
|
+
fallbackLng: defaultLocale,
|
|
526
|
+
ns: namespaces,
|
|
527
|
+
resources: resources ? { [locale]: resources } : undefined,
|
|
528
|
+
defaultNS: "common",
|
|
529
|
+
interpolation: { escapeValue: false },
|
|
530
|
+
react: { useSuspense: false },
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
return i;
|
|
468
534
|
});
|
|
469
535
|
|
|
470
|
-
|
|
536
|
+
return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
```tsx fileName="src/app/[locale]/layout.tsx"
|
|
541
|
+
import type { ReactNode } from "react";
|
|
542
|
+
import { locales, defaultLocale, isRtl, type Locale } from "@/i18n.config";
|
|
543
|
+
|
|
544
|
+
export const dynamicParams = false;
|
|
545
|
+
|
|
546
|
+
export function generateStaticParams() {
|
|
547
|
+
return locales.map((locale) => ({ locale }));
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export default function LocaleLayout({
|
|
551
|
+
children,
|
|
552
|
+
params,
|
|
553
|
+
}: {
|
|
554
|
+
children: ReactNode;
|
|
555
|
+
params: { locale: string };
|
|
556
|
+
}) {
|
|
557
|
+
const locale: Locale = (locales as readonly string[]).includes(params.locale)
|
|
558
|
+
? (params.locale as any)
|
|
559
|
+
: defaultLocale;
|
|
560
|
+
|
|
561
|
+
const dir = isRtl(locale) ? "rtl" : "ltr";
|
|
562
|
+
|
|
563
|
+
return (
|
|
564
|
+
<html lang={locale} dir={dir}>
|
|
565
|
+
<body>{children}</body>
|
|
566
|
+
</html>
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
```tsx fileName="src/app/[locale]/about.tsx"
|
|
572
|
+
import I18nProvider from "@/components/I18nProvider";
|
|
573
|
+
import { initI18next } from "@/app/i18n/server";
|
|
574
|
+
import type { Locale } from "@/i18n.config";
|
|
575
|
+
import ClientComponent from "@/components/ClientComponent";
|
|
576
|
+
import ServerComponent from "@/components/ServerComponent";
|
|
577
|
+
|
|
578
|
+
// Force static rendering for the page
|
|
579
|
+
export const dynamic = "force-static";
|
|
580
|
+
|
|
581
|
+
export default async function AboutPage({
|
|
582
|
+
params: { locale },
|
|
583
|
+
}: {
|
|
584
|
+
params: { locale: Locale };
|
|
585
|
+
}) {
|
|
586
|
+
const namespaces = ["common", "about"] as const;
|
|
587
|
+
|
|
588
|
+
const i18n = await initI18next(locale, [...namespaces]);
|
|
589
|
+
const tAbout = i18n.getFixedT(locale, "about");
|
|
471
590
|
|
|
472
591
|
return (
|
|
473
|
-
<
|
|
592
|
+
<I18nProvider locale={locale} namespaces={[...namespaces]}>
|
|
474
593
|
<main>
|
|
475
|
-
<h1>{
|
|
594
|
+
<h1>{tAbout("title")}</h1>
|
|
595
|
+
|
|
476
596
|
<ClientComponent />
|
|
477
|
-
<ServerComponent />
|
|
597
|
+
<ServerComponent t={tAbout} locale={locale} count={0} />
|
|
478
598
|
</main>
|
|
479
|
-
</
|
|
599
|
+
</I18nProvider>
|
|
480
600
|
);
|
|
481
601
|
}
|
|
482
|
-
|
|
483
|
-
export const getStaticProps: GetStaticProps = async ({ locale }) => {
|
|
484
|
-
// Laden Sie nur die für DIESE Seite benötigten Namespaces vor
|
|
485
|
-
return {
|
|
486
|
-
props: {
|
|
487
|
-
...(await serverSideTranslations(locale ?? "en", ["common", "about"])),
|
|
488
|
-
},
|
|
489
|
-
};
|
|
490
|
-
};
|
|
491
602
|
```
|
|
492
603
|
|
|
493
604
|
</TabItem>
|
|
494
605
|
<TabItem label="next-intl" value="next-intl">
|
|
495
606
|
|
|
496
|
-
```tsx fileName="i18n.ts"
|
|
607
|
+
```tsx fileName="src/i18n.ts"
|
|
497
608
|
import { getRequestConfig } from "next-intl/server";
|
|
498
609
|
import { notFound } from "next/navigation";
|
|
499
610
|
|
|
500
|
-
|
|
501
|
-
const
|
|
611
|
+
export const locales = ["en", "fr", "es"] as const;
|
|
612
|
+
export const defaultLocale = "en" as const;
|
|
613
|
+
|
|
614
|
+
async function loadMessages(locale: string) {
|
|
615
|
+
// Load only the namespaces your layout/pages need
|
|
616
|
+
const [common, about] = await Promise.all([
|
|
617
|
+
import(`../locales/${locale}/common.json`).then((m) => m.default),
|
|
618
|
+
import(`../locales/${locale}/about.json`).then((m) => m.default),
|
|
619
|
+
]);
|
|
620
|
+
|
|
621
|
+
return { common, about } as const;
|
|
622
|
+
}
|
|
502
623
|
|
|
503
624
|
export default getRequestConfig(async ({ locale }) => {
|
|
504
|
-
// Überprüfen Sie, ob der eingehende `locale`-Parameter gültig ist
|
|
505
625
|
if (!locales.includes(locale as any)) notFound();
|
|
506
626
|
|
|
507
627
|
return {
|
|
508
|
-
messages:
|
|
628
|
+
messages: await loadMessages(locale),
|
|
509
629
|
};
|
|
510
630
|
});
|
|
511
631
|
```
|
|
512
632
|
|
|
513
|
-
```tsx fileName="src/app/[locale]/
|
|
514
|
-
import {
|
|
515
|
-
import {
|
|
516
|
-
import
|
|
633
|
+
```tsx fileName="src/app/[locale]/layout.tsx"
|
|
634
|
+
import type { ReactNode } from "react";
|
|
635
|
+
import { locales } from "@/i18n";
|
|
636
|
+
import {
|
|
637
|
+
getLocaleDirection,
|
|
638
|
+
unstable_setRequestLocale,
|
|
639
|
+
} from "next-intl/server";
|
|
640
|
+
|
|
641
|
+
export const dynamic = "force-static";
|
|
642
|
+
|
|
643
|
+
export function generateStaticParams() {
|
|
644
|
+
return locales.map((locale) => ({ locale }));
|
|
645
|
+
}
|
|
517
646
|
|
|
518
647
|
export default async function LocaleLayout({
|
|
519
648
|
children,
|
|
520
649
|
params,
|
|
521
650
|
}: {
|
|
522
|
-
children:
|
|
523
|
-
params: { locale: string }
|
|
651
|
+
children: ReactNode;
|
|
652
|
+
params: Promise<{ locale: string }>;
|
|
524
653
|
}) {
|
|
525
|
-
const { locale } = params;
|
|
654
|
+
const { locale } = await params;
|
|
526
655
|
|
|
527
|
-
//
|
|
656
|
+
// Set the active request locale for this server render (RSC)
|
|
528
657
|
unstable_setRequestLocale(locale);
|
|
529
658
|
|
|
530
|
-
|
|
531
|
-
// (siehe next-intl Dokumentation). Hier senden wir nur einen Teil an den Client,
|
|
532
|
-
// der für Client-Komponenten benötigt wird (Payload-Optimierung).
|
|
533
|
-
const messages = await getMessages();
|
|
534
|
-
const clientMessages = pick(messages, ["common", "about"]);
|
|
659
|
+
const dir = getLocaleDirection(locale);
|
|
535
660
|
|
|
536
661
|
return (
|
|
537
|
-
<html lang={locale}>
|
|
538
|
-
<body>
|
|
539
|
-
<NextIntlClientProvider locale={locale} messages={clientMessages}>
|
|
540
|
-
{children}
|
|
541
|
-
</NextIntlClientProvider>
|
|
542
|
-
</body>
|
|
662
|
+
<html lang={locale} dir={dir}>
|
|
663
|
+
<body>{children}</body>
|
|
543
664
|
</html>
|
|
544
665
|
);
|
|
545
666
|
}
|
|
546
667
|
```
|
|
547
668
|
|
|
548
669
|
```tsx fileName="src/app/[locale]/about/page.tsx"
|
|
549
|
-
import { getTranslations } from "next-intl/server";
|
|
550
|
-
import {
|
|
670
|
+
import { getTranslations, getMessages, getFormatter } from "next-intl/server";
|
|
671
|
+
import { NextIntlClientProvider } from "next-intl";
|
|
672
|
+
import pick from "lodash/pick";
|
|
673
|
+
import ServerComponent from "@/components/ServerComponent";
|
|
674
|
+
import ClientComponentExample from "@/components/ClientComponentExample";
|
|
551
675
|
|
|
552
|
-
export
|
|
676
|
+
export const dynamic = "force-static";
|
|
677
|
+
|
|
678
|
+
export default async function AboutPage({
|
|
553
679
|
params,
|
|
554
680
|
}: {
|
|
555
|
-
params: { locale: string }
|
|
681
|
+
params: Promise<{ locale: string }>;
|
|
556
682
|
}) {
|
|
557
|
-
|
|
558
|
-
|
|
683
|
+
const { locale } = await params;
|
|
684
|
+
|
|
685
|
+
// Messages are loaded server-side. Push only what's needed to the client.
|
|
686
|
+
const messages = await getMessages();
|
|
687
|
+
const clientMessages = pick(messages, ["common", "about"]);
|
|
688
|
+
|
|
689
|
+
// Strictly server-side translations/formatting
|
|
690
|
+
const tAbout = await getTranslations("about");
|
|
691
|
+
const tCounter = await getTranslations("about.counter");
|
|
692
|
+
const format = await getFormatter();
|
|
693
|
+
|
|
694
|
+
const initialFormattedCount = format.number(0);
|
|
559
695
|
|
|
560
696
|
return (
|
|
561
|
-
<
|
|
562
|
-
<
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
697
|
+
<NextIntlClientProvider locale={locale} messages={clientMessages}>
|
|
698
|
+
<main>
|
|
699
|
+
<h1>{tAbout("title")}</h1>
|
|
700
|
+
<ClientComponentExample />
|
|
701
|
+
<ServerComponent
|
|
702
|
+
formattedCount={initialFormattedCount}
|
|
703
|
+
label={tCounter("label")}
|
|
704
|
+
increment={tCounter("increment")}
|
|
705
|
+
/>
|
|
706
|
+
</main>
|
|
707
|
+
</NextIntlClientProvider>
|
|
566
708
|
);
|
|
567
709
|
}
|
|
568
710
|
```
|
|
569
711
|
|
|
570
712
|
</TabItem>
|
|
571
|
-
<TabItem label="intlayer" value="intlayer">
|
|
713
|
+
<TabItem label="intlayer" value="intlayer">
|
|
572
714
|
|
|
573
715
|
```tsx fileName="intlayer.config.ts"
|
|
574
|
-
|
|
716
|
+
import { type IntlayerConfig, Locales } from "intlayer";
|
|
717
|
+
|
|
718
|
+
const config: IntlayerConfig = {
|
|
575
719
|
internationalization: {
|
|
576
|
-
locales: [
|
|
577
|
-
defaultLocale:
|
|
720
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
721
|
+
defaultLocale: Locales.ENGLISH,
|
|
578
722
|
},
|
|
579
723
|
};
|
|
724
|
+
|
|
725
|
+
export default config;
|
|
580
726
|
```
|
|
581
727
|
|
|
582
728
|
```tsx fileName="src/app/[locale]/layout.tsx"
|
|
@@ -589,14 +735,16 @@ import {
|
|
|
589
735
|
|
|
590
736
|
export const dynamic = "force-static";
|
|
591
737
|
|
|
592
|
-
const
|
|
738
|
+
const LocaleLayout: NextLayoutIntlayer = async ({ children, params }) => {
|
|
593
739
|
const { locale } = await params;
|
|
594
740
|
|
|
595
741
|
return (
|
|
596
742
|
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
597
|
-
<
|
|
598
|
-
{
|
|
599
|
-
|
|
743
|
+
<body>
|
|
744
|
+
<IntlayerClientProvider locale={locale}>
|
|
745
|
+
{children}
|
|
746
|
+
</IntlayerClientProvider>
|
|
747
|
+
</body>
|
|
600
748
|
</html>
|
|
601
749
|
);
|
|
602
750
|
};
|
|
@@ -853,10 +1001,11 @@ const ServerComponent = ({ count }: ServerComponentProps) => {
|
|
|
853
1001
|
type ServerComponentProps = {
|
|
854
1002
|
count: number;
|
|
855
1003
|
t: (key: string) => string;
|
|
1004
|
+
formatter: Intl.NumberFormat;
|
|
856
1005
|
};
|
|
857
1006
|
|
|
858
|
-
const ServerComponent = ({ t, count }: ServerComponentProps) => {
|
|
859
|
-
const formatted =
|
|
1007
|
+
const ServerComponent = ({ t, count, formatter }: ServerComponentProps) => {
|
|
1008
|
+
const formatted = formatter.format(count);
|
|
860
1009
|
|
|
861
1010
|
return (
|
|
862
1011
|
<div>
|
|
@@ -870,7 +1019,7 @@ const ServerComponent = ({ t, count }: ServerComponentProps) => {
|
|
|
870
1019
|
> Da die Server-Komponente nicht asynchron sein kann, müssen Sie die Übersetzungen und die Formatierungsfunktion als Props übergeben.
|
|
871
1020
|
>
|
|
872
1021
|
> - `const t = await getTranslations("about.counter");`
|
|
873
|
-
> - `const
|
|
1022
|
+
> - `const formatter = await getFormatter().then((formatter) => formatter.number());`
|
|
874
1023
|
|
|
875
1024
|
</TabItem>
|
|
876
1025
|
<TabItem label="intlayer" value="intlayer">
|