@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-09-04
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title: React Router v7でのIntlayer
|
|
5
|
-
description: Intlayer
|
|
3
|
+
updatedAt: 2025-10-03
|
|
4
|
+
title: React Router v7でのIntlayerを使った国際化の始め方
|
|
5
|
+
description: Intlayerを使用してReact Router v7アプリケーションに国際化(i18n)を追加する方法を学びます。ロケール対応ルーティングでアプリを多言語化するための包括的なガイドに従ってください。
|
|
6
6
|
keywords:
|
|
7
7
|
- 国際化
|
|
8
8
|
- ドキュメント
|
|
@@ -17,24 +17,23 @@ slugs:
|
|
|
17
17
|
- environment
|
|
18
18
|
- vite-and-react
|
|
19
19
|
- react-router-v7
|
|
20
|
-
applicationTemplate: https://github.com/
|
|
21
|
-
author: AydinTheFirst
|
|
20
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-react-router-v7-template
|
|
22
21
|
---
|
|
23
22
|
|
|
24
|
-
# IntlayerとReact Router v7
|
|
23
|
+
# IntlayerとReact Router v7を使った国際化(i18n)の始め方
|
|
25
24
|
|
|
26
|
-
このガイドでは、React Router v7プロジェクトにおいて、ロケール対応ルーティング、TypeScript
|
|
25
|
+
このガイドでは、React Router v7プロジェクトにおいて、ロケール対応ルーティング、TypeScriptサポート、最新の開発手法を活用しながら、**Intlayer**を使ったシームレスな国際化の統合方法を説明します。
|
|
27
26
|
|
|
28
27
|
## Intlayerとは?
|
|
29
28
|
|
|
30
|
-
**Intlayer
|
|
29
|
+
**Intlayer**は、現代のウェブアプリケーションにおける多言語対応を簡素化するために設計された革新的なオープンソースの国際化(i18n)ライブラリです。
|
|
31
30
|
|
|
32
31
|
Intlayerを使うことで、以下が可能になります:
|
|
33
32
|
|
|
34
|
-
-
|
|
33
|
+
- **コンポーネントレベルで宣言的辞書を使い、翻訳を簡単に管理**できます。
|
|
35
34
|
- **メタデータ、ルート、コンテンツを動的にローカライズ**できます。
|
|
36
35
|
- **自動生成される型情報によりTypeScriptサポートを確保し、オートコンプリートやエラー検出を向上**させます。
|
|
37
|
-
-
|
|
36
|
+
- **動的なロケール検出や切り替えなどの高度な機能**を活用できます。
|
|
38
37
|
- **React Router v7の設定ベースのルーティングシステムを使って、ロケール対応ルーティングを有効化**します。
|
|
39
38
|
|
|
40
39
|
---
|
|
@@ -43,7 +42,7 @@ Intlayerを使うことで、以下が可能になります:
|
|
|
43
42
|
|
|
44
43
|
### ステップ1: 依存パッケージのインストール
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
お好みのパッケージマネージャーを使って必要なパッケージをインストールします:
|
|
47
46
|
|
|
48
47
|
```bash packageManager="npm"
|
|
49
48
|
npm install intlayer react-intlayer
|
|
@@ -61,7 +60,7 @@ pnpm add vite-intlayer --save-dev
|
|
|
61
60
|
設定管理、翻訳、[コンテンツ宣言](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/get_started.md)、トランスパイル、および[CLIコマンド](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_cli.md)のための国際化ツールを提供するコアパッケージ。
|
|
62
61
|
|
|
63
62
|
- **react-intlayer**
|
|
64
|
-
IntlayerをReact
|
|
63
|
+
IntlayerをReactアプリケーションと統合するパッケージです。Reactの国際化のためのコンテキストプロバイダーとフックを提供します。
|
|
65
64
|
|
|
66
65
|
- **vite-intlayer**
|
|
67
66
|
Intlayerを[Viteバンドラー](https://vite.dev/guide/why.html#why-bundle-for-production)と統合するためのViteプラグイン、およびユーザーの優先ロケール検出、クッキー管理、URLリダイレクト処理のためのミドルウェアを含みます。
|
|
@@ -75,11 +74,8 @@ import { type IntlayerConfig, Locales } from "intlayer";
|
|
|
75
74
|
|
|
76
75
|
const config: IntlayerConfig = {
|
|
77
76
|
internationalization: {
|
|
78
|
-
defaultLocale: Locales.ENGLISH,
|
|
79
|
-
locales: [Locales.ENGLISH, Locales.
|
|
80
|
-
},
|
|
81
|
-
middleware: {
|
|
82
|
-
prefixDefault: true, // URLに常にデフォルトのロケールをプレフィックスとして付ける
|
|
77
|
+
defaultLocale: Locales.ENGLISH, // デフォルトのロケールを英語に設定
|
|
78
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], // 利用可能なロケールのリスト
|
|
83
79
|
},
|
|
84
80
|
};
|
|
85
81
|
|
|
@@ -92,11 +88,8 @@ import { Locales } from "intlayer";
|
|
|
92
88
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
93
89
|
const config = {
|
|
94
90
|
internationalization: {
|
|
95
|
-
defaultLocale: Locales.ENGLISH,
|
|
96
|
-
locales: [Locales.ENGLISH, Locales.
|
|
97
|
-
},
|
|
98
|
-
middleware: {
|
|
99
|
-
prefixDefault: true,
|
|
91
|
+
defaultLocale: Locales.ENGLISH, // デフォルトのロケールを英語に設定
|
|
92
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH], // 利用可能なロケールのリスト
|
|
100
93
|
},
|
|
101
94
|
};
|
|
102
95
|
|
|
@@ -107,86 +100,78 @@ export default config;
|
|
|
107
100
|
const { Locales } = require("intlayer");
|
|
108
101
|
|
|
109
102
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
110
|
-
// IntlayerConfigの型注釈
|
|
111
103
|
const config = {
|
|
112
104
|
internationalization: {
|
|
113
|
-
defaultLocale: Locales.ENGLISH,
|
|
114
|
-
locales: [Locales.ENGLISH, Locales.
|
|
115
|
-
},
|
|
116
|
-
middleware: {
|
|
117
|
-
prefixDefault: true, // デフォルトロケールのURLに常にプレフィックスを付ける
|
|
105
|
+
defaultLocale: Locales.ENGLISH,
|
|
106
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
118
107
|
},
|
|
119
108
|
};
|
|
120
109
|
|
|
121
110
|
module.exports = config;
|
|
122
111
|
```
|
|
123
112
|
|
|
124
|
-
> この設定ファイルを通じて、ローカライズされたURL
|
|
125
|
-
|
|
126
|
-
### ステップ 3: React Router v7 のルートを設定する
|
|
127
|
-
|
|
128
|
-
ロケール対応のルートでルーティング設定を行います:
|
|
129
|
-
|
|
130
|
-
```typescript fileName="app/routes.ts" codeFormat="typescript"
|
|
131
|
-
import { layout, route, type RouteConfig } from "@react-router/dev/routes";
|
|
132
|
-
|
|
133
|
-
export default [
|
|
134
|
-
layout("routes/layout.tsx", [
|
|
135
|
-
route("/", "routes/page.tsx"), // ルートページ - ロケールへリダイレクト
|
|
136
|
-
route("/:lang", "routes/[lang]/page.tsx"), // ローカライズされたホームページ
|
|
137
|
-
route("/:lang/about", "routes/[lang]/about/page.tsx"), // ローカライズされたアバウトページ
|
|
138
|
-
]),
|
|
139
|
-
] satisfies RouteConfig;
|
|
140
|
-
```
|
|
113
|
+
> この設定ファイルを通じて、ローカライズされたURL、ミドルウェアのリダイレクション、クッキー名、コンテンツ宣言の場所と拡張子、コンソールでのIntlayerログの無効化などを設定できます。利用可能なパラメータの完全なリストについては、[設定ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/configuration.md)を参照してください。
|
|
141
114
|
|
|
142
|
-
### ステップ
|
|
115
|
+
### ステップ3: Vite設定にIntlayerを統合する
|
|
143
116
|
|
|
144
|
-
設定にintlayer
|
|
117
|
+
設定にintlayerプラグインを追加します:
|
|
145
118
|
|
|
146
|
-
```typescript fileName="vite.config.ts"
|
|
119
|
+
```typescript fileName="vite.config.ts"
|
|
147
120
|
import { reactRouter } from "@react-router/dev/vite";
|
|
148
121
|
import { defineConfig } from "vite";
|
|
149
|
-
import {
|
|
122
|
+
import { intlayer } from "vite-intlayer";
|
|
150
123
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
151
124
|
|
|
152
125
|
export default defineConfig({
|
|
153
|
-
plugins: [
|
|
154
|
-
reactRouter(),
|
|
155
|
-
tsconfigPaths(),
|
|
156
|
-
intlayer(),
|
|
157
|
-
intlayerMiddlewarePlugin(),
|
|
158
|
-
],
|
|
126
|
+
plugins: [reactRouter(), tsconfigPaths(), intlayer()],
|
|
159
127
|
});
|
|
160
128
|
```
|
|
161
129
|
|
|
162
130
|
> `intlayer()` Viteプラグインは、IntlayerをViteと統合するために使用されます。これにより、コンテンツ宣言ファイルのビルドが保証され、開発モードで監視されます。また、Viteアプリケーション内でIntlayerの環境変数を定義します。さらに、パフォーマンスを最適化するためのエイリアスも提供します。
|
|
163
131
|
|
|
132
|
+
### ステップ4: React Router v7のルートを設定する
|
|
133
|
+
|
|
134
|
+
ロケール対応のルートでルーティング設定を行います:
|
|
135
|
+
|
|
136
|
+
```typescript fileName="app/routes.ts"
|
|
137
|
+
import { layout, route, type RouteConfig } from "@react-router/dev/routes";
|
|
138
|
+
|
|
139
|
+
export default [
|
|
140
|
+
layout("routes/layout.tsx", [
|
|
141
|
+
route("/:lang?", "routes/page.tsx"), // ローカライズされたホームページ
|
|
142
|
+
route("/:lang?/about", "routes/about/page.tsx"), // ローカライズされたアバウトページ
|
|
143
|
+
]),
|
|
144
|
+
] satisfies RouteConfig;
|
|
145
|
+
```
|
|
146
|
+
|
|
164
147
|
### ステップ5: レイアウトコンポーネントの作成
|
|
165
148
|
|
|
166
|
-
|
|
149
|
+
ルートレイアウトとロケール固有のレイアウトを設定します:
|
|
167
150
|
|
|
168
151
|
#### ルートレイアウト
|
|
169
152
|
|
|
170
|
-
```tsx fileName="app/routes/layout.tsx"
|
|
171
|
-
tsx;
|
|
172
|
-
// app/routes/layout.tsx
|
|
173
|
-
import { Outlet } from "react-router";
|
|
153
|
+
```tsx fileName="app/routes/layout.tsx"
|
|
174
154
|
import { IntlayerProvider } from "react-intlayer";
|
|
155
|
+
import { Outlet } from "react-router";
|
|
156
|
+
|
|
157
|
+
import type { Route } from "./+types/layout";
|
|
158
|
+
|
|
159
|
+
export default function RootLayout({ params }: Route.ComponentProps) {
|
|
160
|
+
const { locale } = params;
|
|
175
161
|
|
|
176
|
-
export default function RootLayout() {
|
|
177
162
|
return (
|
|
178
|
-
<IntlayerProvider>
|
|
163
|
+
<IntlayerProvider locale={locale}>
|
|
179
164
|
<Outlet />
|
|
180
165
|
</IntlayerProvider>
|
|
181
166
|
);
|
|
182
167
|
}
|
|
183
168
|
```
|
|
184
169
|
|
|
185
|
-
### ステップ6: コンテンツを宣言する
|
|
170
|
+
### ステップ 6: コンテンツを宣言する
|
|
186
171
|
|
|
187
|
-
|
|
172
|
+
翻訳を格納するためのコンテンツ宣言を作成および管理します:
|
|
188
173
|
|
|
189
|
-
```tsx fileName="app/routes/[lang]/page.content.ts"
|
|
174
|
+
```tsx fileName="app/routes/[lang]/page.content.ts"
|
|
190
175
|
import { t, type Dictionary } from "intlayer";
|
|
191
176
|
|
|
192
177
|
const pageContent = {
|
|
@@ -194,19 +179,23 @@ const pageContent = {
|
|
|
194
179
|
content: {
|
|
195
180
|
title: t({
|
|
196
181
|
en: "Welcome to React Router v7 + Intlayer",
|
|
197
|
-
|
|
182
|
+
es: "Bienvenido a React Router v7 + Intlayer",
|
|
183
|
+
fr: "Bienvenue sur React Router v7 + Intlayer",
|
|
198
184
|
}),
|
|
199
185
|
description: t({
|
|
200
186
|
en: "Build multilingual applications with ease using React Router v7 and Intlayer.",
|
|
201
|
-
|
|
187
|
+
es: "Cree aplicaciones multilingües fácilmente usando React Router v7 y Intlayer.",
|
|
188
|
+
fr: "Créez des applications multilingues facilement avec React Router v7 et Intlayer.",
|
|
202
189
|
}),
|
|
203
190
|
aboutLink: t({
|
|
204
|
-
en: "
|
|
205
|
-
|
|
191
|
+
en: "私たちについて学ぶ",
|
|
192
|
+
es: "Aprender Sobre Nosotros",
|
|
193
|
+
fr: "En savoir plus sur nous",
|
|
206
194
|
}),
|
|
207
195
|
homeLink: t({
|
|
208
|
-
en: "
|
|
209
|
-
|
|
196
|
+
en: "ホーム",
|
|
197
|
+
es: "Inicio",
|
|
198
|
+
fr: "Accueil",
|
|
210
199
|
}),
|
|
211
200
|
},
|
|
212
201
|
} satisfies Dictionary;
|
|
@@ -214,104 +203,93 @@ const pageContent = {
|
|
|
214
203
|
export default pageContent;
|
|
215
204
|
```
|
|
216
205
|
|
|
217
|
-
>
|
|
206
|
+
> コンテンツ宣言は、`contentDir` ディレクトリ(デフォルトは `./app`)に含まれている限り、アプリケーションのどこにでも定義できます。また、コンテンツ宣言ファイルの拡張子(デフォルトは `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`)に一致する必要があります。
|
|
218
207
|
|
|
219
|
-
> 詳細については、[
|
|
208
|
+
> 詳細については、[コンテンツ宣言ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/get_started.md)を参照してください。
|
|
220
209
|
|
|
221
210
|
### ステップ7: ロケール対応コンポーネントの作成
|
|
222
211
|
|
|
223
|
-
|
|
212
|
+
ロケール対応のナビゲーション用に `LocalizedLink` コンポーネントを作成します:
|
|
224
213
|
|
|
225
|
-
```tsx fileName="app/components/localized-link.tsx"
|
|
226
|
-
|
|
227
|
-
import { getLocalizedUrl } from "intlayer";
|
|
228
|
-
import { useLocale } from "react-intlayer";
|
|
229
|
-
import React from "react";
|
|
230
|
-
import { Link, useLocation } from "react-router";
|
|
231
|
-
|
|
232
|
-
type RouterLinkProps = React.ComponentProps<typeof Link>;
|
|
214
|
+
```tsx fileName="app/components/localized-link.tsx"
|
|
215
|
+
import type { FC } from "react";
|
|
233
216
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
217
|
+
import { getLocalizedUrl, type LocalesValues } from "intlayer";
|
|
218
|
+
import { useLocale } from "react-intlayer";
|
|
219
|
+
import { Link, type LinkProps, type To } from "react-router";
|
|
237
220
|
|
|
238
|
-
|
|
239
|
-
|
|
221
|
+
// 外部リンクかどうかを判定する関数
|
|
222
|
+
const isExternalLink = (to: string) => /^(https?:)?\/\//.test(to);
|
|
240
223
|
|
|
224
|
+
// 指定されたURLをロケールに応じてローカライズする関数
|
|
225
|
+
export const locacalizeTo = (to: To, locale: LocalesValues): To => {
|
|
241
226
|
if (typeof to === "string") {
|
|
242
|
-
if (
|
|
243
|
-
return
|
|
227
|
+
if (isExternalLink(to)) {
|
|
228
|
+
return to;
|
|
244
229
|
}
|
|
245
|
-
|
|
230
|
+
|
|
231
|
+
return getLocalizedUrl(to, locale);
|
|
246
232
|
}
|
|
247
233
|
|
|
248
|
-
if (to
|
|
249
|
-
|
|
250
|
-
if (pathname && pathname.startsWith("/") && !isExternal(pathname)) {
|
|
251
|
-
return (
|
|
252
|
-
<Link
|
|
253
|
-
to={{ ...to, pathname: getLocalizedUrl(pathname, locale) }}
|
|
254
|
-
{...props}
|
|
255
|
-
/>
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
return <Link to={to} {...props} />;
|
|
234
|
+
if (isExternalLink(to.pathname ?? "")) {
|
|
235
|
+
return to;
|
|
259
236
|
}
|
|
260
237
|
|
|
261
|
-
return
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
```
|
|
238
|
+
return {
|
|
239
|
+
...to,
|
|
240
|
+
pathname: getLocalizedUrl(to.pathname ?? "", locale),
|
|
241
|
+
};
|
|
242
|
+
};
|
|
269
243
|
|
|
270
|
-
|
|
244
|
+
// ロケール対応のリンクコンポーネント
|
|
245
|
+
export const LocalizedLink: FC<LinkProps> = (props) => {
|
|
246
|
+
const { locale } = useLocale();
|
|
271
247
|
|
|
272
|
-
|
|
248
|
+
return <Link {...props} to={locacalizeTo(props.to, locale)} />;
|
|
249
|
+
};
|
|
250
|
+
```
|
|
273
251
|
|
|
274
|
-
|
|
252
|
+
ローカライズされたルートにナビゲートしたい場合は、`useLocalizedNavigate` フックを使用できます。
|
|
275
253
|
|
|
276
|
-
```tsx fileName="app/
|
|
277
|
-
|
|
278
|
-
import {
|
|
279
|
-
import { Navigate } from "react-router";
|
|
254
|
+
```tsx fileName="app/hooks/useLocalizedNavigate.ts"
|
|
255
|
+
import { useLocale } from "intlayer";
|
|
256
|
+
import { type NavigateOptions, type To, useNavigate } from "react-router";
|
|
280
257
|
|
|
281
|
-
|
|
258
|
+
import { locacalizeTo } from "~/components/localized-link";
|
|
259
|
+
|
|
260
|
+
export const useLocalizedNavigate = () => {
|
|
261
|
+
const navigate = useNavigate();
|
|
282
262
|
const { locale } = useLocale();
|
|
283
263
|
|
|
284
|
-
|
|
285
|
-
|
|
264
|
+
const localizedNavigate = (to: To, options?: NavigateOptions) => {
|
|
265
|
+
const localedTo = locacalizeTo(to, locale);
|
|
266
|
+
|
|
267
|
+
navigate(localedTo, options);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
return localizedNavigate;
|
|
271
|
+
};
|
|
286
272
|
```
|
|
287
273
|
|
|
274
|
+
### ステップ8: ページで Intlayer を活用する
|
|
275
|
+
|
|
276
|
+
アプリケーション全体でコンテンツ辞書にアクセスします:
|
|
277
|
+
|
|
288
278
|
#### ローカライズされたホームページ
|
|
289
279
|
|
|
290
|
-
```tsx fileName="app/routes/[lang]/page.tsx"
|
|
280
|
+
```tsx fileName="app/routes/[lang]/page.tsx"
|
|
291
281
|
import { useIntlayer } from "react-intlayer";
|
|
292
|
-
import LocalizedLink from "~/components/localized-link";
|
|
282
|
+
import { LocalizedLink } from "~/components/localized-link";
|
|
293
283
|
|
|
294
284
|
export default function Page() {
|
|
295
|
-
const
|
|
285
|
+
const { title, description, aboutLink } = useIntlayer("page");
|
|
296
286
|
|
|
297
287
|
return (
|
|
298
|
-
<div
|
|
299
|
-
<h1>{
|
|
300
|
-
<p>{
|
|
301
|
-
<nav
|
|
302
|
-
<LocalizedLink
|
|
303
|
-
to="/about"
|
|
304
|
-
style={{
|
|
305
|
-
display: "inline-block",
|
|
306
|
-
padding: "0.5rem 1rem",
|
|
307
|
-
backgroundColor: "#007bff",
|
|
308
|
-
color: "white",
|
|
309
|
-
textDecoration: "none",
|
|
310
|
-
borderRadius: "4px",
|
|
311
|
-
}}
|
|
312
|
-
>
|
|
313
|
-
{content.aboutLink}
|
|
314
|
-
</LocalizedLink>
|
|
288
|
+
<div>
|
|
289
|
+
<h1>{title}</h1>
|
|
290
|
+
<p>{description}</p>
|
|
291
|
+
<nav>
|
|
292
|
+
<LocalizedLink to="/about">{aboutLink}</LocalizedLink>
|
|
315
293
|
</nav>
|
|
316
294
|
</div>
|
|
317
295
|
);
|
|
@@ -320,57 +298,71 @@ export default function Page() {
|
|
|
320
298
|
|
|
321
299
|
> `useIntlayer` フックの詳細については、[ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/react-intlayer/useIntlayer.md)を参照してください。
|
|
322
300
|
|
|
323
|
-
### ステップ9
|
|
301
|
+
### ステップ9:ロケールスイッチャーコンポーネントを作成する
|
|
324
302
|
|
|
325
303
|
ユーザーが言語を変更できるコンポーネントを作成します:
|
|
326
304
|
|
|
327
|
-
```tsx fileName="app/components/locale-switcher.tsx"
|
|
328
|
-
import {
|
|
329
|
-
import { useLocale } from "react-intlayer";
|
|
330
|
-
import { useLocation, useNavigate } from "react-router";
|
|
305
|
+
```tsx fileName="app/components/locale-switcher.tsx"
|
|
306
|
+
import type { FC } from "react";
|
|
331
307
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
308
|
+
import {
|
|
309
|
+
getHTMLTextDir,
|
|
310
|
+
getLocaleName,
|
|
311
|
+
getLocalizedUrl,
|
|
312
|
+
getPathWithoutLocale,
|
|
313
|
+
} from "intlayer";
|
|
314
|
+
import { setLocaleCookie, useIntlayer, useLocale } from "react-intlayer";
|
|
315
|
+
import { Link, useLocation } from "react-router";
|
|
336
316
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
};
|
|
317
|
+
export const LocaleSwitcher: FC = () => {
|
|
318
|
+
const { localeSwitcherLabel } = useIntlayer("locale-switcher"); // ロケールスイッチャーのラベルを取得
|
|
319
|
+
const { pathname } = useLocation(); // 現在のパス名を取得
|
|
320
|
+
|
|
321
|
+
const { availableLocales, locale } = useLocale(); // 利用可能なロケールと現在のロケールを取得
|
|
322
|
+
|
|
323
|
+
const pathWithoutLocale = getPathWithoutLocale(pathname); // パスからロケール部分を除去
|
|
345
324
|
|
|
346
325
|
return (
|
|
347
|
-
<
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
326
|
+
<ol>
|
|
327
|
+
{availableLocales.map((localeItem) => (
|
|
328
|
+
<li key={localeItem}>
|
|
329
|
+
<Link
|
|
330
|
+
aria-current={localeItem === locale ? "page" : undefined}
|
|
331
|
+
aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeItem)}`}
|
|
332
|
+
onClick={() => setLocaleCookie(localeItem)}
|
|
333
|
+
to={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
334
|
+
>
|
|
335
|
+
<span>
|
|
336
|
+
{/* ロケール - 例: FR */}
|
|
337
|
+
{localeItem}
|
|
338
|
+
</span>
|
|
339
|
+
<span>
|
|
340
|
+
{/* 自身のロケールでの言語名 - 例: Français */}
|
|
341
|
+
{getLocaleName(localeItem, locale)}
|
|
342
|
+
</span>
|
|
343
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
344
|
+
{/* 現在のロケールでの言語名 - 例: 現在のロケールがLocales.SPANISHの場合のFrancés */}
|
|
345
|
+
{getLocaleName(localeItem)}
|
|
346
|
+
</span>
|
|
347
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
348
|
+
{/* 英語での言語名 - 例: French */}
|
|
349
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
350
|
+
</span>
|
|
351
|
+
</Link>
|
|
352
|
+
</li>
|
|
353
|
+
))}
|
|
354
|
+
</ol>
|
|
362
355
|
);
|
|
363
|
-
}
|
|
356
|
+
};
|
|
364
357
|
```
|
|
365
358
|
|
|
366
359
|
> `useLocale` フックの詳細については、[ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/react-intlayer/useLocale.md)を参照してください。
|
|
367
360
|
|
|
368
361
|
### ステップ10: HTML属性の管理を追加(オプション)
|
|
369
362
|
|
|
370
|
-
HTMLの
|
|
363
|
+
HTMLのlang属性とdir属性を管理するフックを作成します:
|
|
371
364
|
|
|
372
|
-
```tsx fileName="app/hooks/useI18nHTMLAttributes.tsx"
|
|
373
|
-
// app/hooks/useI18nHTMLAttributes.tsx
|
|
365
|
+
```tsx fileName="app/hooks/useI18nHTMLAttributes.tsx"
|
|
374
366
|
import { getHTMLTextDir } from "intlayer";
|
|
375
367
|
import { useEffect } from "react";
|
|
376
368
|
import { useLocale } from "react-intlayer";
|
|
@@ -387,8 +379,7 @@ export const useI18nHTMLAttributes = () => {
|
|
|
387
379
|
|
|
388
380
|
次に、ルートコンポーネントでこれを使用します:
|
|
389
381
|
|
|
390
|
-
```tsx fileName="app/
|
|
391
|
-
// app/routes/layout.tsx
|
|
382
|
+
```tsx fileName="app/routes/layout.tsx"
|
|
392
383
|
import { Outlet } from "react-router";
|
|
393
384
|
import { IntlayerProvider } from "react-intlayer";
|
|
394
385
|
|
|
@@ -405,57 +396,48 @@ export default function RootLayout() {
|
|
|
405
396
|
}
|
|
406
397
|
```
|
|
407
398
|
|
|
408
|
-
### ステップ11:
|
|
409
|
-
|
|
410
|
-
コンテンツ辞書をビルドしてアプリケーションを実行します:
|
|
399
|
+
### ステップ11: ミドルウェアを追加する(オプション)
|
|
411
400
|
|
|
412
|
-
|
|
413
|
-
# Intlayerの辞書をビルド
|
|
414
|
-
npm run intlayer:build
|
|
401
|
+
`intlayerMiddleware` を使用して、アプリケーションにサーバーサイドルーティングを追加することもできます。このプラグインは、URL に基づいて現在のロケールを自動的に検出し、適切なロケールクッキーを設定します。ロケールが指定されていない場合、プラグインはユーザーのブラウザの言語設定に基づいて最も適切なロケールを判断します。ロケールが検出されない場合は、デフォルトのロケールにリダイレクトします。
|
|
415
402
|
|
|
416
|
-
|
|
417
|
-
npm run dev
|
|
418
|
-
```
|
|
403
|
+
> `intlayerMiddleware` を本番環境で使用するには、`vite-intlayer` パッケージを `devDependencies` から `dependencies` に切り替える必要があることに注意してください。
|
|
419
404
|
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
|
|
405
|
+
```typescript {3,7} fileName="vite.config.ts"
|
|
406
|
+
import { defineConfig } from "vite";
|
|
407
|
+
import react from "@vitejs/plugin-react-swc";
|
|
408
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
423
409
|
|
|
424
|
-
|
|
425
|
-
|
|
410
|
+
// https://vitejs.dev/config/
|
|
411
|
+
export default defineConfig({
|
|
412
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
413
|
+
});
|
|
426
414
|
```
|
|
427
415
|
|
|
428
|
-
|
|
429
|
-
# Intlayerの辞書をビルド
|
|
430
|
-
yarn intlayer:build
|
|
431
|
-
|
|
432
|
-
# 開発サーバーを起動
|
|
433
|
-
yarn dev
|
|
434
|
-
```
|
|
416
|
+
---
|
|
435
417
|
|
|
436
|
-
|
|
418
|
+
## TypeScriptの設定
|
|
437
419
|
|
|
438
|
-
Intlayer
|
|
420
|
+
Intlayerはモジュール拡張を使用して、TypeScriptの利点を活かし、コードベースをより強固にします。
|
|
439
421
|
|
|
440
|
-
TypeScript
|
|
422
|
+
TypeScriptの設定に自動生成された型が含まれていることを確認してください。
|
|
441
423
|
|
|
442
424
|
```json5 fileName="tsconfig.json"
|
|
443
425
|
{
|
|
444
|
-
|
|
445
|
-
// ... 既存のTypeScript設定
|
|
446
|
-
},
|
|
426
|
+
// ... 既存の設定
|
|
447
427
|
include: [
|
|
448
|
-
// ...
|
|
428
|
+
// ... 既存のinclude
|
|
449
429
|
".intlayer/**/*.ts", // 自動生成された型を含める
|
|
450
430
|
],
|
|
451
431
|
}
|
|
452
432
|
```
|
|
453
433
|
|
|
454
|
-
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Gitの設定
|
|
455
437
|
|
|
456
438
|
Intlayerによって生成されたファイルは無視することを推奨します。これにより、Gitリポジトリへのコミットを避けることができます。
|
|
457
439
|
|
|
458
|
-
これを行うには、`.gitignore
|
|
440
|
+
これを行うには、`.gitignore`ファイルに以下の指示を追加してください。
|
|
459
441
|
|
|
460
442
|
```plaintext fileName=".gitignore"
|
|
461
443
|
# Intlayerによって生成されたファイルを無視する
|
|
@@ -464,55 +446,26 @@ Intlayerによって生成されたファイルは無視することを推奨し
|
|
|
464
446
|
|
|
465
447
|
---
|
|
466
448
|
|
|
467
|
-
##
|
|
468
|
-
|
|
469
|
-
アプリケーションをデプロイする際は:
|
|
470
|
-
|
|
471
|
-
1. **アプリケーションをビルドする:**
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
npm run build
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
2. **Intlayerの辞書をビルドする:**
|
|
478
|
-
|
|
479
|
-
```bash
|
|
480
|
-
npm run intlayer:build
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
3. **本番環境でミドルウェアを使用する場合は、`vite-intlayer`を依存関係に移動する:**
|
|
484
|
-
```bash
|
|
485
|
-
npm install vite-intlayer --save
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
あなたのアプリケーションは以下をサポートします:
|
|
489
|
-
|
|
490
|
-
- **URL構造**: `/en`、`/en/about`、`/tr`、`/tr/about`
|
|
491
|
-
- ブラウザの設定に基づく**自動ロケール検出**
|
|
492
|
-
- React Router v7による**ロケール対応ルーティング**
|
|
493
|
-
- 自動生成された型定義による**TypeScriptサポート**
|
|
494
|
-
- 適切なロケール処理を伴う**サーバーサイドレンダリング**
|
|
495
|
-
|
|
496
|
-
## VS Code拡張機能
|
|
449
|
+
## VS Code 拡張機能
|
|
497
450
|
|
|
498
|
-
Intlayer
|
|
451
|
+
Intlayerでの開発体験を向上させるために、公式の **Intlayer VS Code 拡張機能** をインストールできます。
|
|
499
452
|
|
|
500
|
-
[VS Code
|
|
453
|
+
[VS Code Marketplaceからインストール](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
501
454
|
|
|
502
455
|
この拡張機能は以下を提供します:
|
|
503
456
|
|
|
504
|
-
-
|
|
505
|
-
-
|
|
506
|
-
-
|
|
507
|
-
-
|
|
457
|
+
- 翻訳キーの **自動補完**。
|
|
458
|
+
- 翻訳が不足している場合の **リアルタイムエラー検出**。
|
|
459
|
+
- 翻訳内容の **インラインプレビュー**。
|
|
460
|
+
- 翻訳を簡単に作成・更新できる **クイックアクション**。
|
|
508
461
|
|
|
509
|
-
|
|
462
|
+
拡張機能の使い方の詳細は、[Intlayer VS Code 拡張機能のドキュメント](https://intlayer.org/doc/vs-code-extension)を参照してください。
|
|
510
463
|
|
|
511
464
|
---
|
|
512
465
|
|
|
513
|
-
##
|
|
466
|
+
## さらに進む
|
|
514
467
|
|
|
515
|
-
|
|
468
|
+
さらに進めるために、[ビジュアルエディター](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_visual_editor.md)を実装するか、[CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_CMS.md)を使用してコンテンツを外部化することができます。
|
|
516
469
|
|
|
517
470
|
---
|
|
518
471
|
|
|
@@ -525,10 +478,11 @@ Intlayerでの開発体験を向上させるために、公式の**Intlayer VS C
|
|
|
525
478
|
- [コンテンツ宣言](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/get_started.md)
|
|
526
479
|
- [設定](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/configuration.md)
|
|
527
480
|
|
|
528
|
-
この包括的なガイドは、Intlayer
|
|
481
|
+
この包括的なガイドは、IntlayerをReact Router v7と統合し、ロケール対応のルーティングとTypeScriptサポートを備えた完全に国際化されたアプリケーションを構築するために必要なすべてを提供します。
|
|
529
482
|
|
|
530
483
|
## ドキュメント履歴
|
|
531
484
|
|
|
532
|
-
| バージョン | 日付
|
|
533
|
-
| ---------- |
|
|
534
|
-
|
|
|
485
|
+
| バージョン | 日付 | 変更内容 |
|
|
486
|
+
| ---------- | ---------- | ----------------------- |
|
|
487
|
+
| 6.1.5 | 2025-10-03 | ドキュメント更新 |
|
|
488
|
+
| 5.8.2 | 2025-09-04 | React Router v7対応追加 |
|