@intlayer/docs 8.3.0-canary.4 → 8.3.1
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/docs/ar/compiler.md +84 -49
- package/docs/ar/configuration.md +80 -37
- package/docs/ar/intlayer_with_nextjs_16.md +174 -1
- package/docs/ar/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/ar/intlayer_with_react_router_v7.md +224 -1
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/ar/intlayer_with_svelte_kit.md +175 -2
- package/docs/ar/intlayer_with_tanstack.md +176 -1
- package/docs/ar/intlayer_with_vite+preact.md +174 -1
- package/docs/ar/intlayer_with_vite+react.md +174 -1
- package/docs/ar/intlayer_with_vite+solid.md +174 -1
- package/docs/ar/intlayer_with_vite+svelte.md +174 -1
- package/docs/ar/intlayer_with_vite+vue.md +174 -1
- package/docs/de/compiler.md +83 -48
- package/docs/de/configuration.md +434 -212
- package/docs/de/intlayer_with_nextjs_16.md +176 -1
- package/docs/de/intlayer_with_nextjs_compiler.md +106 -349
- package/docs/de/intlayer_with_react_router_v7.md +225 -2
- package/docs/de/intlayer_with_react_router_v7_fs_routes.md +221 -79
- package/docs/de/intlayer_with_svelte_kit.md +158 -2
- package/docs/de/intlayer_with_tanstack.md +159 -1
- package/docs/de/intlayer_with_vite+preact.md +157 -1
- package/docs/de/intlayer_with_vite+react.md +157 -1
- package/docs/de/intlayer_with_vite+solid.md +159 -3
- package/docs/de/intlayer_with_vite+svelte.md +157 -1
- package/docs/de/intlayer_with_vite+vue.md +157 -1
- package/docs/en/compiler.md +60 -33
- package/docs/en/configuration.md +80 -57
- package/docs/en/intlayer_with_nextjs_16.md +176 -0
- package/docs/en/intlayer_with_nextjs_compiler.md +179 -1
- package/docs/en/intlayer_with_react_router_v7.md +159 -0
- package/docs/en/intlayer_with_react_router_v7_fs_routes.md +159 -0
- package/docs/en/intlayer_with_svelte_kit.md +159 -0
- package/docs/en/intlayer_with_tanstack.md +160 -1
- package/docs/en/intlayer_with_vite+preact.md +159 -0
- package/docs/en/intlayer_with_vite+react.md +159 -0
- package/docs/en/intlayer_with_vite+solid.md +148 -27
- package/docs/en/intlayer_with_vite+svelte.md +159 -0
- package/docs/en/intlayer_with_vite+vue.md +142 -41
- package/docs/en-GB/compiler.md +66 -34
- package/docs/en-GB/configuration.md +78 -36
- package/docs/es/compiler.md +83 -48
- package/docs/es/configuration.md +429 -206
- package/docs/es/intlayer_with_adonisjs.md +1 -1
- package/docs/es/intlayer_with_express.md +1 -1
- package/docs/es/intlayer_with_fastify.md +1 -1
- package/docs/es/intlayer_with_hono.md +1 -1
- package/docs/es/intlayer_with_nestjs.md +1 -1
- package/docs/es/intlayer_with_nextjs_16.md +176 -3
- package/docs/es/intlayer_with_nextjs_compiler.md +175 -2
- package/docs/es/intlayer_with_nuxt.md +1 -1
- package/docs/es/intlayer_with_react_router_v7.md +227 -4
- package/docs/es/intlayer_with_react_router_v7_fs_routes.md +162 -4
- package/docs/es/intlayer_with_svelte_kit.md +158 -2
- package/docs/es/intlayer_with_tanstack.md +160 -2
- package/docs/es/intlayer_with_vite+preact.md +162 -6
- package/docs/es/intlayer_with_vite+react.md +160 -4
- package/docs/es/intlayer_with_vite+solid.md +163 -7
- package/docs/es/intlayer_with_vite+svelte.md +157 -1
- package/docs/es/intlayer_with_vite+vue.md +165 -9
- package/docs/fr/compiler.md +81 -46
- package/docs/fr/configuration.md +355 -134
- package/docs/fr/intlayer_with_adonisjs.md +1 -1
- package/docs/fr/intlayer_with_express.md +1 -1
- package/docs/fr/intlayer_with_fastify.md +1 -1
- package/docs/fr/intlayer_with_hono.md +1 -1
- package/docs/fr/intlayer_with_nestjs.md +1 -1
- package/docs/fr/intlayer_with_nextjs_16.md +183 -7
- package/docs/fr/intlayer_with_nextjs_compiler.md +179 -3
- package/docs/fr/intlayer_with_react_router_v7.md +229 -3
- package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +237 -6
- package/docs/fr/intlayer_with_svelte_kit.md +158 -2
- package/docs/fr/intlayer_with_tanstack.md +159 -1
- package/docs/fr/intlayer_with_vite+preact.md +164 -8
- package/docs/fr/intlayer_with_vite+react.md +162 -6
- package/docs/fr/intlayer_with_vite+solid.md +163 -7
- package/docs/fr/intlayer_with_vite+svelte.md +157 -1
- package/docs/fr/intlayer_with_vite+vue.md +164 -8
- package/docs/hi/compiler.md +81 -46
- package/docs/hi/configuration.md +87 -44
- package/docs/hi/intlayer_with_nextjs_16.md +174 -1
- package/docs/hi/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/hi/intlayer_with_react_router_v7.md +224 -1
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/hi/intlayer_with_svelte_kit.md +158 -2
- package/docs/hi/intlayer_with_tanstack.md +159 -1
- package/docs/hi/intlayer_with_vite+preact.md +157 -1
- package/docs/hi/intlayer_with_vite+react.md +157 -1
- package/docs/hi/intlayer_with_vite+solid.md +157 -1
- package/docs/hi/intlayer_with_vite+svelte.md +157 -1
- package/docs/hi/intlayer_with_vite+vue.md +157 -1
- package/docs/id/compiler.md +84 -51
- package/docs/id/configuration.md +83 -45
- package/docs/id/intlayer_with_nextjs_16.md +174 -1
- package/docs/id/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/id/intlayer_with_react_router_v7.md +224 -1
- package/docs/id/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/id/intlayer_with_svelte_kit.md +158 -2
- package/docs/id/intlayer_with_tanstack.md +159 -1
- package/docs/id/intlayer_with_vite+preact.md +157 -1
- package/docs/id/intlayer_with_vite+react.md +157 -1
- package/docs/id/intlayer_with_vite+solid.md +157 -1
- package/docs/id/intlayer_with_vite+svelte.md +157 -1
- package/docs/id/intlayer_with_vite+vue.md +157 -1
- package/docs/it/compiler.md +81 -46
- package/docs/it/configuration.md +426 -204
- package/docs/it/intlayer_with_nextjs_16.md +174 -1
- package/docs/it/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/it/intlayer_with_react_router_v7.md +225 -2
- package/docs/it/intlayer_with_react_router_v7_fs_routes.md +226 -2
- package/docs/it/intlayer_with_svelte_kit.md +158 -2
- package/docs/it/intlayer_with_tanstack.md +159 -1
- package/docs/it/intlayer_with_vite+preact.md +157 -1
- package/docs/it/intlayer_with_vite+react.md +157 -1
- package/docs/it/intlayer_with_vite+solid.md +159 -3
- package/docs/it/intlayer_with_vite+svelte.md +157 -1
- package/docs/it/intlayer_with_vite+vue.md +157 -1
- package/docs/ja/compiler.md +94 -58
- package/docs/ja/configuration.md +88 -45
- package/docs/ja/intlayer_with_nextjs_16.md +174 -1
- package/docs/ja/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/ja/intlayer_with_react_router_v7.md +184 -394
- package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +226 -2
- package/docs/ja/intlayer_with_svelte_kit.md +119 -595
- package/docs/ja/intlayer_with_tanstack.md +131 -642
- package/docs/ja/intlayer_with_vite+preact.md +111 -1231
- package/docs/ja/intlayer_with_vite+react.md +129 -1304
- package/docs/ja/intlayer_with_vite+solid.md +159 -3
- package/docs/ja/intlayer_with_vite+svelte.md +157 -1
- package/docs/ja/intlayer_with_vite+vue.md +157 -1
- package/docs/ko/compiler.md +88 -52
- package/docs/ko/configuration.md +87 -44
- package/docs/ko/intlayer_with_nextjs_16.md +174 -1
- package/docs/ko/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/ko/intlayer_with_react_router_v7.md +225 -2
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +226 -2
- package/docs/ko/intlayer_with_svelte_kit.md +158 -2
- package/docs/ko/intlayer_with_tanstack.md +159 -1
- package/docs/ko/intlayer_with_vite+preact.md +157 -1
- package/docs/ko/intlayer_with_vite+react.md +157 -1
- package/docs/ko/intlayer_with_vite+solid.md +159 -3
- package/docs/ko/intlayer_with_vite+svelte.md +157 -1
- package/docs/ko/intlayer_with_vite+vue.md +157 -1
- package/docs/pl/compiler.md +84 -51
- package/docs/pl/configuration.md +83 -37
- package/docs/pl/intlayer_with_nextjs_16.md +174 -1
- package/docs/pl/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/pl/intlayer_with_react_router_v7.md +224 -1
- package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/pl/intlayer_with_svelte_kit.md +158 -2
- package/docs/pl/intlayer_with_tanstack.md +159 -1
- package/docs/pl/intlayer_with_vite+preact.md +157 -1
- package/docs/pl/intlayer_with_vite+react.md +157 -1
- package/docs/pl/intlayer_with_vite+solid.md +157 -1
- package/docs/pl/intlayer_with_vite+svelte.md +157 -1
- package/docs/pl/intlayer_with_vite+vue.md +157 -1
- package/docs/pt/compiler.md +81 -46
- package/docs/pt/configuration.md +404 -194
- package/docs/pt/intlayer_with_nextjs_16.md +174 -1
- package/docs/pt/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/pt/intlayer_with_react_router_v7.md +224 -1
- package/docs/pt/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/pt/intlayer_with_svelte_kit.md +158 -2
- package/docs/pt/intlayer_with_tanstack.md +159 -1
- package/docs/pt/intlayer_with_vite+preact.md +157 -1
- package/docs/pt/intlayer_with_vite+react.md +157 -1
- package/docs/pt/intlayer_with_vite+solid.md +157 -1
- package/docs/pt/intlayer_with_vite+svelte.md +157 -1
- package/docs/pt/intlayer_with_vite+vue.md +157 -1
- package/docs/ru/compiler.md +90 -57
- package/docs/ru/configuration.md +76 -46
- package/docs/ru/intlayer_with_nextjs_16.md +174 -1
- package/docs/ru/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/ru/intlayer_with_react_router_v7.md +224 -1
- package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/ru/intlayer_with_svelte_kit.md +158 -2
- package/docs/ru/intlayer_with_tanstack.md +159 -1
- package/docs/ru/intlayer_with_vite+preact.md +157 -1
- package/docs/ru/intlayer_with_vite+react.md +157 -1
- package/docs/ru/intlayer_with_vite+solid.md +157 -1
- package/docs/ru/intlayer_with_vite+svelte.md +157 -1
- package/docs/ru/intlayer_with_vite+vue.md +157 -1
- package/docs/tr/compiler.md +85 -52
- package/docs/tr/configuration.md +83 -40
- package/docs/tr/intlayer_with_nextjs_16.md +174 -1
- package/docs/tr/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/tr/intlayer_with_react_router_v7.md +224 -1
- package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/tr/intlayer_with_svelte_kit.md +158 -2
- package/docs/tr/intlayer_with_tanstack.md +159 -1
- package/docs/tr/intlayer_with_vite+preact.md +157 -1
- package/docs/tr/intlayer_with_vite+react.md +157 -1
- package/docs/tr/intlayer_with_vite+solid.md +157 -1
- package/docs/tr/intlayer_with_vite+svelte.md +157 -1
- package/docs/tr/intlayer_with_vite+vue.md +157 -1
- package/docs/uk/compiler.md +96 -61
- package/docs/uk/configuration.md +83 -37
- package/docs/uk/intlayer_with_nextjs_16.md +174 -1
- package/docs/uk/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/uk/intlayer_with_react_router_v7.md +224 -1
- package/docs/uk/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/uk/intlayer_with_svelte_kit.md +157 -1
- package/docs/uk/intlayer_with_tanstack.md +159 -1
- package/docs/uk/intlayer_with_vite+preact.md +157 -1
- package/docs/uk/intlayer_with_vite+react.md +157 -1
- package/docs/uk/intlayer_with_vite+solid.md +157 -1
- package/docs/uk/intlayer_with_vite+svelte.md +157 -1
- package/docs/uk/intlayer_with_vite+vue.md +157 -1
- package/docs/vi/compiler.md +85 -50
- package/docs/vi/configuration.md +85 -39
- package/docs/vi/intlayer_with_nextjs_16.md +174 -1
- package/docs/vi/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/vi/intlayer_with_react_router_v7.md +224 -1
- package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +225 -1
- package/docs/vi/intlayer_with_svelte_kit.md +158 -2
- package/docs/vi/intlayer_with_tanstack.md +159 -1
- package/docs/vi/intlayer_with_vite+preact.md +157 -1
- package/docs/vi/intlayer_with_vite+react.md +157 -1
- package/docs/vi/intlayer_with_vite+solid.md +157 -1
- package/docs/vi/intlayer_with_vite+svelte.md +157 -1
- package/docs/vi/intlayer_with_vite+vue.md +157 -1
- package/docs/zh/compiler.md +84 -49
- package/docs/zh/configuration.md +80 -37
- package/docs/zh/intlayer_with_adonisjs.md +1 -1
- package/docs/zh/intlayer_with_express.md +1 -1
- package/docs/zh/intlayer_with_fastify.md +1 -1
- package/docs/zh/intlayer_with_hono.md +1 -1
- package/docs/zh/intlayer_with_nestjs.md +1 -1
- package/docs/zh/intlayer_with_nextjs_16.md +174 -1
- package/docs/zh/intlayer_with_nextjs_compiler.md +174 -1
- package/docs/zh/intlayer_with_react_router_v7.md +227 -4
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +228 -4
- package/docs/zh/intlayer_with_svelte_kit.md +158 -2
- package/docs/zh/intlayer_with_tanstack.md +159 -1
- package/docs/zh/intlayer_with_vite+preact.md +159 -3
- package/docs/zh/intlayer_with_vite+react.md +157 -1
- package/docs/zh/intlayer_with_vite+solid.md +161 -5
- package/docs/zh/intlayer_with_vite+svelte.md +157 -1
- package/docs/zh/intlayer_with_vite+vue.md +158 -2
- package/package.json +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2024-03-07
|
|
3
|
-
updatedAt:
|
|
3
|
+
updatedAt: 2026-03-12
|
|
4
4
|
title: Vite + React i18n - Reactアプリの翻訳方法 2026
|
|
5
5
|
description: Intlayerを使ってViteとReactアプリケーションに国際化(i18n)を追加する方法を学びます。このガイドに従ってアプリを多言語対応にしましょう。
|
|
6
6
|
keywords:
|
|
@@ -43,85 +43,39 @@ Intlayerを使うと、以下が可能です:
|
|
|
43
43
|
- **自動生成された型によりTypeScriptサポートを保証** し、オートコンプリートやエラー検出を向上させます。
|
|
44
44
|
- **動的なロケール検出や切り替えなどの高度な機能を活用** できます。
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## ViteとReactアプリケーションでIntlayerをセットアップするステップバイステップガイド
|
|
49
|
-
|
|
50
|
-
<Tabs defaultTab="video">
|
|
51
|
-
<Tab label="ビデオ" value="video">
|
|
52
|
-
|
|
53
|
-
<iframe title="ViteとReactに最適なi18nソリューション?Intlayerを発見" class="m-auto aspect-16/9 w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/dS9L7uJeak4?si=VaKmrYMmXjo3xpk2"/>
|
|
54
|
-
|
|
55
|
-
</Tab>
|
|
56
|
-
<Tab label="コード" value="code">
|
|
57
|
-
|
|
58
|
-
<iframe
|
|
59
|
-
src="https://stackblitz.com/github/aymericzip/intlayer-vite-react-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
60
|
-
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
61
|
-
title="Demo CodeSandbox - Intlayerを使ってアプリケーションを国際化する方法"
|
|
62
|
-
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
63
|
-
loading="lazy"
|
|
64
|
-
/>
|
|
65
|
-
|
|
66
|
-
</Tab>
|
|
67
|
-
</Tabs>
|
|
68
|
-
|
|
69
|
-
GitHubの[Application Template](https://github.com/aymericzip/intlayer-vite-react-template)を参照してください。
|
|
70
|
-
|
|
71
|
-
### ステップ1: 依存関係のインストール
|
|
72
|
-
|
|
73
|
-
npmを使って必要なパッケージをインストールします:
|
|
74
|
-
|
|
75
|
-
```bash packageManager="npm"
|
|
76
|
-
npm install intlayer react-intlayer
|
|
77
|
-
npm install vite-intlayer --save-dev
|
|
78
|
-
npx intlayer init
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
```bash packageManager="pnpm"
|
|
82
|
-
pnpm add intlayer react-intlayer
|
|
83
|
-
pnpm add vite-intlayer --save-dev
|
|
84
|
-
pnpm intlayer init
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
```bash packageManager="yarn"
|
|
88
|
-
yarn add intlayer react-intlayer
|
|
89
|
-
yarn add vite-intlayer --save-dev
|
|
90
|
-
yarn intlayer init
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
```bash packageManager="bun"
|
|
94
|
-
bun add intlayer react-intlayer
|
|
95
|
-
bun add vite-intlayer --dev
|
|
96
|
-
bunx intlayer init
|
|
97
|
-
```
|
|
46
|
+
### (オプション) ステップ 1 : コンポーネントのコンテンツを抽出する
|
|
98
47
|
|
|
99
|
-
|
|
48
|
+
既存のコードベースがある場合、数千のファイルを変換するのは時間がかかることがあります。
|
|
100
49
|
|
|
101
|
-
|
|
50
|
+
このプロセスを容易にするために、Intlayerは、コンポーネントを変換しコンテンツを抽出するための [コンパイラ](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/compiler.md) / [エクストラクタ](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/cli/extract.md) を提案しています。
|
|
102
51
|
|
|
103
|
-
|
|
104
|
-
IntlayerをReactアプリケーションと統合するパッケージです。Reactの国際化のためのコンテキストプロバイダーとフックを提供します。
|
|
105
|
-
|
|
106
|
-
- **vite-intlayer**
|
|
107
|
-
Intlayerを[Viteバンドラー](https://vite.dev/guide/why.html#why-bundle-for-production)と統合するためのViteプラグイン、およびユーザーの優先ロケール検出、クッキー管理、URLリダイレクト処理のためのミドルウェアを含みます。
|
|
108
|
-
|
|
109
|
-
### ステップ 2: プロジェクトの設定
|
|
110
|
-
|
|
111
|
-
アプリケーションの言語を設定するための設定ファイルを作成します:
|
|
52
|
+
セットアップするには、`intlayer.config.ts` ファイルに `compiler` セクションを追加します。
|
|
112
53
|
|
|
113
54
|
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
114
|
-
import {
|
|
55
|
+
import { type IntlayerConfig } from "intlayer";
|
|
115
56
|
|
|
116
57
|
const config: IntlayerConfig = {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
58
|
+
// ... 他の構成
|
|
59
|
+
compiler: {
|
|
60
|
+
/**
|
|
61
|
+
* コンパイラを有効にするかどうかを指定します。
|
|
62
|
+
*/
|
|
63
|
+
enabled: true,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 出力ファイルのパスを定義します。
|
|
67
|
+
*/
|
|
68
|
+
output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 変換後にコンポーネントを保存するかどうかを指定します。これにより、コンパイラを一度だけ実行してアプリを変換し、その後削除することができます。
|
|
72
|
+
*/
|
|
73
|
+
saveComponents: false,
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 辞書キーの接頭辞
|
|
77
|
+
*/
|
|
78
|
+
dictionaryKeyPrefix: "",
|
|
125
79
|
},
|
|
126
80
|
};
|
|
127
81
|
|
|
@@ -129,18 +83,29 @@ export default config;
|
|
|
129
83
|
```
|
|
130
84
|
|
|
131
85
|
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
132
|
-
import { Locales } from "intlayer";
|
|
133
|
-
|
|
134
86
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
135
87
|
const config = {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
88
|
+
// ... 他の構成
|
|
89
|
+
compiler: {
|
|
90
|
+
/**
|
|
91
|
+
* コンパイラを有効にするかどうかを指定します。
|
|
92
|
+
*/
|
|
93
|
+
enabled: true,
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 出力ファイルのパスを定義します。
|
|
97
|
+
*/
|
|
98
|
+
output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 変換後にコンポーネントを保存するかどうかを指定します。これにより、コンパイラを一度だけ実行してアプリを変換し、その後削除することができます。
|
|
102
|
+
*/
|
|
103
|
+
saveComponents: false,
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 辞書キーの接頭辞
|
|
107
|
+
*/
|
|
108
|
+
dictionaryKeyPrefix: "",
|
|
144
109
|
},
|
|
145
110
|
};
|
|
146
111
|
|
|
@@ -148,1273 +113,133 @@ export default config;
|
|
|
148
113
|
```
|
|
149
114
|
|
|
150
115
|
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
151
|
-
const { Locales } = require("intlayer");
|
|
152
|
-
|
|
153
116
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
154
117
|
const config = {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
118
|
+
// ... 他の構成
|
|
119
|
+
compiler: {
|
|
120
|
+
/**
|
|
121
|
+
* コンパイラを有効にするかどうかを指定します。
|
|
122
|
+
*/
|
|
123
|
+
enabled: true,
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 出力ファイルのパスを定義します。
|
|
127
|
+
*/
|
|
128
|
+
output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 変換後にコンポーネントを保存するかどうかを指定します。これにより、コンパイラを一度だけ実行してアプリを変換し、その後削除することができます。
|
|
132
|
+
*/
|
|
133
|
+
saveComponents: false,
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 辞書キーの接頭辞
|
|
137
|
+
*/
|
|
138
|
+
dictionaryKeyPrefix: "",
|
|
163
139
|
},
|
|
164
140
|
};
|
|
165
141
|
|
|
166
142
|
module.exports = config;
|
|
167
143
|
```
|
|
168
144
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
### ステップ3: Vite設定にIntlayerを統合する
|
|
172
|
-
|
|
173
|
-
設定にintlayerプラグインを追加します。
|
|
174
|
-
|
|
175
|
-
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
176
|
-
import { defineConfig } from "vite";
|
|
177
|
-
import react from "@vitejs/plugin-react-swc";
|
|
178
|
-
import { intlayer } from "vite-intlayer";
|
|
179
|
-
|
|
180
|
-
// https://vitejs.dev/config/
|
|
181
|
-
export default defineConfig({
|
|
182
|
-
plugins: [react(), intlayer()],
|
|
183
|
-
});
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
187
|
-
import { defineConfig } from "vite";
|
|
188
|
-
import react from "@vitejs/plugin-react-swc";
|
|
189
|
-
import { intlayer } from "vite-intlayer";
|
|
190
|
-
|
|
191
|
-
// https://vitejs.dev/config/
|
|
192
|
-
export default defineConfig({
|
|
193
|
-
plugins: [react(), intlayer()],
|
|
194
|
-
});
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
198
|
-
const { defineConfig } = require("vite");
|
|
199
|
-
const react = require("@vitejs/plugin-react-swc");
|
|
200
|
-
const { intlayer } = require("vite-intlayer");
|
|
201
|
-
|
|
202
|
-
// https://vitejs.dev/config/
|
|
203
|
-
module.exports = defineConfig({
|
|
204
|
-
plugins: [react(), intlayer()],
|
|
205
|
-
});
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
`intlayer()` Viteプラグインは、IntlayerをViteと統合するために使用されます。これにより、コンテンツ宣言ファイルのビルドが保証され、開発モードで監視されます。また、Viteアプリケーション内でIntlayerの環境変数を定義します。さらに、パフォーマンスを最適化するためのエイリアスも提供します。
|
|
209
|
-
|
|
210
|
-
### ステップ4: コンテンツを宣言する
|
|
211
|
-
|
|
212
|
-
翻訳を格納するためのコンテンツ宣言を作成および管理します:
|
|
213
|
-
|
|
214
|
-
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
215
|
-
import { t, type Dictionary } from "intlayer";
|
|
216
|
-
import type { ReactNode } from "react";
|
|
217
|
-
|
|
218
|
-
const appContent = {
|
|
219
|
-
key: "app",
|
|
220
|
-
content: {
|
|
221
|
-
viteLogo: t({
|
|
222
|
-
en: "Vite logo",
|
|
223
|
-
fr: "Logo Vite",
|
|
224
|
-
es: "Logo Vite",
|
|
225
|
-
}),
|
|
226
|
-
reactLogo: t({
|
|
227
|
-
en: "React logo",
|
|
228
|
-
fr: "Logo React",
|
|
229
|
-
es: "Logo React",
|
|
230
|
-
}),
|
|
231
|
-
|
|
232
|
-
title: "Vite + React",
|
|
233
|
-
|
|
234
|
-
count: t({
|
|
235
|
-
en: "count is ",
|
|
236
|
-
fr: "le compte est ",
|
|
237
|
-
es: "el recuento es ",
|
|
238
|
-
}),
|
|
239
|
-
|
|
240
|
-
edit: t<ReactNode>({
|
|
241
|
-
en: (
|
|
242
|
-
<>
|
|
243
|
-
<code>src/App.tsx</code> を編集して保存し、HMRをテストします
|
|
244
|
-
</>
|
|
245
|
-
),
|
|
246
|
-
fr: (
|
|
247
|
-
<>
|
|
248
|
-
<code>src/App.tsx</code> を編集して保存し、HMRをテストします
|
|
249
|
-
</>
|
|
250
|
-
),
|
|
251
|
-
es: (
|
|
252
|
-
<>
|
|
253
|
-
<code>src/App.tsx</code> を編集して保存し、HMRをテストします
|
|
254
|
-
</>
|
|
255
|
-
),
|
|
256
|
-
}),
|
|
257
|
-
|
|
258
|
-
readTheDocs: t({
|
|
259
|
-
en: "Click on the Vite and React logos to learn more",
|
|
260
|
-
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
261
|
-
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
262
|
-
}),
|
|
263
|
-
},
|
|
264
|
-
} satisfies Dictionary;
|
|
265
|
-
|
|
266
|
-
export default appContent;
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
270
|
-
import { t } from "intlayer";
|
|
271
|
-
|
|
272
|
-
/** @type {import('intlayer').Dictionary} */
|
|
273
|
-
const appContent = {
|
|
274
|
-
key: "app",
|
|
275
|
-
content: {
|
|
276
|
-
viteLogo: t({
|
|
277
|
-
en: "Vite logo",
|
|
278
|
-
fr: "Logo Vite",
|
|
279
|
-
es: "Logo Vite",
|
|
280
|
-
ja: "Vite ロゴ",
|
|
281
|
-
}),
|
|
282
|
-
reactLogo: t({
|
|
283
|
-
en: "React logo",
|
|
284
|
-
fr: "Logo React",
|
|
285
|
-
es: "Logo React",
|
|
286
|
-
ja: "React ロゴ",
|
|
287
|
-
}),
|
|
288
|
-
|
|
289
|
-
title: "Vite + React",
|
|
290
|
-
|
|
291
|
-
count: t({
|
|
292
|
-
en: "count is ",
|
|
293
|
-
fr: "le compte est ",
|
|
294
|
-
es: "el recuento es ",
|
|
295
|
-
ja: "カウントは ",
|
|
296
|
-
}),
|
|
297
|
-
|
|
298
|
-
edit:
|
|
299
|
-
t <
|
|
300
|
-
ReactNode >
|
|
301
|
-
{
|
|
302
|
-
// コンテンツ内でReactノードを使用する場合はReactをインポートすることを忘れないでください
|
|
303
|
-
en: (
|
|
304
|
-
<>
|
|
305
|
-
Edit <code>src/App.tsx</code> and save to test HMR
|
|
306
|
-
</>
|
|
307
|
-
),
|
|
308
|
-
fr: (
|
|
309
|
-
<>
|
|
310
|
-
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
311
|
-
</>
|
|
312
|
-
),
|
|
313
|
-
es: (
|
|
314
|
-
<>
|
|
315
|
-
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
316
|
-
</>
|
|
317
|
-
),
|
|
318
|
-
ja: (
|
|
319
|
-
<>
|
|
320
|
-
<code>src/App.tsx</code> を編集して保存し、HMRをテストしてください
|
|
321
|
-
</>
|
|
322
|
-
),
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
readTheDocs: t({
|
|
326
|
-
en: "Click on the Vite and React logos to learn more",
|
|
327
|
-
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
328
|
-
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
329
|
-
ja: "ViteとReactのロゴをクリックして詳細を確認してください",
|
|
330
|
-
}),
|
|
331
|
-
},
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export default appContent;
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
338
|
-
const { t } = require("intlayer");
|
|
339
|
-
|
|
340
|
-
/** @type {import('intlayer').Dictionary} */
|
|
341
|
-
const appContent = {
|
|
342
|
-
key: "app",
|
|
343
|
-
content: {
|
|
344
|
-
viteLogo: t({
|
|
345
|
-
en: "Vite logo",
|
|
346
|
-
fr: "Logo Vite",
|
|
347
|
-
es: "Logo Vite",
|
|
348
|
-
}),
|
|
349
|
-
reactLogo: t({
|
|
350
|
-
en: "React logo",
|
|
351
|
-
fr: "Logo React",
|
|
352
|
-
es: "Logo React",
|
|
353
|
-
}),
|
|
354
|
-
|
|
355
|
-
title: "Vite + React",
|
|
356
|
-
|
|
357
|
-
count: t({
|
|
358
|
-
en: "count is ",
|
|
359
|
-
fr: "le compte est ",
|
|
360
|
-
es: "el recuento es ",
|
|
361
|
-
}),
|
|
362
|
-
|
|
363
|
-
edit:
|
|
364
|
-
t <
|
|
365
|
-
ReactNode >
|
|
366
|
-
{
|
|
367
|
-
// コンテンツ内でReactノードを使用する場合はReactをインポートすることを忘れないでください
|
|
368
|
-
en: (
|
|
369
|
-
<>
|
|
370
|
-
Edit <code>src/App.tsx</code> and save to test HMR
|
|
371
|
-
</>
|
|
372
|
-
),
|
|
373
|
-
fr: (
|
|
374
|
-
<>
|
|
375
|
-
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
376
|
-
</>
|
|
377
|
-
),
|
|
378
|
-
es: (
|
|
379
|
-
<>
|
|
380
|
-
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
381
|
-
</>
|
|
382
|
-
),
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
readTheDocs: t({
|
|
386
|
-
en: "Click on the Vite and React logos to learn more",
|
|
387
|
-
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
388
|
-
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
389
|
-
ja: "詳細を知るには、Vite と React のロゴをクリックしてください",
|
|
390
|
-
}),
|
|
391
|
-
},
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
module.exports = appContent;
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
```json fileName="src/app.content.json" contentDeclarationFormat="json"
|
|
398
|
-
{
|
|
399
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
400
|
-
"key": "app",
|
|
401
|
-
"content": {
|
|
402
|
-
"viteLogo": {
|
|
403
|
-
"nodeType": "translation",
|
|
404
|
-
"translation": {
|
|
405
|
-
"en": "Vite logo",
|
|
406
|
-
"fr": "Logo Vite",
|
|
407
|
-
"es": "Logo Vite",
|
|
408
|
-
"ja": "Vite ロゴ"
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
"reactLogo": {
|
|
412
|
-
"nodeType": "translation",
|
|
413
|
-
"translation": {
|
|
414
|
-
"ja": "React ロゴ",
|
|
415
|
-
"en": "React logo",
|
|
416
|
-
"fr": "Logo React",
|
|
417
|
-
"es": "Logo React"
|
|
418
|
-
}
|
|
419
|
-
},
|
|
420
|
-
"title": {
|
|
421
|
-
"nodeType": "translation",
|
|
422
|
-
"translation": {
|
|
423
|
-
"ja": "Vite + React",
|
|
424
|
-
"en": "Vite + React",
|
|
425
|
-
"fr": "Vite + React",
|
|
426
|
-
"es": "Vite + React"
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
"count": {
|
|
430
|
-
"nodeType": "translation",
|
|
431
|
-
"translation": {
|
|
432
|
-
"ja": "カウントは ",
|
|
433
|
-
"en": "count is ",
|
|
434
|
-
"fr": "le compte est ",
|
|
435
|
-
"es": "el recuento es "
|
|
436
|
-
}
|
|
437
|
-
},
|
|
438
|
-
"edit": {
|
|
439
|
-
"nodeType": "translation",
|
|
440
|
-
"translation": {
|
|
441
|
-
"ja": "src/App.tsx を編集して保存し、HMR をテストしてください",
|
|
442
|
-
"en": "Edit src/App.tsx and save to test HMR",
|
|
443
|
-
"fr": "Éditez src/App.tsx et enregistrez pour tester HMR",
|
|
444
|
-
"es": "Edita src/App.tsx y guarda para probar HMR"
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
"readTheDocs": {
|
|
448
|
-
"nodeType": "translation",
|
|
449
|
-
"translation": {
|
|
450
|
-
"ja": "ViteとReactのロゴをクリックして詳細を学びましょう",
|
|
451
|
-
"en": "Click on the Vite and React logos to learn more",
|
|
452
|
-
"fr": "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
453
|
-
"es": "Haga clic en los logotipos de Vite y React para obtener más información"
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
> あなたのコンテンツ宣言は、`contentDir`ディレクトリ(デフォルトは`./src`)に含まれた時点で、アプリケーションのどこにでも定義できます。そして、コンテンツ宣言ファイルの拡張子(デフォルトは`.content.{json,ts,tsx,js,jsx,mjs,cjs}`)に一致する必要があります。
|
|
461
|
-
|
|
462
|
-
> 詳細については、[コンテンツ宣言のドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/content_file.md)を参照してください。
|
|
463
|
-
|
|
464
|
-
コンテンツファイルにTSXコードが含まれている場合は、`import React from "react";`をコンテンツファイルにインポートすることを検討してください。
|
|
465
|
-
|
|
466
|
-
### ステップ5: コード内でIntlayerを利用する
|
|
467
|
-
|
|
468
|
-
アプリケーション全体でコンテンツ辞書にアクセスします:
|
|
469
|
-
|
|
470
|
-
```tsx {5,9} fileName="src/App.tsx" codeFormat="typescript"
|
|
471
|
-
import { useState, type FC } from "react";
|
|
472
|
-
import reactLogo from "./assets/react.svg";
|
|
473
|
-
import viteLogo from "/vite.svg";
|
|
474
|
-
import "./App.css";
|
|
475
|
-
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
476
|
-
|
|
477
|
-
const AppContent: FC = () => {
|
|
478
|
-
const [count, setCount] = useState(0);
|
|
479
|
-
const content = useIntlayer("app");
|
|
480
|
-
|
|
481
|
-
return (
|
|
482
|
-
<>
|
|
483
|
-
<div>
|
|
484
|
-
<a href="https://vitejs.dev" target="_blank">
|
|
485
|
-
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
486
|
-
</a>
|
|
487
|
-
<a href="https://react.dev" target="_blank">
|
|
488
|
-
<img
|
|
489
|
-
src={reactLogo}
|
|
490
|
-
className="logo react"
|
|
491
|
-
alt={content.reactLogo.value}
|
|
492
|
-
/>
|
|
493
|
-
</a>
|
|
494
|
-
</div>
|
|
495
|
-
<h1>{content.title}</h1>
|
|
496
|
-
<div className="card">
|
|
497
|
-
<button onClick={() => setCount((count) => count + 1)}>
|
|
498
|
-
{content.count}
|
|
499
|
-
{count}
|
|
500
|
-
</button>
|
|
501
|
-
<p>{content.edit}</p>
|
|
502
|
-
</div>
|
|
503
|
-
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
504
|
-
</>
|
|
505
|
-
);
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
const App: FC = () => (
|
|
509
|
-
<IntlayerProvider>
|
|
510
|
-
<AppContent />
|
|
511
|
-
</IntlayerProvider>
|
|
512
|
-
);
|
|
513
|
-
|
|
514
|
-
export default App;
|
|
515
|
-
```
|
|
516
|
-
|
|
517
|
-
```tsx {5,9} fileName="src/App.msx" codeFormat="esm"
|
|
518
|
-
import { useState } from "react";
|
|
519
|
-
import reactLogo from "./assets/react.svg";
|
|
520
|
-
import viteLogo from "/vite.svg";
|
|
521
|
-
import "./App.css";
|
|
522
|
-
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
523
|
-
|
|
524
|
-
const AppContent = () => {
|
|
525
|
-
const [count, setCount] = useState(0);
|
|
526
|
-
const content = useIntlayer("app");
|
|
527
|
-
|
|
528
|
-
return (
|
|
529
|
-
<>
|
|
530
|
-
<div>
|
|
531
|
-
<a href="https://vitejs.dev" target="_blank">
|
|
532
|
-
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
533
|
-
</a>
|
|
534
|
-
<a href="https://react.dev" target="_blank">
|
|
535
|
-
<img
|
|
536
|
-
src={reactLogo}
|
|
537
|
-
className="logo react"
|
|
538
|
-
alt={content.reactLogo.value}
|
|
539
|
-
/>
|
|
540
|
-
</a>
|
|
541
|
-
</div>
|
|
542
|
-
<h1>{content.title}</h1>
|
|
543
|
-
<div className="card">
|
|
544
|
-
<button onClick={() => setCount((count) => count + 1)}>
|
|
545
|
-
{content.count}
|
|
546
|
-
{count}
|
|
547
|
-
</button>
|
|
548
|
-
<p>{content.edit}</p>
|
|
549
|
-
</div>
|
|
550
|
-
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
551
|
-
</>
|
|
552
|
-
);
|
|
553
|
-
};
|
|
554
|
-
|
|
555
|
-
const App = () => (
|
|
556
|
-
<IntlayerProvider>
|
|
557
|
-
<AppContent />
|
|
558
|
-
</IntlayerProvider>
|
|
559
|
-
);
|
|
560
|
-
|
|
561
|
-
export default App;
|
|
562
|
-
```
|
|
563
|
-
|
|
564
|
-
```tsx {5,9} fileName="src/App.csx" codeFormat="commonjs"
|
|
565
|
-
const { useState } = require("react");
|
|
566
|
-
const reactLogo = require("./assets/react.svg");
|
|
567
|
-
const viteLogo = require("/vite.svg");
|
|
568
|
-
require("./App.css");
|
|
569
|
-
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
570
|
-
|
|
571
|
-
const AppContent = () => {
|
|
572
|
-
const [count, setCount] = useState(0);
|
|
573
|
-
const content = useIntlayer("app");
|
|
574
|
-
|
|
575
|
-
return (
|
|
576
|
-
<>
|
|
577
|
-
<div>
|
|
578
|
-
<a href="https://vitejs.dev" target="_blank">
|
|
579
|
-
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
580
|
-
</a>
|
|
581
|
-
<a href="https://react.dev" target="_blank">
|
|
582
|
-
<img
|
|
583
|
-
src={reactLogo}
|
|
584
|
-
className="logo react"
|
|
585
|
-
alt={content.reactLogo.value} // Reactロゴの代替テキスト
|
|
586
|
-
/>
|
|
587
|
-
</a>
|
|
588
|
-
</div>
|
|
589
|
-
<h1>{content.title}</h1>
|
|
590
|
-
<div className="card">
|
|
591
|
-
<button onClick={() => setCount((count) => count + 1)}>
|
|
592
|
-
{content.count}
|
|
593
|
-
{count}
|
|
594
|
-
</button>
|
|
595
|
-
<p>{content.edit}</p>
|
|
596
|
-
</div>
|
|
597
|
-
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
598
|
-
</>
|
|
599
|
-
);
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
const App = () => (
|
|
603
|
-
<IntlayerProvider>
|
|
604
|
-
<AppContent />
|
|
605
|
-
</IntlayerProvider>
|
|
606
|
-
);
|
|
607
|
-
|
|
608
|
-
module.exports = App;
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
> もし `alt`、`title`、`href`、`aria-label` などの `string` 属性でコンテンツを使用したい場合は、関数の値を呼び出す必要があります。例えば:
|
|
612
|
-
|
|
613
|
-
> ```jsx
|
|
614
|
-
> <img src={content.image.src.value} alt={content.image.value} />
|
|
615
|
-
> ```
|
|
616
|
-
|
|
617
|
-
> `useIntlayer` フックの詳細については、[ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/react-intlayer/useIntlayer.md)を参照してください。
|
|
618
|
-
|
|
619
|
-
> アプリケーションが既に存在する場合は、[Intlayer コンパイラ](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/compiler.md) と [抽出コマンド](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/cli/extract.md) を組み合わせて、1 秒で何千ものコンポーネントを変換できます。
|
|
620
|
-
|
|
621
|
-
### (オプション)ステップ6: コンテンツの言語を変更する
|
|
622
|
-
|
|
623
|
-
コンテンツの言語を変更するには、`useLocale` フックが提供する `setLocale` 関数を使用します。この関数を使うことで、アプリケーションのロケールを設定し、それに応じてコンテンツを更新できます。
|
|
624
|
-
|
|
625
|
-
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
626
|
-
import type { FC } from "react";
|
|
627
|
-
import { Locales } from "intlayer";
|
|
628
|
-
import { useLocale } from "react-intlayer";
|
|
629
|
-
|
|
630
|
-
const LocaleSwitcher: FC = () => {
|
|
631
|
-
const { setLocale } = useLocale();
|
|
632
|
-
|
|
633
|
-
return (
|
|
634
|
-
<button onClick={() => setLocale(Locales.English)}>英語に言語を変更</button>
|
|
635
|
-
);
|
|
636
|
-
};
|
|
637
|
-
```
|
|
638
|
-
|
|
639
|
-
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
640
|
-
import { Locales } from "intlayer";
|
|
641
|
-
import { useLocale } from "react-intlayer";
|
|
642
|
-
|
|
643
|
-
const LocaleSwitcher = () => {
|
|
644
|
-
const { setLocale } = useLocale();
|
|
645
|
-
|
|
646
|
-
return (
|
|
647
|
-
<button onClick={() => setLocale(Locales.English)}>英語に言語を変更</button>
|
|
648
|
-
);
|
|
649
|
-
};
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
653
|
-
const { Locales } = require("intlayer");
|
|
654
|
-
const { useLocale } = require("react-intlayer");
|
|
655
|
-
|
|
656
|
-
const LocaleSwitcher = () => {
|
|
657
|
-
const { setLocale } = useLocale();
|
|
658
|
-
|
|
659
|
-
return (
|
|
660
|
-
<button onClick={() => setLocale(Locales.English)}>英語に言語を変更</button>
|
|
661
|
-
);
|
|
662
|
-
};
|
|
663
|
-
```
|
|
664
|
-
|
|
665
|
-
> `useLocale` フックの詳細については、[ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/react-intlayer/useLocale.md)を参照してください。
|
|
666
|
-
|
|
667
|
-
### (オプション)ステップ7:アプリケーションにローカライズされたルーティングを追加する
|
|
668
|
-
|
|
669
|
-
このステップの目的は、各言語ごとにユニークなルートを作成することです。これはSEOやSEOに適したURLに役立ちます。
|
|
670
|
-
例:
|
|
671
|
-
|
|
672
|
-
```plaintext
|
|
673
|
-
- https://example.com/about
|
|
674
|
-
- https://example.com/es/about
|
|
675
|
-
- https://example.com/fr/about
|
|
676
|
-
```
|
|
677
|
-
|
|
678
|
-
> デフォルトでは、ルートはデフォルトロケールに対してプレフィックスが付きません。デフォルトロケールにもプレフィックスを付けたい場合は、設定の `middleware.prefixDefault` オプションを `true` に設定できます。詳細は[設定ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/configuration.md)を参照してください。
|
|
679
|
-
|
|
680
|
-
アプリケーションにローカライズされたルーティングを追加するには、アプリケーションのルートをラップし、ロケールベースのルーティングを処理する `LocaleRouter` コンポーネントを作成できます。以下は [React Router](https://reactrouter.com/home) を使用した例です。
|
|
681
|
-
|
|
682
|
-
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
683
|
-
import { localeMap } from "intlayer"; // 'intlayer'からのユーティリティ関数と型
|
|
684
|
-
import type { FC, PropsWithChildren } from "react"; // 関数コンポーネントとプロパティのReact型
|
|
685
|
-
import { IntlayerProvider } from "react-intlayer"; // 国際化コンテキストのプロバイダー
|
|
686
|
-
import { BrowserRouter, Route, Routes } from "react-router-dom"; // ナビゲーション管理用のルーターコンポーネント
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* ロケール固有のルートを設定するルーターコンポーネント。
|
|
690
|
-
* React Routerを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
|
|
691
|
-
*/
|
|
692
|
-
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
693
|
-
<BrowserRouter>
|
|
694
|
-
<Routes>
|
|
695
|
-
{localeMap(({ locale, urlPrefix }) => (
|
|
696
|
-
<Route
|
|
697
|
-
// ロケールをキャプチャするルートパターン(例: /en/, /fr/)およびそれに続くすべてのパスにマッチ
|
|
698
|
-
path={`${urlPrefix}/*`}
|
|
699
|
-
key={locale}
|
|
700
|
-
element={
|
|
701
|
-
<IntlayerProvider locale={locale}>{children}</IntlayerProvider>
|
|
702
|
-
} // ロケール管理で子要素をラップ
|
|
703
|
-
/>
|
|
704
|
-
))}
|
|
705
|
-
</Routes>
|
|
706
|
-
</BrowserRouter>
|
|
707
|
-
);
|
|
708
|
-
```
|
|
709
|
-
|
|
710
|
-
```jsx fileName="src/components/LocaleRouter.mjx" codeFormat="esm"
|
|
711
|
-
import { localeMap } from 'intlayer'; // 'intlayer'からのユーティリティ関数と型
|
|
712
|
-
import type { FC, PropsWithChildren } from 'react'; // 関数コンポーネントとプロパティ用のReact型
|
|
713
|
-
import { IntlayerProvider } from 'react-intlayer'; // 国際化コンテキストのプロバイダー
|
|
714
|
-
import { BrowserRouter, Route, Routes } from 'react-router-dom'; // ナビゲーション管理用のルーターコンポーネント
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* ロケール固有のルートを設定するルーターコンポーネント。
|
|
718
|
-
* React Routerを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
|
|
719
|
-
*/
|
|
720
|
-
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
721
|
-
<BrowserRouter>
|
|
722
|
-
<Routes>
|
|
723
|
-
{localeMap(({ locale, urlPrefix }) => (
|
|
724
|
-
<Route
|
|
725
|
-
// ロケールをキャプチャするルートパターン(例:/en/、/fr/)およびその後のすべてのパスにマッチ
|
|
726
|
-
path={`${urlPrefix}/*`}
|
|
727
|
-
key={locale}
|
|
728
|
-
element={
|
|
729
|
-
<IntlayerProvider locale={locale}>{children}</IntlayerProvider>
|
|
730
|
-
} // ロケール管理で子要素をラップ
|
|
731
|
-
/>
|
|
732
|
-
))}
|
|
733
|
-
</Routes>
|
|
734
|
-
</BrowserRouter>
|
|
735
|
-
);
|
|
736
|
-
```
|
|
737
|
-
|
|
738
|
-
```jsx fileName="src/components/LocaleRouter.cjx" codeFormat="commonjs"
|
|
739
|
-
const { localeMap } = require("intlayer"); // 'intlayer'からのユーティリティ関数と型
|
|
740
|
-
const React = require("react"); // Reactのインポート
|
|
741
|
-
const { IntlayerProvider } = require("react-intlayer"); // 国際化コンテキストのプロバイダー
|
|
742
|
-
const { BrowserRouter, Route, Routes } = require("react-router-dom"); // ナビゲーション管理のためのルーターコンポーネント
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* ロケール固有のルートを設定するルーターコンポーネント。
|
|
746
|
-
* React Routerを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
|
|
747
|
-
*/
|
|
748
|
-
const LocaleRouter = ({ children }) =>
|
|
749
|
-
React.createElement(
|
|
750
|
-
BrowserRouter,
|
|
751
|
-
{},
|
|
752
|
-
React.createElement(
|
|
753
|
-
Routes,
|
|
754
|
-
{},
|
|
755
|
-
localeMap(({ locale, urlPrefix }) =>
|
|
756
|
-
React.createElement(Route, {
|
|
757
|
-
path: `${urlPrefix}/*`,
|
|
758
|
-
key: locale,
|
|
759
|
-
element: React.createElement(IntlayerProvider, { locale }, children),
|
|
760
|
-
})
|
|
761
|
-
)
|
|
762
|
-
)
|
|
763
|
-
);
|
|
764
|
-
|
|
765
|
-
exports.LocaleRouter = LocaleRouter;
|
|
766
|
-
```
|
|
145
|
+
<Tabs>
|
|
146
|
+
<Tab value='抽出コマンド'>
|
|
767
147
|
|
|
768
|
-
|
|
148
|
+
コンポーネントを変換してコンテンツを抽出するためにエクストラクタを実行します
|
|
769
149
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
773
|
-
import { LocaleRouter } from "./components/LocaleRouter";
|
|
774
|
-
import type { FC } from "react";
|
|
775
|
-
|
|
776
|
-
// ... あなたの AppContent コンポーネント
|
|
777
|
-
|
|
778
|
-
const App: FC = () => (
|
|
779
|
-
<LocaleRouter>
|
|
780
|
-
<AppContent />
|
|
781
|
-
</LocaleRouter>
|
|
782
|
-
);
|
|
150
|
+
```bash packageManager="npm"
|
|
151
|
+
npx intlayer extract
|
|
783
152
|
```
|
|
784
153
|
|
|
785
|
-
```
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
// ... あなたの AppContent コンポーネント
|
|
789
|
-
|
|
790
|
-
const App = () => (
|
|
791
|
-
<LocaleRouter>
|
|
792
|
-
<AppContent />
|
|
793
|
-
</LocaleRouter>
|
|
794
|
-
);
|
|
154
|
+
```bash packageManager="pnpm"
|
|
155
|
+
pnpm intlayer extract
|
|
795
156
|
```
|
|
796
157
|
|
|
797
|
-
```
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
// ... あなたの AppContent コンポーネント
|
|
801
|
-
|
|
802
|
-
const App = () => (
|
|
803
|
-
<LocaleRouter>
|
|
804
|
-
<AppContent />
|
|
805
|
-
</LocaleRouter>
|
|
806
|
-
);
|
|
158
|
+
```bash packageManager="yarn"
|
|
159
|
+
yarn intlayer extract
|
|
807
160
|
```
|
|
808
161
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
> `intlayerProxy`を本番環境で使用するには、`vite-intlayer`パッケージを`devDependencies`から`dependencies`に切り替える必要があることに注意してください。
|
|
812
|
-
|
|
813
|
-
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
814
|
-
import { defineConfig } from "vite";
|
|
815
|
-
import react from "@vitejs/plugin-react-swc";
|
|
816
|
-
import { intlayer, intlayerProxy } from "vite-intlayer";
|
|
817
|
-
|
|
818
|
-
// https://vitejs.dev/config/
|
|
819
|
-
export default defineConfig({
|
|
820
|
-
plugins: [react(), intlayer(), intlayerProxy()],
|
|
821
|
-
});
|
|
162
|
+
```bash packageManager="bun"
|
|
163
|
+
bunx intlayer extract
|
|
822
164
|
```
|
|
823
165
|
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
import react from "@vitejs/plugin-react-swc";
|
|
827
|
-
import { intlayer, intlayerProxy } from "vite-intlayer";
|
|
166
|
+
</Tab>
|
|
167
|
+
<Tab value='Babelコンパイラ'>
|
|
828
168
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
plugins: [react(), intlayer(), intlayerProxy()],
|
|
832
|
-
});
|
|
169
|
+
```bash packageManager="npm"
|
|
170
|
+
npm install @intlayer/babel --save-dev
|
|
833
171
|
```
|
|
834
172
|
|
|
835
|
-
```
|
|
836
|
-
|
|
837
|
-
const react = require("@vitejs/plugin-react-swc");
|
|
838
|
-
const { intlayer, intlayerProxy } = require("vite-intlayer");
|
|
839
|
-
|
|
840
|
-
// https://vitejs.dev/config/
|
|
841
|
-
module.exports = defineConfig({
|
|
842
|
-
plugins: [react(), intlayer(), intlayerProxy()],
|
|
843
|
-
});
|
|
173
|
+
```bash packageManager="pnpm"
|
|
174
|
+
pnpm add @intlayer/babel --save-dev
|
|
844
175
|
```
|
|
845
176
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
ロケールが変更されたときにURLを変更するには、`useLocale`フックが提供する`onLocaleChange`プロパティを使用できます。同時に、`react-router-dom`の`useLocation`と`useNavigate`フックを使用してURLパスを更新できます。
|
|
849
|
-
|
|
850
|
-
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
851
|
-
import { useLocation, useNavigate } from "react-router-dom";
|
|
852
|
-
import {
|
|
853
|
-
Locales,
|
|
854
|
-
getHTMLTextDir,
|
|
855
|
-
getLocaleName,
|
|
856
|
-
getLocalizedUrl,
|
|
857
|
-
} from "intlayer";
|
|
858
|
-
import { useLocale } from "intlayer";
|
|
859
|
-
import { type FC } from "react";
|
|
860
|
-
|
|
861
|
-
const LocaleSwitcher: FC = () => {
|
|
862
|
-
const { pathname, search } = useLocation(); // 現在のURLパスを取得。例: /fr/about?foo=bar
|
|
863
|
-
const navigate = useNavigate();
|
|
864
|
-
|
|
865
|
-
const { locale, availableLocales, setLocale } = useLocale({
|
|
866
|
-
onLocaleChange: (locale) => {
|
|
867
|
-
// 更新されたロケールでURLを構築する
|
|
868
|
-
// 例: /es/about?foo=bar
|
|
869
|
-
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
870
|
-
|
|
871
|
-
// URLパスを更新する
|
|
872
|
-
navigate(pathWithLocale);
|
|
873
|
-
},
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
return (
|
|
877
|
-
<div>
|
|
878
|
-
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
879
|
-
<div id="localePopover" popover="auto">
|
|
880
|
-
{availableLocales.map((localeItem) => (
|
|
881
|
-
<a
|
|
882
|
-
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
883
|
-
hrefLang={localeItem}
|
|
884
|
-
aria-current={locale === localeItem ? "page" : undefined}
|
|
885
|
-
onClick={(e) => {
|
|
886
|
-
e.preventDefault();
|
|
887
|
-
setLocale(localeItem);
|
|
888
|
-
}}
|
|
889
|
-
key={localeItem}
|
|
890
|
-
>
|
|
891
|
-
<span>
|
|
892
|
-
{/* ロケール - 例: FR */}
|
|
893
|
-
{localeItem}
|
|
894
|
-
</span>
|
|
895
|
-
<span>
|
|
896
|
-
{/* 自身のロケールでの言語名 - 例: Français */}
|
|
897
|
-
{getLocaleName(localeItem, locale)}
|
|
898
|
-
</span>
|
|
899
|
-
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
900
|
-
{/* 現在のロケールでの言語名 - 例: Francés(現在のロケールがLocales.SPANISHの場合) */}
|
|
901
|
-
{getLocaleName(localeItem)}
|
|
902
|
-
</span>
|
|
903
|
-
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
904
|
-
{/* 英語での言語名 - 例: French */}
|
|
905
|
-
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
906
|
-
</span>
|
|
907
|
-
</a>
|
|
908
|
-
))}
|
|
909
|
-
</div>
|
|
910
|
-
</div>
|
|
911
|
-
);
|
|
912
|
-
};
|
|
177
|
+
```bash packageManager="yarn"
|
|
178
|
+
yarn add @intlayer/babel --save-dev
|
|
913
179
|
```
|
|
914
180
|
|
|
915
|
-
```
|
|
916
|
-
|
|
917
|
-
import {
|
|
918
|
-
Locales,
|
|
919
|
-
getHTMLTextDir,
|
|
920
|
-
getLocaleName,
|
|
921
|
-
getLocalizedUrl,
|
|
922
|
-
} from "intlayer";
|
|
923
|
-
import { useLocale } from "react-intlayer";
|
|
924
|
-
|
|
925
|
-
const LocaleSwitcher = () => {
|
|
926
|
-
const { pathname, search } = useLocation(); // 現在のURLパスを取得します。例: /fr/about?foo=bar
|
|
927
|
-
const navigate = useNavigate();
|
|
928
|
-
|
|
929
|
-
const { locale, availableLocales, setLocale } = useLocale({
|
|
930
|
-
onLocaleChange: (locale) => {
|
|
931
|
-
// 更新されたロケールでURLを構築します
|
|
932
|
-
// 例: /es/about?foo=bar
|
|
933
|
-
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
934
|
-
|
|
935
|
-
// URLパスを更新します
|
|
936
|
-
navigate(pathWithLocale);
|
|
937
|
-
},
|
|
938
|
-
});
|
|
939
|
-
|
|
940
|
-
return (
|
|
941
|
-
<div>
|
|
942
|
-
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
943
|
-
<div id="localePopover" popover="auto">
|
|
944
|
-
{availableLocales.map((localeItem) => (
|
|
945
|
-
<a
|
|
946
|
-
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
947
|
-
hrefLang={localeItem}
|
|
948
|
-
aria-current={locale === localeItem ? "page" : undefined}
|
|
949
|
-
onClick={(e) => {
|
|
950
|
-
e.preventDefault();
|
|
951
|
-
setLocale(localeItem);
|
|
952
|
-
}}
|
|
953
|
-
key={localeItem}
|
|
954
|
-
>
|
|
955
|
-
<span>
|
|
956
|
-
{/* ロケール - 例: FR */}
|
|
957
|
-
{localeItem}
|
|
958
|
-
</span>
|
|
959
|
-
<span>
|
|
960
|
-
{/* そのロケールでの言語名 - 例: Français */}
|
|
961
|
-
{getLocaleName(localeItem, locale)}
|
|
962
|
-
</span>
|
|
963
|
-
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
964
|
-
{/* 現在のロケールでの言語名 - 例: Locales.SPANISH に設定された現在のロケールでの "Francés" */}
|
|
965
|
-
{getLocaleName(localeItem)}
|
|
966
|
-
</span>
|
|
967
|
-
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
968
|
-
{/* 英語での言語名 - 例: French */}
|
|
969
|
-
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
970
|
-
</span>
|
|
971
|
-
</a>
|
|
972
|
-
))}
|
|
973
|
-
</div>
|
|
974
|
-
</div>
|
|
975
|
-
);
|
|
976
|
-
};
|
|
181
|
+
```bash packageManager="bun"
|
|
182
|
+
bun add @intlayer/babel --dev
|
|
977
183
|
```
|
|
978
184
|
|
|
979
|
-
```
|
|
980
|
-
const { useLocation, useNavigate } = require("react-router-dom");
|
|
185
|
+
```js fileName="babel.config.js"
|
|
981
186
|
const {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
const { locale, availableLocales, setLocale } = useLocale({
|
|
994
|
-
onLocaleChange: (locale) => {
|
|
995
|
-
// 更新されたロケールでURLを構築します
|
|
996
|
-
// 例: /es/about?foo=bar
|
|
997
|
-
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
998
|
-
|
|
999
|
-
// URLパスを更新します
|
|
1000
|
-
navigate(pathWithLocale);
|
|
1001
|
-
},
|
|
1002
|
-
});
|
|
1003
|
-
|
|
1004
|
-
return (
|
|
1005
|
-
<div>
|
|
1006
|
-
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1007
|
-
<div id="localePopover" popover="auto">
|
|
1008
|
-
{availableLocales.map((localeItem) => (
|
|
1009
|
-
<a
|
|
1010
|
-
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1011
|
-
hrefLang={localeItem}
|
|
1012
|
-
aria-current={locale === localeItem ? "page" : undefined}
|
|
1013
|
-
onClick={(e) => {
|
|
1014
|
-
e.preventDefault();
|
|
1015
|
-
setLocale(localeItem);
|
|
1016
|
-
}}
|
|
1017
|
-
key={localeItem}
|
|
1018
|
-
>
|
|
1019
|
-
<span>
|
|
1020
|
-
{/* ロケール - 例: FR */}
|
|
1021
|
-
{localeItem}
|
|
1022
|
-
</span>
|
|
1023
|
-
<span>
|
|
1024
|
-
{/* 自身のロケールでの言語名 - 例: Français */}
|
|
1025
|
-
{getLocaleName(localeItem, locale)}
|
|
1026
|
-
</span>
|
|
1027
|
-
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1028
|
-
{/* 現在のロケールでの言語名 - 例: Locales.SPANISHに設定された現在のロケールでのFrancés */}
|
|
1029
|
-
{getLocaleName(localeItem)}
|
|
1030
|
-
</span>
|
|
1031
|
-
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1032
|
-
{/* 英語での言語名 - 例: French */}
|
|
1033
|
-
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1034
|
-
</span>
|
|
1035
|
-
</a>
|
|
1036
|
-
))}
|
|
1037
|
-
</div>
|
|
1038
|
-
</div>
|
|
1039
|
-
);
|
|
1040
|
-
};
|
|
1041
|
-
```
|
|
1042
|
-
|
|
1043
|
-
> ドキュメント参照:
|
|
1044
|
-
>
|
|
1045
|
-
> - [`useLocale` フック](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/react-intlayer/useLocale.md)
|
|
1046
|
-
> - [`getLocaleName` フック](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/intlayer/getLocaleName.md)
|
|
1047
|
-
> - [`getLocalizedUrl` フック](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/intlayer/getLocalizedUrl.md)
|
|
1048
|
-
> - [`getHTMLTextDir` フック](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/intlayer/getHTMLTextDir.md)
|
|
1049
|
-
> - [`hrefLang` 属性](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1050
|
-
> - [`lang` 属性](https://developer.mozilla.org/ja/docs/Web/HTML/Global_attributes/lang)
|
|
1051
|
-
> - [`dir` 属性](https://developer.mozilla.org/ja/docs/Web/HTML/Global_attributes/dir)
|
|
1052
|
-
> - [`aria-current` 属性](https://developer.mozilla.org/ja/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1053
|
-
|
|
1054
|
-
以下は、説明を追加しコード例を洗練させた更新版の**ステップ9**です:
|
|
1055
|
-
|
|
1056
|
-
---
|
|
1057
|
-
|
|
1058
|
-
### (オプション)ステップ9: HTMLの言語属性と方向属性を切り替える
|
|
1059
|
-
|
|
1060
|
-
アプリケーションが複数の言語をサポートしている場合、`<html>`タグの`lang`属性と`dir`属性を現在のロケールに合わせて更新することが非常に重要です。これにより、以下が保証されます:
|
|
1061
|
-
|
|
1062
|
-
- **アクセシビリティ**:スクリーンリーダーや支援技術は、正しい`lang`属性に依存してコンテンツを正確に発音・解釈します。
|
|
1063
|
-
- **テキストのレンダリング**:`dir`(方向)属性は、テキストが適切な順序(例:英語は左から右、アラビア語やヘブライ語は右から左)で表示されることを保証し、読みやすさに不可欠です。
|
|
1064
|
-
- **SEO**:検索エンジンは`lang`属性を使用してページの言語を判別し、適切なローカライズされたコンテンツを検索結果に提供します。
|
|
1065
|
-
|
|
1066
|
-
ロケールが変更されるたびにこれらの属性を動的に更新することで、すべての対応言語において一貫性がありアクセシブルなユーザー体験を保証します。
|
|
1067
|
-
|
|
1068
|
-
#### フックの実装
|
|
1069
|
-
|
|
1070
|
-
HTML属性を管理するカスタムフックを作成します。このフックはロケールの変更を監視し、それに応じて属性を更新します。
|
|
1071
|
-
|
|
1072
|
-
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1073
|
-
import { useEffect } from "react";
|
|
1074
|
-
import { useLocale } from "react-intlayer";
|
|
1075
|
-
import { getHTMLTextDir } from "intlayer";
|
|
1076
|
-
|
|
1077
|
-
/**
|
|
1078
|
-
* 現在のロケールに基づいてHTMLの<html>要素の`lang`および`dir`属性を更新します。
|
|
1079
|
-
* - `lang`: ブラウザや検索エンジンにページの言語を通知します。
|
|
1080
|
-
* - `dir`: 正しい読み順を保証します(例:英語は'ltr'、アラビア語は'rtl')。
|
|
1081
|
-
*
|
|
1082
|
-
* この動的な更新は、適切なテキストレンダリング、アクセシビリティ、およびSEOに不可欠です。
|
|
1083
|
-
*/
|
|
1084
|
-
export const useI18nHTMLAttributes = () => {
|
|
1085
|
-
const { locale } = useLocale();
|
|
1086
|
-
|
|
1087
|
-
useEffect(() => {
|
|
1088
|
-
// 現在のロケールに言語属性を更新します。
|
|
1089
|
-
document.documentElement.lang = locale;
|
|
1090
|
-
|
|
1091
|
-
// 現在のロケールに基づいてテキストの方向を設定します。
|
|
1092
|
-
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1093
|
-
}, [locale]);
|
|
1094
|
-
};
|
|
1095
|
-
```
|
|
1096
|
-
|
|
1097
|
-
```jsx fileName="src/hooks/useI18nHTMLAttributes.msx" codeFormat="esm"
|
|
1098
|
-
import { useEffect } from "react";
|
|
1099
|
-
import { useLocale } from "react-intlayer";
|
|
1100
|
-
import { getHTMLTextDir } from "intlayer";
|
|
1101
|
-
|
|
1102
|
-
/**
|
|
1103
|
-
* 現在のロケールに基づいてHTMLの<html>要素の`lang`および`dir`属性を更新します。
|
|
1104
|
-
* - `lang`: ブラウザや検索エンジンにページの言語を通知します。
|
|
1105
|
-
* - `dir`: 正しい読み順を保証します(例:英語は 'ltr'、アラビア語は 'rtl')。
|
|
1106
|
-
*
|
|
1107
|
-
* この動的な更新は、適切なテキストレンダリング、アクセシビリティ、およびSEOに不可欠です。
|
|
1108
|
-
*/
|
|
1109
|
-
export const useI18nHTMLAttributes = () => {
|
|
1110
|
-
const { locale } = useLocale();
|
|
1111
|
-
|
|
1112
|
-
useEffect(() => {
|
|
1113
|
-
// 現在のロケールに言語属性を更新します。
|
|
1114
|
-
document.documentElement.lang = locale;
|
|
1115
|
-
|
|
1116
|
-
// 現在のロケールに基づいてテキストの方向を設定します。
|
|
1117
|
-
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1118
|
-
}, [locale]);
|
|
1119
|
-
};
|
|
1120
|
-
```
|
|
1121
|
-
|
|
1122
|
-
```jsx fileName="src/hooks/useI18nHTMLAttributes.csx" codeFormat="commonjs"
|
|
1123
|
-
const { useEffect } = require("react");
|
|
1124
|
-
const { useLocale } = require("react-intlayer");
|
|
1125
|
-
const { getHTMLTextDir } = require("intlayer");
|
|
1126
|
-
|
|
1127
|
-
/**
|
|
1128
|
-
* 現在のロケールに基づいてHTMLの<html>要素の`lang`および`dir`属性を更新します。
|
|
1129
|
-
* - `lang`: ブラウザや検索エンジンにページの言語を通知します。
|
|
1130
|
-
* - `dir`: 正しい読み順を保証します(例:英語は'ltr'、アラビア語は'rtl')。
|
|
1131
|
-
*
|
|
1132
|
-
* この動的な更新は、適切なテキストレンダリング、アクセシビリティ、およびSEOに不可欠です。
|
|
1133
|
-
*/
|
|
1134
|
-
const useI18nHTMLAttributes = () => {
|
|
1135
|
-
const { locale } = useLocale();
|
|
1136
|
-
|
|
1137
|
-
useEffect(() => {
|
|
1138
|
-
// 現在のロケールに言語属性を更新します。
|
|
1139
|
-
document.documentElement.lang = locale;
|
|
1140
|
-
|
|
1141
|
-
// 現在のロケールに基づいてテキストの方向を設定します。
|
|
1142
|
-
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1143
|
-
}, [locale]);
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
module.exports = { useI18nHTMLAttributes };
|
|
1147
|
-
```
|
|
1148
|
-
|
|
1149
|
-
#### アプリケーションでのフックの使用
|
|
1150
|
-
|
|
1151
|
-
フックをメインコンポーネントに統合し、ロケールが変更されるたびにHTML属性が更新されるようにします:
|
|
1152
|
-
|
|
1153
|
-
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
1154
|
-
import type { FC } from "react";
|
|
1155
|
-
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1156
|
-
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1157
|
-
import "./App.css";
|
|
1158
|
-
|
|
1159
|
-
const AppContent: FC = () => {
|
|
1160
|
-
// ロケールに基づいて<html>タグのlangとdir属性を更新するためにフックを適用します。
|
|
1161
|
-
useI18nHTMLAttributes();
|
|
1162
|
-
|
|
1163
|
-
// ... コンポーネントの残りの部分
|
|
1164
|
-
};
|
|
1165
|
-
|
|
1166
|
-
const App: FC = () => (
|
|
1167
|
-
<IntlayerProvider>
|
|
1168
|
-
<AppContent />
|
|
1169
|
-
</IntlayerProvider>
|
|
1170
|
-
);
|
|
1171
|
-
|
|
1172
|
-
export default App;
|
|
1173
|
-
```
|
|
1174
|
-
|
|
1175
|
-
```jsx fileName="src/App.msx" codeFormat="esm"
|
|
1176
|
-
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1177
|
-
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1178
|
-
import "./App.css";
|
|
1179
|
-
|
|
1180
|
-
const AppContent = () => {
|
|
1181
|
-
// ロケールに基づいて<html>タグのlangとdir属性を更新するためにフックを適用します。
|
|
1182
|
-
useI18nHTMLAttributes();
|
|
1183
|
-
|
|
1184
|
-
// ... コンポーネントの残りの部分
|
|
187
|
+
intlayerExtractBabelPlugin,
|
|
188
|
+
getExtractPluginOptions,
|
|
189
|
+
} = require("@intlayer/babel");
|
|
190
|
+
|
|
191
|
+
module.exports = {
|
|
192
|
+
presets: ["next/babel"],
|
|
193
|
+
plugins: [
|
|
194
|
+
// コンポーネントから辞書へコンテンツを抽出する
|
|
195
|
+
[intlayerExtractBabelPlugin, getExtractPluginOptions()],
|
|
196
|
+
],
|
|
1185
197
|
};
|
|
1186
|
-
|
|
1187
|
-
const App = () => (
|
|
1188
|
-
<IntlayerProvider>
|
|
1189
|
-
<AppContent />
|
|
1190
|
-
</IntlayerProvider>
|
|
1191
|
-
);
|
|
1192
|
-
|
|
1193
|
-
export default App;
|
|
1194
198
|
```
|
|
1195
199
|
|
|
1196
|
-
```
|
|
1197
|
-
|
|
1198
|
-
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
1199
|
-
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1200
|
-
require("./App.css");
|
|
1201
|
-
|
|
1202
|
-
const AppContent = () => {
|
|
1203
|
-
// ロケールに基づいて<html>タグのlangとdir属性を更新するためにフックを適用します。
|
|
1204
|
-
useI18nHTMLAttributes();
|
|
1205
|
-
|
|
1206
|
-
// ... コンポーネントの残りの部分
|
|
1207
|
-
};
|
|
1208
|
-
|
|
1209
|
-
const App = () => (
|
|
1210
|
-
<IntlayerProvider>
|
|
1211
|
-
<AppContent />
|
|
1212
|
-
</IntlayerProvider>
|
|
1213
|
-
);
|
|
1214
|
-
|
|
1215
|
-
module.exports = App;
|
|
1216
|
-
```
|
|
1217
|
-
|
|
1218
|
-
これらの変更を適用することで、アプリケーションは以下を実現します:
|
|
1219
|
-
|
|
1220
|
-
- **言語**(`lang`)属性が現在のロケールを正確に反映し、SEOやブラウザの動作に重要な役割を果たします。
|
|
1221
|
-
- ロケールに応じて**テキストの方向**(`dir`)を調整し、異なる読み方向の言語に対して読みやすさと使いやすさを向上させます。
|
|
1222
|
-
- 支援技術がこれらの属性に依存して最適に機能するため、より**アクセシブル**な体験を提供します。
|
|
1223
|
-
|
|
1224
|
-
### (オプション)ステップ10:ローカライズされたリンクコンポーネントの作成
|
|
1225
|
-
|
|
1226
|
-
アプリケーションのナビゲーションが現在のロケールを尊重するようにするために、カスタムの `Link` コンポーネントを作成できます。このコンポーネントは内部のURLに自動的に現在の言語をプレフィックスとして付加します。例えば、フランス語を話すユーザーが「About」ページへのリンクをクリックすると、`/about` ではなく `/fr/about` にリダイレクトされます。
|
|
1227
|
-
|
|
1228
|
-
この動作は以下の理由で有用です:
|
|
1229
|
-
|
|
1230
|
-
- **SEOとユーザー体験**:ローカライズされたURLは、検索エンジンが言語別のページを正しくインデックスし、ユーザーに好みの言語でコンテンツを提供するのに役立ちます。
|
|
1231
|
-
- **一貫性**:アプリケーション全体でローカライズされたリンクを使用することで、ナビゲーションが現在のロケール内に留まり、予期しない言語の切り替えを防ぎます。
|
|
1232
|
-
- **保守性**:ローカリゼーションのロジックを単一のコンポーネントに集約することで、URLの管理が簡素化され、アプリケーションの成長に伴いコードベースの保守や拡張が容易になります。
|
|
1233
|
-
|
|
1234
|
-
以下は、TypeScriptで実装されたローカライズされた `Link` コンポーネントの例です。
|
|
1235
|
-
|
|
1236
|
-
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1237
|
-
import { getLocalizedUrl } from "intlayer";
|
|
1238
|
-
import {
|
|
1239
|
-
forwardRef,
|
|
1240
|
-
type DetailedHTMLProps,
|
|
1241
|
-
type AnchorHTMLAttributes,
|
|
1242
|
-
} from "react";
|
|
1243
|
-
import { useLocale } from "react-intlayer";
|
|
1244
|
-
|
|
1245
|
-
export interface LinkProps extends DetailedHTMLProps<
|
|
1246
|
-
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
1247
|
-
HTMLAnchorElement
|
|
1248
|
-
> {}
|
|
1249
|
-
|
|
1250
|
-
/**
|
|
1251
|
-
* 指定されたURLが外部リンクかどうかを判定するユーティリティ関数。
|
|
1252
|
-
* URLが http:// または https:// で始まる場合、外部リンクとみなされます。
|
|
1253
|
-
*/
|
|
1254
|
-
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1255
|
-
/^https?:\/\//.test(href ?? "");
|
|
1256
|
-
|
|
1257
|
-
/**
|
|
1258
|
-
* 現在のロケールに基づいてhref属性を適応するカスタムLinkコンポーネント。
|
|
1259
|
-
* 内部リンクの場合、`getLocalizedUrl`を使用してURLの先頭にロケールを付加します(例:/fr/about)。
|
|
1260
|
-
* これにより、ナビゲーションが同じロケールコンテキスト内に留まることを保証します。
|
|
1261
|
-
*/
|
|
1262
|
-
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
1263
|
-
({ href, children, ...props }, ref) => {
|
|
1264
|
-
const { locale } = useLocale();
|
|
1265
|
-
const isExternalLink = checkIsExternalLink(href);
|
|
1266
|
-
|
|
1267
|
-
// リンクが内部リンクで有効なhrefが提供されている場合、ローカライズされたURLを取得します。
|
|
1268
|
-
const hrefI18n =
|
|
1269
|
-
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1270
|
-
|
|
1271
|
-
return (
|
|
1272
|
-
<a href={hrefI18n} ref={ref} {...props}>
|
|
1273
|
-
{children}
|
|
1274
|
-
</a>
|
|
1275
|
-
);
|
|
1276
|
-
}
|
|
1277
|
-
);
|
|
1278
|
-
|
|
1279
|
-
Link.displayName = "Link";
|
|
200
|
+
```bash packageManager="npm"
|
|
201
|
+
npm run build # または npm run dev
|
|
1280
202
|
```
|
|
1281
203
|
|
|
1282
|
-
```
|
|
1283
|
-
|
|
1284
|
-
import { useLocale } from "react-intlayer";
|
|
1285
|
-
import { forwardRef } from "react";
|
|
1286
|
-
|
|
1287
|
-
/**
|
|
1288
|
-
* 指定されたURLが外部リンクかどうかをチェックするユーティリティ関数。
|
|
1289
|
-
* URLが http:// または https:// で始まる場合、外部リンクとみなされます。
|
|
1290
|
-
*/
|
|
1291
|
-
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1292
|
-
/^https?:\/\//.test(href ?? "");
|
|
1293
|
-
|
|
1294
|
-
/**
|
|
1295
|
-
* 現在のロケールに基づいてhref属性を適応させるカスタムLinkコンポーネント。
|
|
1296
|
-
* 内部リンクの場合、`getLocalizedUrl`を使用してURLにロケールのプレフィックスを付けます(例:/fr/about)。
|
|
1297
|
-
* これにより、ナビゲーションが同じロケールのコンテキスト内に留まることが保証されます。
|
|
1298
|
-
*/
|
|
1299
|
-
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1300
|
-
const { locale } = useLocale();
|
|
1301
|
-
const isExternalLink = checkIsExternalLink(href);
|
|
1302
|
-
|
|
1303
|
-
// リンクが内部リンクで有効なhrefが提供されている場合、ローカライズされたURLを取得します。
|
|
1304
|
-
const hrefI18n =
|
|
1305
|
-
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1306
|
-
|
|
1307
|
-
return (
|
|
1308
|
-
<a href={hrefI18n} ref={ref} {...props}>
|
|
1309
|
-
{children}
|
|
1310
|
-
</a>
|
|
1311
|
-
);
|
|
1312
|
-
});
|
|
1313
|
-
|
|
1314
|
-
Link.displayName = "Link";
|
|
204
|
+
```bash packageManager="pnpm"
|
|
205
|
+
pnpm run build # または pnpm run dev
|
|
1315
206
|
```
|
|
1316
207
|
|
|
1317
|
-
```
|
|
1318
|
-
|
|
1319
|
-
const { useLocale } = require("react-intlayer");
|
|
1320
|
-
const { forwardRef } = require("react");
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* 指定されたURLが外部リンクかどうかをチェックするユーティリティ関数。
|
|
1324
|
-
* URLが http:// または https:// で始まる場合、外部リンクと見なされます。
|
|
1325
|
-
*/
|
|
1326
|
-
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1327
|
-
|
|
1328
|
-
/**
|
|
1329
|
-
* 現在のロケールに基づいて href 属性を適応するカスタム Link コンポーネント。
|
|
1330
|
-
* 内部リンクの場合、`getLocalizedUrl` を使用して URL にロケールをプレフィックスします(例: /fr/about)。
|
|
1331
|
-
* これにより、ナビゲーションが同じロケールのコンテキスト内に留まることが保証されます。
|
|
1332
|
-
*/
|
|
1333
|
-
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1334
|
-
const { locale } = useLocale();
|
|
1335
|
-
const isExternalLink = checkIsExternalLink(href);
|
|
1336
|
-
|
|
1337
|
-
// リンクが内部リンクで有効な href が提供されている場合、ローカライズされた URL を取得します。
|
|
1338
|
-
const localizedHref = isExternalLink ? href : getLocalizedUrl(href, locale);
|
|
1339
|
-
|
|
1340
|
-
return (
|
|
1341
|
-
<a
|
|
1342
|
-
href={localizedHref}
|
|
1343
|
-
ref={ref}
|
|
1344
|
-
{...props}
|
|
1345
|
-
aria-current={isExternalLink ? "external" : undefined}
|
|
1346
|
-
>
|
|
1347
|
-
{children}
|
|
1348
|
-
</a>
|
|
1349
|
-
);
|
|
1350
|
-
});
|
|
1351
|
-
|
|
1352
|
-
Link.displayName = "Link";
|
|
208
|
+
```bash packageManager="yarn"
|
|
209
|
+
yarn build # または yarn dev
|
|
1353
210
|
```
|
|
1354
211
|
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
- **外部リンクの検出**:
|
|
1358
|
-
ヘルパー関数 `checkIsExternalLink` は、URLが外部リンクかどうかを判定します。外部リンクはローカライズの必要がないため、そのままにされます。
|
|
1359
|
-
|
|
1360
|
-
- **現在のロケールの取得**:
|
|
1361
|
-
`useLocale` フックは現在のロケール(例:フランス語の場合は `fr`)を提供します。
|
|
1362
|
-
|
|
1363
|
-
- **URLのローカライズ**:
|
|
1364
|
-
内部リンク(すなわち外部リンクでない場合)には、`getLocalizedUrl` が使用され、URLの先頭に現在のロケールを自動的に付加します。例えば、ユーザーがフランス語環境にいる場合、`href` に `/about` を渡すと `/fr/about` に変換されます。
|
|
1365
|
-
|
|
1366
|
-
- **リンクの返却**:
|
|
1367
|
-
コンポーネントはローカライズされたURLを持つ `<a>` 要素を返し、ナビゲーションがロケールに一貫して対応するようにします。
|
|
1368
|
-
|
|
1369
|
-
この `Link` コンポーネントをアプリケーション全体に統合することで、一貫性のある言語対応のユーザー体験を維持しつつ、SEOや使いやすさの向上も実現できます。
|
|
1370
|
-
|
|
1371
|
-
### TypeScript の設定
|
|
1372
|
-
|
|
1373
|
-
Intlayerはモジュール拡張を利用してTypeScriptの利点を活かし、コードベースをより強固にします。
|
|
1374
|
-
|
|
1375
|
-

|
|
1376
|
-
|
|
1377
|
-

|
|
1378
|
-
|
|
1379
|
-
TypeScriptの設定に自動生成された型を含めることを確認してください。
|
|
1380
|
-
|
|
1381
|
-
```json5 fileName="tsconfig.json"
|
|
1382
|
-
{
|
|
1383
|
-
// ... 既存のTypeScript設定
|
|
1384
|
-
"include": [
|
|
1385
|
-
// ... 既存のTypeScript設定
|
|
1386
|
-
".intlayer/**/*.ts", // 自動生成された型を含める
|
|
1387
|
-
],
|
|
1388
|
-
}
|
|
212
|
+
```bash packageManager="bun"
|
|
213
|
+
bun run build # Or bun run dev
|
|
1389
214
|
```
|
|
1390
215
|
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
Intlayerによって生成されたファイルは無視することを推奨します。これにより、それらをGitリポジトリにコミットするのを避けることができます。
|
|
1394
|
-
|
|
1395
|
-
これを行うには、`.gitignore`ファイルに以下の指示を追加してください。
|
|
1396
|
-
|
|
1397
|
-
```plaintext fileName=".gitignore"
|
|
1398
|
-
# Intlayerによって生成されたファイルを無視する
|
|
1399
|
-
.intlayer
|
|
1400
|
-
```
|
|
216
|
+
</Tab>
|
|
217
|
+
</Tabs>
|
|
1401
218
|
|
|
1402
|
-
|
|
219
|
+
---
|
|
1403
220
|
|
|
1404
|
-
Intlayer
|
|
221
|
+
## ViteとReactアプリケーションでIntlayerをセットアップするステップバイステップガイド
|
|
1405
222
|
|
|
1406
|
-
|
|
223
|
+
<Tabs defaultTab="video">
|
|
224
|
+
<Tab label="ビデオ" value="video">
|
|
225
|
+
|
|
226
|
+
<iframe title="ViteとReactに最適なi18nソリューション?Intlayerを発見" class="m-auto aspect-16/9 w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/dS9L7uJeak4?si=VaKmrYMmXjo3xpk2"/>
|
|
1407
227
|
|
|
1408
|
-
|
|
228
|
+
</Tab>
|
|
229
|
+
<Tab label="コード" value="code">
|
|
1409
230
|
|
|
1410
|
-
|
|
1411
|
-
-
|
|
1412
|
-
-
|
|
1413
|
-
-
|
|
231
|
+
<iframe
|
|
232
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-vite-react-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
233
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
234
|
+
title="Demo CodeSandbox - Intlayerを使ってアプリケーションを国際化する方法"
|
|
235
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
236
|
+
loading="lazy"
|
|
237
|
+
/>
|
|
1414
238
|
|
|
1415
|
-
|
|
239
|
+
</Tab>
|
|
240
|
+
</Tabs>
|
|
1416
241
|
|
|
1417
|
-
|
|
242
|
+
GitHubの[Application Template](https://github.com/aymericzip/intlayer-vite-react-template)を参照してください。
|
|
1418
243
|
|
|
1419
244
|
### さらに進むために
|
|
1420
245
|
|