@intlayer/docs 7.3.10 → 7.3.12
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/dist/cjs/generated/docs.entry.cjs +19 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +19 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_nuxt.md +305 -421
- package/docs/ar/intlayer_with_react_router_v7.md +33 -4
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/ar/intlayer_with_tanstack.md +2 -12
- package/docs/ar/intlayer_with_vite+vue.md +1 -0
- package/docs/de/intlayer_with_nuxt.md +296 -394
- package/docs/de/intlayer_with_react_router_v7.md +33 -4
- package/docs/de/intlayer_with_react_router_v7_fs_routes.md +573 -0
- package/docs/de/intlayer_with_tanstack.md +1 -0
- package/docs/de/intlayer_with_vite+vue.md +1 -0
- package/docs/en/intlayer_with_nuxt.md +242 -321
- package/docs/en/intlayer_with_react_router_v7.md +24 -0
- package/docs/en/intlayer_with_react_router_v7_fs_routes.md +570 -0
- package/docs/en/intlayer_with_tanstack.md +2 -12
- package/docs/en/intlayer_with_vite+vue.md +49 -48
- package/docs/en-GB/intlayer_with_nuxt.md +262 -358
- package/docs/en-GB/intlayer_with_react_router_v7.md +33 -4
- package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +513 -0
- package/docs/en-GB/intlayer_with_tanstack.md +2 -12
- package/docs/en-GB/intlayer_with_vite+vue.md +1 -0
- package/docs/es/intlayer_with_nuxt.md +284 -375
- package/docs/es/intlayer_with_react_router_v7.md +33 -4
- package/docs/es/intlayer_with_react_router_v7_fs_routes.md +575 -0
- package/docs/es/intlayer_with_tanstack.md +1 -0
- package/docs/es/intlayer_with_vite+vue.md +1 -2
- package/docs/fr/intlayer_with_nuxt.md +288 -387
- package/docs/fr/intlayer_with_react_router_v7.md +34 -5
- package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/fr/intlayer_with_tanstack.md +1 -0
- package/docs/fr/intlayer_with_vite+vue.md +1 -0
- package/docs/hi/intlayer_with_nuxt.md +318 -434
- package/docs/hi/intlayer_with_react_router_v7.md +33 -4
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +518 -0
- package/docs/hi/intlayer_with_tanstack.md +2 -12
- package/docs/hi/intlayer_with_vite+vue.md +1 -0
- package/docs/id/intlayer_with_nuxt.md +275 -376
- package/docs/id/intlayer_with_react_router_v7.md +29 -4
- package/docs/id/intlayer_with_react_router_v7_fs_routes.md +521 -0
- package/docs/id/intlayer_with_tanstack.md +2 -12
- package/docs/id/intlayer_with_vite+vue.md +1 -0
- package/docs/it/intlayer_with_nuxt.md +312 -408
- package/docs/it/intlayer_with_react_router_v7.md +33 -4
- package/docs/it/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/it/intlayer_with_tanstack.md +1 -0
- package/docs/ja/intlayer_with_nuxt.md +319 -414
- package/docs/ja/intlayer_with_react_router_v7.md +33 -4
- package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ja/intlayer_with_tanstack.md +2 -12
- package/docs/ja/intlayer_with_vite+vue.md +1 -0
- package/docs/ko/intlayer_with_nuxt.md +307 -406
- package/docs/ko/intlayer_with_react_router_v7.md +33 -4
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +515 -0
- package/docs/ko/intlayer_with_tanstack.md +2 -12
- package/docs/ko/intlayer_with_vite+vue.md +1 -0
- package/docs/pl/intlayer_with_nuxt.md +282 -457
- package/docs/pl/intlayer_with_react_router_v7.md +32 -5
- package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +615 -0
- package/docs/pl/intlayer_with_tanstack.md +2 -12
- package/docs/pl/intlayer_with_vite+vue.md +1 -0
- package/docs/pt/intlayer_with_nuxt.md +288 -403
- package/docs/pt/intlayer_with_react_router_v7.md +28 -0
- package/docs/pt/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_nuxt.md +300 -410
- package/docs/ru/intlayer_with_react_router_v7.md +33 -4
- package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ru/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_vite+vue.md +1 -0
- package/docs/tr/intlayer_with_nuxt.md +327 -392
- package/docs/tr/intlayer_with_react_router_v7.md +33 -4
- package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +572 -0
- package/docs/tr/intlayer_with_tanstack.md +2 -12
- package/docs/tr/intlayer_with_vite+vue.md +1 -0
- package/docs/vi/intlayer_with_nuxt.md +282 -399
- package/docs/vi/intlayer_with_react_router_v7.md +29 -4
- package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +523 -0
- package/docs/vi/intlayer_with_tanstack.md +2 -12
- package/docs/vi/intlayer_with_vite+vue.md +1 -0
- package/docs/zh/intlayer_with_nuxt.md +311 -444
- package/docs/zh/intlayer_with_react_router_v7.md +33 -4
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/zh/intlayer_with_tanstack.md +2 -12
- package/docs/zh/intlayer_with_vite+vue.md +1 -0
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +19 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-06-18
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title: Nuxt
|
|
3
|
+
updatedAt: 2025-12-07
|
|
4
|
+
title: Nuxt と Vue アプリを翻訳する方法 – i18n ガイド 2025
|
|
5
5
|
description: Nuxt と Vue のウェブサイトを多言語対応にする方法を紹介します。国際化(i18n)と翻訳のためのドキュメントに従ってください。
|
|
6
6
|
keywords:
|
|
7
7
|
- 国際化
|
|
@@ -14,35 +14,70 @@ slugs:
|
|
|
14
14
|
- doc
|
|
15
15
|
- environment
|
|
16
16
|
- nuxt-and-vue
|
|
17
|
-
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-template
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-4-template
|
|
18
|
+
youtubeVideo: https://www.youtube.com/watch?v=IE3XWkZ6a5U
|
|
18
19
|
history:
|
|
20
|
+
- version: 7.3.11
|
|
21
|
+
date: 2025-12-07
|
|
22
|
+
changes: LocaleSwitcher、SEO、メタデータの更新
|
|
19
23
|
- version: 5.5.10
|
|
20
24
|
date: 2025-06-29
|
|
21
25
|
changes: 履歴の初期化
|
|
22
26
|
---
|
|
23
27
|
|
|
24
|
-
# Intlayer
|
|
28
|
+
# Intlayer を使って Nuxt と Vue のウェブサイトを翻訳する | 国際化(i18n)
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
## 目次
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
<TOC/>
|
|
33
|
+
|
|
34
|
+
## Intlayerとは?
|
|
29
35
|
|
|
30
36
|
**Intlayer** は、最新のウェブアプリケーションにおける多言語対応を簡素化するために設計された革新的なオープンソースの国際化(i18n)ライブラリです。
|
|
31
37
|
|
|
32
|
-
Intlayer
|
|
38
|
+
Intlayerを使うことで、以下が可能になります:
|
|
33
39
|
|
|
34
40
|
- **コンポーネントレベルで宣言的な辞書を使い、翻訳を簡単に管理**できます。
|
|
35
41
|
- **メタデータ、ルート、コンテンツを動的にローカライズ**できます。
|
|
36
|
-
- **自動生成された型により
|
|
37
|
-
-
|
|
42
|
+
- **自動生成された型によりTypeScriptサポートを確保し、オートコンプリートやエラー検出を向上**させます。
|
|
43
|
+
- **動的なロケール検出や切り替えなどの高度な機能**を利用できます。
|
|
38
44
|
|
|
39
45
|
---
|
|
40
46
|
|
|
41
|
-
## Nuxt
|
|
47
|
+
## NuxtアプリケーションでIntlayerをセットアップするステップバイステップガイド
|
|
48
|
+
|
|
49
|
+
<iframe
|
|
50
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
51
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
52
|
+
title="デモ CodeSandbox - Intlayerを使ってアプリケーションを国際化する方法"
|
|
53
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
54
|
+
loading="lazy"
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
### ステップ1: 依存関係のインストール
|
|
58
|
+
|
|
59
|
+
<Tab defaultTab="video">
|
|
60
|
+
<TabItem label="ビデオ" value="video">
|
|
61
|
+
|
|
62
|
+
<iframe title="NuxtとVueアプリをIntlayerで翻訳する方法?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/IE3XWkZ6a5U?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
63
|
+
|
|
64
|
+
</TabItem>
|
|
65
|
+
<TabItem label="コード" value="code">
|
|
66
|
+
|
|
67
|
+
<iframe
|
|
68
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
69
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
70
|
+
title="デモ CodeSandbox - Intlayerを使ってアプリケーションを国際化する方法"
|
|
71
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
72
|
+
loading="lazy"
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
</TabItem>
|
|
76
|
+
</Tab>
|
|
42
77
|
|
|
43
|
-
|
|
78
|
+
GitHubの[アプリケーションテンプレート](https://github.com/aymericzip/intlayer-nuxt-4-template)を参照してください。
|
|
44
79
|
|
|
45
|
-
npm
|
|
80
|
+
npmを使って必要なパッケージをインストールします:
|
|
46
81
|
|
|
47
82
|
```bash packageManager="npm"
|
|
48
83
|
npm install intlayer vue-intlayer
|
|
@@ -61,17 +96,17 @@ yarn add --save-dev nuxt-intlayer
|
|
|
61
96
|
|
|
62
97
|
- **intlayer**
|
|
63
98
|
|
|
64
|
-
設定管理、翻訳、[コンテンツ宣言](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/
|
|
99
|
+
設定管理、翻訳、[コンテンツ宣言](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/content_file.md)、トランスパイル、および[CLIコマンド](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/cli/index.md)のための国際化ツールを提供するコアパッケージです。
|
|
65
100
|
|
|
66
101
|
- **vue-intlayer**
|
|
67
|
-
IntlayerをVueアプリケーションに統合するパッケージです。Vue
|
|
102
|
+
IntlayerをVueアプリケーションに統合するパッケージです。Vueコンポーネント用のcomposablesを提供します。
|
|
68
103
|
|
|
69
104
|
- **nuxt-intlayer**
|
|
70
|
-
Nuxt
|
|
105
|
+
NuxtアプリケーションとIntlayerを統合するNuxtモジュールです。自動セットアップ、ロケール検出のためのミドルウェア、クッキー管理、URLリダイレクトを提供します。
|
|
71
106
|
|
|
72
107
|
### ステップ2: プロジェクトの設定
|
|
73
108
|
|
|
74
|
-
|
|
109
|
+
アプリケーションの言語を設定するための設定ファイルを作成します。
|
|
75
110
|
|
|
76
111
|
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
77
112
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -82,13 +117,10 @@ const config: IntlayerConfig = {
|
|
|
82
117
|
Locales.ENGLISH,
|
|
83
118
|
Locales.FRENCH,
|
|
84
119
|
Locales.SPANISH,
|
|
85
|
-
//
|
|
120
|
+
// 他のロケールをここに追加
|
|
86
121
|
],
|
|
87
122
|
defaultLocale: Locales.ENGLISH,
|
|
88
123
|
},
|
|
89
|
-
content: {
|
|
90
|
-
contentDir: ["."], // デフォルトではIntlayerは`./src`ディレクトリのコンテンツ宣言ファイルを監視します
|
|
91
|
-
},
|
|
92
124
|
};
|
|
93
125
|
|
|
94
126
|
export default config;
|
|
@@ -108,9 +140,6 @@ const config = {
|
|
|
108
140
|
],
|
|
109
141
|
defaultLocale: Locales.ENGLISH,
|
|
110
142
|
},
|
|
111
|
-
content: {
|
|
112
|
-
contentDir: ["."],
|
|
113
|
-
},
|
|
114
143
|
};
|
|
115
144
|
|
|
116
145
|
export default config;
|
|
@@ -130,19 +159,16 @@ const config = {
|
|
|
130
159
|
],
|
|
131
160
|
defaultLocale: Locales.ENGLISH,
|
|
132
161
|
},
|
|
133
|
-
content: {
|
|
134
|
-
contentDir: ["."],
|
|
135
|
-
},
|
|
136
162
|
};
|
|
137
163
|
|
|
138
164
|
module.exports = config;
|
|
139
165
|
```
|
|
140
166
|
|
|
141
|
-
> この設定ファイルを通じて、ローカライズされたURL
|
|
167
|
+
> この設定ファイルを通じて、ローカライズされたURL、ミドルウェアのリダイレクション、クッキー名、コンテンツ宣言の場所と拡張子、Intlayerのコンソールログの無効化などを設定できます。利用可能なパラメータの完全なリストについては、[設定ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/configuration.md)を参照してください。
|
|
142
168
|
|
|
143
169
|
### ステップ3: Nuxt設定にIntlayerを統合する
|
|
144
170
|
|
|
145
|
-
Nuxtの設定にintlayer
|
|
171
|
+
Nuxtの設定にintlayerモジュールを追加します:
|
|
146
172
|
|
|
147
173
|
```typescript fileName="nuxt.config.ts"
|
|
148
174
|
import { defineNuxtConfig } from "nuxt/config";
|
|
@@ -153,229 +179,46 @@ export default defineNuxtConfig({
|
|
|
153
179
|
});
|
|
154
180
|
```
|
|
155
181
|
|
|
156
|
-
> `nuxt-intlayer` モジュールは、Intlayer と Nuxt
|
|
182
|
+
> `nuxt-intlayer` モジュールは、Intlayer と Nuxt の統合を自動的に処理します。コンテンツ宣言のビルドを設定し、開発モードでファイルを監視し、ロケール検出のためのミドルウェアを提供し、ローカライズされたルーティングを管理します。
|
|
157
183
|
|
|
158
184
|
### ステップ 4: コンテンツを宣言する
|
|
159
185
|
|
|
160
186
|
翻訳を格納するためのコンテンツ宣言を作成および管理します:
|
|
161
187
|
|
|
162
|
-
```tsx fileName="
|
|
163
|
-
import {
|
|
188
|
+
```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
|
|
189
|
+
import { type Dictionary, t } from "intlayer";
|
|
164
190
|
|
|
165
|
-
const
|
|
166
|
-
key: "
|
|
191
|
+
const content = {
|
|
192
|
+
key: "home-page",
|
|
167
193
|
content: {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
173
|
-
}),
|
|
174
|
-
checkOut: t({ en: "Check out ", fr: "Vérifiez ", es: "Compruebe " }),
|
|
175
|
-
nuxtIntlayer: t({
|
|
176
|
-
en: "Nuxt Intlayer documentation",
|
|
177
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
178
|
-
es: "Documentación de Nuxt Intlayer",
|
|
179
|
-
}),
|
|
180
|
-
learnMore: t({
|
|
181
|
-
en: "Learn more about Nuxt in the ",
|
|
182
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
183
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
184
|
-
}),
|
|
185
|
-
nuxtDocs: t({
|
|
186
|
-
en: "Nuxt Documentation",
|
|
187
|
-
fr: "Documentation Nuxt",
|
|
188
|
-
es: "Documentación de Nuxt",
|
|
194
|
+
title: t({
|
|
195
|
+
en: "Hello world",
|
|
196
|
+
fr: "Bonjour le monde",
|
|
197
|
+
es: "Hola mundo",
|
|
189
198
|
}),
|
|
190
|
-
|
|
191
|
-
en: "
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
199
|
+
metaTitle: t({
|
|
200
|
+
en: "Welcome | My Application",
|
|
201
|
+
fr: "Bienvenue | Mon Application",
|
|
202
|
+
es: "Bienvenido | Mi Aplicación",
|
|
195
203
|
}),
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
201
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
204
|
+
metaDescription: t({
|
|
205
|
+
en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
|
|
206
|
+
fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
|
|
207
|
+
es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
|
|
202
208
|
}),
|
|
203
209
|
},
|
|
204
210
|
} satisfies Dictionary;
|
|
205
211
|
|
|
206
|
-
export default
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
```javascript fileName="components/helloWorld.content.mjs" contentDeclarationFormat="esm"
|
|
210
|
-
import { t } from "intlayer";
|
|
211
|
-
|
|
212
|
-
/** @type {import('intlayer').Dictionary} */
|
|
213
|
-
const helloWorldContent = {
|
|
214
|
-
key: "helloworld",
|
|
215
|
-
content: {
|
|
216
|
-
count: t({
|
|
217
|
-
en: "count is ",
|
|
218
|
-
ja: "カウントは ",
|
|
219
|
-
fr: "le compte est ",
|
|
220
|
-
es: "el recuento es ",
|
|
221
|
-
}),
|
|
222
|
-
edit: t({
|
|
223
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
224
|
-
ja: "<code>components/HelloWorld.vue</code> を編集して保存し、HMRをテストしてください",
|
|
225
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
226
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
227
|
-
}),
|
|
228
|
-
checkOut: t({
|
|
229
|
-
ja: "チェックしてください ",
|
|
230
|
-
en: "Check out ",
|
|
231
|
-
fr: "Vérifiez ",
|
|
232
|
-
es: "Compruebe ",
|
|
233
|
-
}),
|
|
234
|
-
nuxtIntlayer: t({
|
|
235
|
-
ja: "Nuxt Intlayer ドキュメント",
|
|
236
|
-
en: "Nuxt Intlayer documentation",
|
|
237
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
238
|
-
es: "Documentación de Nuxt Intlayer",
|
|
239
|
-
}),
|
|
240
|
-
learnMore: t({
|
|
241
|
-
ja: "Nuxt について詳しくは ",
|
|
242
|
-
en: "Learn more about Nuxt in the ",
|
|
243
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
244
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
245
|
-
}),
|
|
246
|
-
nuxtDocs: t({
|
|
247
|
-
ja: "Nuxt ドキュメント",
|
|
248
|
-
en: "Nuxt Documentation",
|
|
249
|
-
fr: "Documentation Nuxt",
|
|
250
|
-
es: "Documentación de Nuxt",
|
|
251
|
-
}),
|
|
252
|
-
readTheDocs: t({
|
|
253
|
-
ja: "Nuxt ロゴをクリックして詳細を確認してください",
|
|
254
|
-
en: "Click on the Nuxt logo to learn more",
|
|
255
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
256
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
257
|
-
}),
|
|
258
|
-
},
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
export default helloWorldContent;
|
|
212
|
+
export default content;
|
|
262
213
|
```
|
|
263
214
|
|
|
264
|
-
|
|
265
|
-
const { t } = require("intlayer");
|
|
215
|
+
> コンテンツ宣言は、`contentDir` ディレクトリ(デフォルトは `./src`)に含まれている限り、アプリケーションのどこにでも定義できます。また、コンテンツ宣言ファイルの拡張子(デフォルトは `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`)に一致している必要があります。
|
|
266
216
|
|
|
267
|
-
|
|
268
|
-
const helloWorldContent = {
|
|
269
|
-
key: "helloworld",
|
|
270
|
-
content: {
|
|
271
|
-
count: t({ ja: "カウントは ", en: "count is ", fr: "le compte est ", es: "el recuento es " }),
|
|
272
|
-
edit: t({
|
|
273
|
-
ja: "<code>components/HelloWorld.vue</code> を編集して保存し、HMRをテストしてください",
|
|
274
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
275
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
276
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
277
|
-
}),
|
|
278
|
-
checkOut: t({ ja: "チェックしてください ", en: "Check out ", fr: "Vérifiez ", es: "Compruebe " }),
|
|
279
|
-
nuxtIntlayer: t({
|
|
280
|
-
ja: "Nuxt Intlayer ドキュメント",
|
|
281
|
-
en: "Nuxt Intlayer documentation",
|
|
282
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
283
|
-
es: "Documentación de Nuxt Intlayer",
|
|
284
|
-
}),
|
|
285
|
-
es: "Nuxt Intlayerのドキュメント",
|
|
286
|
-
}),
|
|
287
|
-
learnMore: t({
|
|
288
|
-
en: "Learn more about Nuxt in the ",
|
|
289
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
290
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
291
|
-
ja: "Nuxtについて詳しくは、",
|
|
292
|
-
}),
|
|
293
|
-
nuxtDocs: t({
|
|
294
|
-
en: "Nuxt Documentation",
|
|
295
|
-
fr: "Documentation Nuxt",
|
|
296
|
-
es: "Documentación de Nuxt",
|
|
297
|
-
ja: "Nuxtドキュメント",
|
|
298
|
-
}),
|
|
299
|
-
readTheDocs: t({
|
|
300
|
-
en: "Click on the Nuxt logo to learn more",
|
|
301
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
302
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
303
|
-
ja: "Nuxtのロゴをクリックして詳細を確認してください",
|
|
304
|
-
}),
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
module.exports = helloWorldContent;
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
```json fileName="components/helloWorld.content.json" contentDeclarationFormat="json"
|
|
312
|
-
{
|
|
313
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
314
|
-
"key": "helloworld",
|
|
315
|
-
"content": {
|
|
316
|
-
"count": {
|
|
317
|
-
"nodeType": "translation",
|
|
318
|
-
"translation": {
|
|
319
|
-
"en": "count is ",
|
|
320
|
-
"fr": "le compte est ",
|
|
321
|
-
"es": "el recuento es ",
|
|
322
|
-
"ja": "カウントは "
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
"edit": {
|
|
326
|
-
"nodeType": "translation",
|
|
327
|
-
"translation": {
|
|
328
|
-
"en": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
329
|
-
"fr": "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
330
|
-
"es": "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
331
|
-
"ja": "<code>components/HelloWorld.vue</code> を編集して保存し、HMRをテストしてください"
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
"checkOut": {
|
|
335
|
-
"nodeType": "translation",
|
|
336
|
-
"translation": {
|
|
337
|
-
"en": "Check out ",
|
|
338
|
-
"fr": "Vérifiez ",
|
|
339
|
-
"es": "Compruebe ",
|
|
340
|
-
"ja": "チェックしてください "
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
|
-
"nuxtIntlayer": {
|
|
344
|
-
"nodeType": "translation",
|
|
345
|
-
"translation": {
|
|
346
|
-
"ja": "Nuxt Intlayer ドキュメント"
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
"learnMore": {
|
|
350
|
-
"nodeType": "translation",
|
|
351
|
-
"translation": {
|
|
352
|
-
"ja": "Nuxt について詳しくは "
|
|
353
|
-
}
|
|
354
|
-
},
|
|
355
|
-
"nuxtDocs": {
|
|
356
|
-
"nodeType": "translation",
|
|
357
|
-
"translation": {
|
|
358
|
-
"ja": "Nuxt ドキュメント"
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
"readTheDocs": {
|
|
362
|
-
"nodeType": "translation",
|
|
363
|
-
"translation": {
|
|
364
|
-
"ja": "Nuxt ロゴをクリックして詳細を確認してください"
|
|
365
|
-
"es": "Haga clic en el logotipo de Nuxt para obtener más información"
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
> あなたのコンテンツ宣言は、`contentDir` ディレクトリ(デフォルトは `./src`)内に含まれている限り、アプリケーションのどこにでも定義できます。また、コンテンツ宣言ファイルの拡張子(デフォルトは `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`)に一致している必要があります。
|
|
373
|
-
|
|
374
|
-
> 詳細については、[コンテンツ宣言のドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/get_started.md)を参照してください。
|
|
217
|
+
> 詳細については、[コンテンツ宣言ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/content_file.md)を参照してください。
|
|
375
218
|
|
|
376
219
|
### ステップ5: コード内でIntlayerを利用する
|
|
377
220
|
|
|
378
|
-
`useIntlayer
|
|
221
|
+
`useIntlayer`コンポーザブルを使って、Nuxtアプリケーション全体でコンテンツ辞書にアクセスします:
|
|
379
222
|
|
|
380
223
|
```vue fileName="components/HelloWorld.vue"
|
|
381
224
|
<script setup lang="ts">
|
|
@@ -413,97 +256,87 @@ const countRef = ref(0);
|
|
|
413
256
|
<checkOut />
|
|
414
257
|
<a href="https://nuxt.com/docs/getting-started/introduction" target="_blank"
|
|
415
258
|
>Nuxt</a
|
|
416
|
-
|
|
259
|
+
>、<nuxtIntlayer />
|
|
417
260
|
</p>
|
|
418
261
|
<p>
|
|
419
262
|
<learnMore />
|
|
420
|
-
<a href="https://nuxt.com" target="_blank"><nuxtDocs /></a
|
|
263
|
+
<a href="https://nuxt.com" target="_blank"><nuxtDocs /></a>。
|
|
421
264
|
</p>
|
|
422
265
|
<p class="read-the-docs"><readTheDocs /></p>
|
|
423
266
|
<p class="read-the-docs">{{ readTheDocs }}</p>
|
|
424
267
|
</template>
|
|
425
268
|
```
|
|
426
269
|
|
|
427
|
-
#### Intlayer
|
|
270
|
+
#### Intlayerでのコンテンツアクセス
|
|
428
271
|
|
|
429
|
-
Intlayer
|
|
272
|
+
IntlayerはコンテンツにアクセスするためのさまざまなAPIを提供しています:
|
|
430
273
|
|
|
431
274
|
- **コンポーネントベースの構文**(推奨):
|
|
432
|
-
`<myContent />` または `<Component :is="myContent" />`
|
|
275
|
+
`<myContent />` または `<Component :is="myContent" />` の構文を使用して、コンテンツを Intlayer ノードとしてレンダリングします。これは [Visual Editor](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) とシームレスに統合されます。
|
|
433
276
|
|
|
434
|
-
-
|
|
435
|
-
`{{ myContent }}`
|
|
277
|
+
- **文字列ベースの構文**:
|
|
278
|
+
`{{ myContent }}` を使用して、Visual Editor のサポートなしにプレーンテキストとしてコンテンツをレンダリングします。
|
|
436
279
|
|
|
437
|
-
- **生のHTML
|
|
438
|
-
`<div v-html="myContent" />`
|
|
280
|
+
- **生の HTML 構文**:
|
|
281
|
+
`<div v-html="myContent" />` を使用して、Visual Editor のサポートなしに生の HTML としてコンテンツをレンダリングします。
|
|
439
282
|
|
|
440
|
-
-
|
|
441
|
-
`useIntlayer`
|
|
442
|
-
- `const content = useIntlayer("myContent");`
|
|
443
|
-
-
|
|
283
|
+
- **分割代入構文**:
|
|
284
|
+
`useIntlayer` コンポーザブルはコンテンツを含む Proxy を返します。この Proxy はリアクティビティを保ちながらコンテンツにアクセスするために分割代入可能です。
|
|
285
|
+
- `const content = useIntlayer("myContent");` を使用し、`{{ content.myContent }}` / `<content.myContent />` としてレンダリングします。
|
|
286
|
+
- または、`const { myContent } = useIntlayer("myContent");` を使用してコンテンツを分割代入し、`{{ myContent }}` / `<myContent/>` としてレンダリングします。
|
|
444
287
|
|
|
445
288
|
### (オプション)ステップ6: コンテンツの言語を変更する
|
|
446
289
|
|
|
447
|
-
コンテンツの言語を変更するには、`useLocale` コンポーザブルが提供する `setLocale`
|
|
290
|
+
コンテンツの言語を変更するには、`useLocale` コンポーザブルが提供する `setLocale` 関数を使用します。この関数により、アプリケーションのロケールを設定し、それに応じてコンテンツを更新できます。
|
|
448
291
|
|
|
449
|
-
|
|
292
|
+
`NuxtLink` を使用して言語を切り替えるコンポーネントを作成します。**ロケール切り替えにボタンではなくリンクを使うことは、SEOやページの発見性向上のベストプラクティスです**。これにより、検索エンジンがすべてのローカライズされたページをクロールしインデックス化できます。
|
|
450
293
|
|
|
451
294
|
```vue fileName="components/LocaleSwitcher.vue"
|
|
452
|
-
<template>
|
|
453
|
-
<div class="locale-switcher">
|
|
454
|
-
<select v-model="selectedLocale" @change="changeLocale">
|
|
455
|
-
<option v-for="loc in availableLocales" :key="loc" :value="loc">
|
|
456
|
-
{{ getLocaleName(loc) }}
|
|
457
|
-
</option>
|
|
458
|
-
</select>
|
|
459
|
-
</div>
|
|
460
|
-
</template>
|
|
461
|
-
|
|
462
295
|
<script setup lang="ts">
|
|
463
|
-
import {
|
|
464
|
-
import { getLocaleName } from "intlayer";
|
|
296
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
465
297
|
import { useLocale } from "vue-intlayer";
|
|
466
298
|
|
|
467
|
-
//
|
|
299
|
+
// NuxtはuseRouteを自動インポートします
|
|
300
|
+
const route = useRoute();
|
|
468
301
|
const { locale, availableLocales, setLocale } = useLocale();
|
|
469
|
-
|
|
470
|
-
// ref で選択されたロケールを追跡
|
|
471
|
-
const selectedLocale = ref(locale.value);
|
|
472
|
-
|
|
473
|
-
// 選択が変更されたときにロケールを更新
|
|
474
|
-
const changeLocale = () => setLocale(selectedLocale.value);
|
|
475
|
-
|
|
476
|
-
// selectedLocale をグローバルロケールと同期させる
|
|
477
|
-
watch(
|
|
478
|
-
() => locale.value,
|
|
479
|
-
(newLocale) => {
|
|
480
|
-
selectedLocale.value = newLocale;
|
|
481
|
-
}
|
|
482
|
-
);
|
|
483
302
|
</script>
|
|
303
|
+
|
|
304
|
+
<template>
|
|
305
|
+
<nav class="locale-switcher">
|
|
306
|
+
<NuxtLink
|
|
307
|
+
v-for="localeEl in availableLocales"
|
|
308
|
+
:key="localeEl"
|
|
309
|
+
:to="getLocalizedUrl(route.fullPath, localeEl)"
|
|
310
|
+
class="locale-link"
|
|
311
|
+
:class="{ 'active-locale': localeEl === locale }"
|
|
312
|
+
@click="setLocale(localeEl)"
|
|
313
|
+
>
|
|
314
|
+
{{ getLocaleName(localeEl) }}
|
|
315
|
+
</NuxtLink>
|
|
316
|
+
</nav>
|
|
484
317
|
</template>
|
|
318
|
+
```
|
|
485
319
|
|
|
486
|
-
|
|
487
|
-
.locale-switcher {
|
|
488
|
-
margin: 1rem 0;
|
|
489
|
-
}
|
|
320
|
+
> `NuxtLink` を適切な `href` 属性(`getLocalizedUrl` 経由)と共に使用することで、検索エンジンがページのすべての言語バリアントを検出できるようになります。これは、検索エンジンクローラーが追跡しない可能性のあるJavaScriptのみのロケール切り替えよりも望ましい方法です。
|
|
490
321
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
322
|
+
次に、`app.vue` を設定してレイアウトを使用します:
|
|
323
|
+
|
|
324
|
+
```vue fileName="app.vue"
|
|
325
|
+
<template>
|
|
326
|
+
<NuxtLayout>
|
|
327
|
+
<NuxtPage />
|
|
328
|
+
</NuxtLayout>
|
|
329
|
+
</template>
|
|
497
330
|
```
|
|
498
331
|
|
|
499
|
-
|
|
332
|
+
### (オプション)ステップ6b:ナビゲーション付きレイアウトの作成
|
|
500
333
|
|
|
501
|
-
|
|
334
|
+
Nuxtのレイアウトを使うと、ページの共通構造を定義できます。ロケールスイッチャーとナビゲーションを含むデフォルトレイアウトを作成しましょう:
|
|
335
|
+
|
|
336
|
+
```vue fileName="layouts/default.vue"
|
|
502
337
|
<script setup lang="ts">
|
|
503
|
-
import
|
|
338
|
+
import Links from "~/components/Links.vue";
|
|
504
339
|
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
505
|
-
|
|
506
|
-
const content = useIntlayer("app"); // 関連するintlayer宣言ファイルを作成
|
|
507
340
|
</script>
|
|
508
341
|
|
|
509
342
|
<template>
|
|
@@ -512,17 +345,22 @@ const content = useIntlayer("app"); // 関連するintlayer宣言ファイルを
|
|
|
512
345
|
<LocaleSwitcher />
|
|
513
346
|
</header>
|
|
514
347
|
<main>
|
|
515
|
-
<
|
|
348
|
+
<slot />
|
|
516
349
|
</main>
|
|
350
|
+
|
|
351
|
+
<Links href="/">ホーム</Links>
|
|
352
|
+
<Links href="/about">アバウト</Links>
|
|
517
353
|
</div>
|
|
518
354
|
</template>
|
|
519
355
|
```
|
|
520
356
|
|
|
521
|
-
|
|
357
|
+
`Links` コンポーネント(以下に示す)は、内部ナビゲーションリンクが自動的にローカライズされることを保証します。
|
|
522
358
|
|
|
523
|
-
|
|
359
|
+
### (オプション)ステップ7: アプリケーションにローカライズされたルーティングを追加する
|
|
524
360
|
|
|
525
|
-
|
|
361
|
+
`nuxt-intlayer` モジュールを使用すると、Nuxtはローカライズされたルーティングを自動的に処理します。これは、ページのディレクトリ構造に基づいて各言語のルートを自動的に作成します。
|
|
362
|
+
|
|
363
|
+
例:
|
|
526
364
|
|
|
527
365
|
```plaintext
|
|
528
366
|
pages/
|
|
@@ -532,217 +370,286 @@ pages/
|
|
|
532
370
|
└── index.vue → /contact, /fr/contact, /es/contact
|
|
533
371
|
```
|
|
534
372
|
|
|
535
|
-
|
|
373
|
+
ローカライズされたページを作成するには、単に `pages/` ディレクトリに Vue ファイルを作成します。以下に2つの例を示します。
|
|
536
374
|
|
|
537
|
-
|
|
375
|
+
**ホームページ (`pages/index.vue`):**
|
|
376
|
+
|
|
377
|
+
```vue fileName="pages/index.vue"
|
|
538
378
|
<script setup lang="ts">
|
|
539
379
|
import { useIntlayer } from "vue-intlayer";
|
|
540
380
|
|
|
541
|
-
const content = useIntlayer("
|
|
381
|
+
const content = useIntlayer("home-page");
|
|
382
|
+
|
|
383
|
+
useHead({
|
|
384
|
+
title: content.metaTitle.value,
|
|
385
|
+
meta: [
|
|
386
|
+
{
|
|
387
|
+
name: "description",
|
|
388
|
+
content: content.metaDescription.value,
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
});
|
|
542
392
|
</script>
|
|
543
393
|
|
|
544
394
|
<template>
|
|
545
|
-
<
|
|
546
|
-
<h1>{{ content.title }}</h1>
|
|
547
|
-
<p>{{ content.description }}</p>
|
|
548
|
-
</div>
|
|
395
|
+
<h1><content.title /></h1>
|
|
549
396
|
</template>
|
|
550
397
|
```
|
|
551
398
|
|
|
552
|
-
`
|
|
399
|
+
**アバウトページ (`pages/about.vue`):**
|
|
553
400
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
- ロケールクッキーを管理する
|
|
558
|
-
- ユーザーを適切なローカライズされたURLにリダイレクトする
|
|
401
|
+
```vue fileName="pages/about.vue"
|
|
402
|
+
<script setup lang="ts">
|
|
403
|
+
import { useIntlayer } from "vue-intlayer";
|
|
559
404
|
|
|
560
|
-
|
|
405
|
+
const content = useIntlayer("about-page");
|
|
561
406
|
|
|
562
|
-
|
|
407
|
+
useHead({
|
|
408
|
+
title: content.metaTitle.raw, // プリミティブ文字列アクセスには .raw を使用
|
|
409
|
+
meta: [
|
|
410
|
+
{
|
|
411
|
+
name: "description",
|
|
412
|
+
content: content.metaDescription.raw, // プリミティブな文字列アクセスには .raw を使用
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
});
|
|
416
|
+
</script>
|
|
563
417
|
|
|
564
|
-
```vue fileName="components/LocalizedLink.vue"
|
|
565
418
|
<template>
|
|
566
|
-
<
|
|
567
|
-
<slot />
|
|
568
|
-
</NuxtLink>
|
|
419
|
+
<h1><content.title /></h1>
|
|
569
420
|
</template>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
> 注意: `useHead` は Nuxt で自動インポートされます。コンテンツの値には `.value`(リアクティブ)または `.raw`(プリミティブ文字列)を用途に応じて使用できます。
|
|
424
|
+
|
|
425
|
+
`nuxt-intlayer` モジュールは自動的に以下を行います:
|
|
426
|
+
|
|
427
|
+
- ユーザーの優先ロケールを検出
|
|
428
|
+
- URL を介したロケール切り替えの処理
|
|
429
|
+
- 適切な `<html lang="">` 属性の設定
|
|
430
|
+
- ロケールクッキーの管理
|
|
431
|
+
- ユーザーを適切なローカライズされた URL にリダイレクト
|
|
432
|
+
|
|
433
|
+
### (オプション)ステップ8:ローカライズされたリンクコンポーネントの作成
|
|
434
|
+
|
|
435
|
+
アプリケーションのナビゲーションが現在のロケールを尊重するようにするために、カスタムの `Links` コンポーネントを作成できます。このコンポーネントは内部URLに自動的に現在の言語をプレフィックスとして付加し、これは**SEOおよびページの発見性**に不可欠です。
|
|
570
436
|
|
|
437
|
+
```vue fileName="components/Links.vue"
|
|
571
438
|
<script setup lang="ts">
|
|
572
|
-
import { computed } from "vue";
|
|
573
439
|
import { getLocalizedUrl } from "intlayer";
|
|
574
440
|
import { useLocale } from "vue-intlayer";
|
|
575
441
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
},
|
|
581
|
-
});
|
|
442
|
+
interface Props {
|
|
443
|
+
href: string;
|
|
444
|
+
locale?: string;
|
|
445
|
+
}
|
|
582
446
|
|
|
583
|
-
const
|
|
447
|
+
const props = defineProps<Props>();
|
|
584
448
|
|
|
585
|
-
|
|
586
|
-
const isExternalLink = computed(() => /^https?:\/\//.test(props.to || ""));
|
|
449
|
+
const { locale: currentLocale } = useLocale();
|
|
587
450
|
|
|
588
|
-
//
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
);
|
|
451
|
+
// 最終的なパスを計算する
|
|
452
|
+
const finalPath = computed(() => {
|
|
453
|
+
// 1. リンクが外部かどうかをチェック
|
|
454
|
+
const isExternal = /^https?:\/\//.test(props.href || "");
|
|
455
|
+
|
|
456
|
+
// 2. 外部の場合はそのまま返す(NuxtLinkが<a>タグの生成を処理)
|
|
457
|
+
if (isExternal) return props.href;
|
|
458
|
+
|
|
459
|
+
// 3. 内部リンクの場合、URLをローカライズする
|
|
460
|
+
const targetLocale = props.locale || currentLocale.value;
|
|
461
|
+
return getLocalizedUrl(props.href, targetLocale);
|
|
462
|
+
});
|
|
592
463
|
</script>
|
|
464
|
+
|
|
465
|
+
<template>
|
|
466
|
+
<NuxtLink :to="finalPath" v-bind="$attrs">
|
|
467
|
+
<slot />
|
|
468
|
+
</NuxtLink>
|
|
469
|
+
</template>
|
|
593
470
|
```
|
|
594
471
|
|
|
595
|
-
|
|
472
|
+
次に、このコンポーネントをアプリケーション全体で使用します:
|
|
473
|
+
|
|
474
|
+
```vue fileName="layouts/default.vue"
|
|
475
|
+
<script setup lang="ts">
|
|
476
|
+
import Links from "~/components/Links.vue";
|
|
477
|
+
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
478
|
+
</script>
|
|
596
479
|
|
|
597
|
-
```vue fileName="pages/index.vue"
|
|
598
480
|
<template>
|
|
599
481
|
<div>
|
|
600
|
-
<
|
|
601
|
-
|
|
602
|
-
</
|
|
603
|
-
<
|
|
604
|
-
|
|
605
|
-
</
|
|
482
|
+
<header>
|
|
483
|
+
<LocaleSwitcher />
|
|
484
|
+
</header>
|
|
485
|
+
<main>
|
|
486
|
+
<slot />
|
|
487
|
+
</main>
|
|
488
|
+
|
|
489
|
+
<Links href="/">ホーム</Links>
|
|
490
|
+
<Links href="/about">アバウト</Links>
|
|
606
491
|
</div>
|
|
607
492
|
</template>
|
|
608
|
-
|
|
609
|
-
<script setup lang="ts">
|
|
610
|
-
import { useIntlayer } from "vue-intlayer";
|
|
611
|
-
import LocalizedLink from "~/components/LocalizedLink.vue";
|
|
612
|
-
|
|
613
|
-
const content = useIntlayer("home");
|
|
614
|
-
</script>
|
|
615
493
|
```
|
|
616
494
|
|
|
495
|
+
> `NuxtLink` をローカライズされたパスで使用することで、以下を保証できます:
|
|
496
|
+
>
|
|
497
|
+
> - 検索エンジンがすべての言語バージョンのページをクロールおよびインデックスできる
|
|
498
|
+
> - ユーザーがローカライズされたURLを直接共有できる
|
|
499
|
+
> - ブラウザの履歴がロケール接頭辞付きURLで正しく動作する
|
|
500
|
+
|
|
617
501
|
### (オプション)ステップ9:メタデータとSEOの処理
|
|
618
502
|
|
|
619
|
-
Nuxt
|
|
503
|
+
Nuxtは `useHead` コンポーザブル(自動インポート)を通じて優れたSEO機能を提供します。Intlayerを使って、`.raw` または `.value` アクセサを用いてプリミティブな文字列値を取得し、ローカライズされたメタデータを扱うことができます:
|
|
620
504
|
|
|
621
505
|
```vue fileName="pages/about.vue"
|
|
622
506
|
<script setup lang="ts">
|
|
623
|
-
import {
|
|
624
|
-
import { getIntlayer } from "intlayer";
|
|
625
|
-
import { useLocale } from "vue-intlayer";
|
|
507
|
+
import { useIntlayer } from "vue-intlayer";
|
|
626
508
|
|
|
627
|
-
|
|
628
|
-
const content =
|
|
509
|
+
// useHeadはNuxtで自動インポートされます
|
|
510
|
+
const content = useIntlayer("about-page");
|
|
629
511
|
|
|
630
|
-
|
|
631
|
-
title: content.
|
|
632
|
-
|
|
512
|
+
useHead({
|
|
513
|
+
title: content.metaTitle.raw, // プリミティブな文字列アクセスには .raw を使用
|
|
514
|
+
meta: [
|
|
515
|
+
{
|
|
516
|
+
name: "description",
|
|
517
|
+
content: content.metaDescription.raw, // プリミティブな文字列アクセスには .raw を使用
|
|
518
|
+
},
|
|
519
|
+
],
|
|
633
520
|
});
|
|
634
521
|
</script>
|
|
635
522
|
|
|
636
523
|
<template>
|
|
637
|
-
<
|
|
638
|
-
<h1>{{ content.pageTitle }}</h1>
|
|
639
|
-
<p>{{ content.pageContent }}</p>
|
|
640
|
-
</div>
|
|
524
|
+
<h1><content.title /></h1>
|
|
641
525
|
</template>
|
|
642
526
|
```
|
|
643
527
|
|
|
644
|
-
|
|
528
|
+
> あるいは、Vueのリアクティビティなしでコンテンツを取得するために `import { getIntlayer } from "intlayer"` 関数を使用することもできます。
|
|
645
529
|
|
|
646
|
-
|
|
530
|
+
> **コンテンツ値へのアクセス方法:**
|
|
531
|
+
>
|
|
532
|
+
> - プリミティブな文字列値(非リアクティブ)を取得するには `.raw` を使用
|
|
533
|
+
> - リアクティブな値を取得するには `.value` を使用
|
|
534
|
+
> - Visual Editorサポートのために `<content.key />` コンポーネント構文を使用
|
|
535
|
+
|
|
536
|
+
対応するコンテンツ宣言を作成します:
|
|
537
|
+
|
|
538
|
+
```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
|
|
647
539
|
import { t, type Dictionary } from "intlayer";
|
|
648
|
-
import type { useSeoMeta } from "nuxt/app";
|
|
649
540
|
|
|
650
|
-
const
|
|
651
|
-
key: "about-
|
|
541
|
+
const aboutPageContent = {
|
|
542
|
+
key: "about-page",
|
|
652
543
|
content: {
|
|
653
|
-
|
|
654
|
-
ja: "私たちについて - 私の会社",
|
|
544
|
+
metaTitle: t({
|
|
655
545
|
en: "About Us - My Company",
|
|
656
546
|
fr: "À Propos - Ma Société",
|
|
657
547
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
658
548
|
}),
|
|
659
|
-
|
|
660
|
-
ja: "
|
|
549
|
+
metaDescription: t({
|
|
550
|
+
ja: "私たちの会社とミッションについて詳しく知る",
|
|
661
551
|
en: "Learn more about our company and our mission",
|
|
662
552
|
fr: "En savoir plus sur notre société et notre mission",
|
|
663
553
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
664
554
|
}),
|
|
555
|
+
title: t({
|
|
556
|
+
ja: "私たちについて",
|
|
557
|
+
en: "About Us",
|
|
558
|
+
fr: "À Propos",
|
|
559
|
+
es: "Acerca de Nosotros",
|
|
560
|
+
}),
|
|
665
561
|
},
|
|
666
|
-
} satisfies Dictionary
|
|
562
|
+
} satisfies Dictionary;
|
|
667
563
|
|
|
668
|
-
export default
|
|
564
|
+
export default aboutPageContent;
|
|
669
565
|
```
|
|
670
566
|
|
|
671
|
-
```
|
|
567
|
+
```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
|
|
672
568
|
import { t } from "intlayer";
|
|
673
569
|
|
|
674
570
|
/** @type {import('intlayer').Dictionary} */
|
|
675
|
-
const
|
|
676
|
-
key: "about-
|
|
571
|
+
const aboutPageContent = {
|
|
572
|
+
key: "about-page",
|
|
677
573
|
content: {
|
|
678
|
-
|
|
679
|
-
zh: "关于我们 - 我的公司",
|
|
574
|
+
metaTitle: t({
|
|
680
575
|
ja: "私たちについて - 私の会社",
|
|
681
576
|
en: "About Us - My Company",
|
|
682
577
|
fr: "À Propos - Ma Société",
|
|
683
578
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
684
579
|
}),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
ja: "私たちの会社と使命について詳しく知る",
|
|
688
|
-
en: "Learn more about our company and our mission",
|
|
580
|
+
metaDescription: t({
|
|
581
|
+
en: "私たちの会社とミッションについて詳しく知る",
|
|
689
582
|
fr: "En savoir plus sur notre société et notre mission",
|
|
690
583
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
691
584
|
}),
|
|
585
|
+
title: t({
|
|
586
|
+
en: "私たちについて",
|
|
587
|
+
fr: "À Propos",
|
|
588
|
+
es: "Acerca de Nosotros",
|
|
589
|
+
}),
|
|
692
590
|
},
|
|
693
591
|
};
|
|
694
592
|
|
|
695
|
-
export default
|
|
593
|
+
export default aboutPageContent;
|
|
696
594
|
```
|
|
697
595
|
|
|
698
|
-
```
|
|
596
|
+
```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
|
|
699
597
|
const { t } = require("intlayer");
|
|
700
598
|
|
|
701
599
|
/** @type {import('intlayer').Dictionary} */
|
|
702
|
-
const
|
|
703
|
-
key: "about-
|
|
600
|
+
const aboutPageContent = {
|
|
601
|
+
key: "about-page",
|
|
704
602
|
content: {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
ja: "私たちについて - 私の会社",
|
|
708
|
-
en: "About Us - My Company",
|
|
603
|
+
metaTitle: t({
|
|
604
|
+
en: "私たちについて - マイカンパニー",
|
|
709
605
|
fr: "À Propos - Ma Société",
|
|
710
606
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
711
607
|
}),
|
|
712
|
-
|
|
713
|
-
zh: "了解更多关于我们公司和我们的使命",
|
|
608
|
+
metaDescription: t({
|
|
714
609
|
en: "Learn more about our company and our mission",
|
|
715
610
|
fr: "En savoir plus sur notre société et notre mission",
|
|
716
611
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
717
|
-
|
|
612
|
+
}),
|
|
613
|
+
title: t({
|
|
614
|
+
en: "About Us",
|
|
615
|
+
fr: "À Propos",
|
|
616
|
+
es: "Acerca de Nosotros",
|
|
718
617
|
}),
|
|
719
618
|
},
|
|
720
619
|
};
|
|
721
620
|
|
|
722
|
-
module.exports =
|
|
621
|
+
module.exports = aboutPageContent;
|
|
723
622
|
```
|
|
724
623
|
|
|
725
|
-
```json fileName="pages/about-
|
|
624
|
+
```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
|
|
726
625
|
{
|
|
727
|
-
"
|
|
626
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
627
|
+
"key": "about-page",
|
|
728
628
|
"content": {
|
|
729
|
-
"
|
|
629
|
+
"metaTitle": {
|
|
730
630
|
"nodeType": "translation",
|
|
731
|
-
"
|
|
732
|
-
"zh": "关于我们 - 我的公司",
|
|
631
|
+
"translation": {
|
|
733
632
|
"en": "About Us - My Company",
|
|
734
633
|
"fr": "À Propos - Ma Société",
|
|
735
|
-
"es": "Acerca de Nosotros - Mi Empresa"
|
|
736
|
-
"ja": "私たちについて - 私の会社"
|
|
634
|
+
"es": "Acerca de Nosotros - Mi Empresa"
|
|
737
635
|
}
|
|
738
636
|
},
|
|
739
|
-
"
|
|
637
|
+
"metaDescription": {
|
|
740
638
|
"nodeType": "translation",
|
|
741
|
-
"
|
|
742
|
-
"zh": "了解更多关于我们公司和我们的使命",
|
|
639
|
+
"translation": {
|
|
743
640
|
"en": "Learn more about our company and our mission",
|
|
744
641
|
"fr": "En savoir plus sur notre société et notre mission",
|
|
745
|
-
"es": "Conozca más sobre nuestra empresa y nuestra misión"
|
|
642
|
+
"es": "Conozca más sobre nuestra empresa y nuestra misión",
|
|
643
|
+
"ja": "当社と当社のミッションについて詳しく知る"
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
"title": {
|
|
647
|
+
"nodeType": "translation",
|
|
648
|
+
"translation": {
|
|
649
|
+
"en": "About Us",
|
|
650
|
+
"fr": "À Propos",
|
|
651
|
+
"es": "Acerca de Nosotros",
|
|
652
|
+
"ja": "私たちについて"
|
|
746
653
|
}
|
|
747
654
|
}
|
|
748
655
|
}
|
|
@@ -753,7 +660,7 @@ module.exports = aboutMetaContent;
|
|
|
753
660
|
|
|
754
661
|
Intlayerはモジュール拡張を使用してTypeScriptの利点を活かし、コードベースをより強固にします。
|
|
755
662
|
|
|
756
|
-

|
|
757
664
|
|
|
758
665
|

|
|
759
666
|
|
|
@@ -763,42 +670,40 @@ TypeScriptの設定に自動生成された型が含まれていることを確
|
|
|
763
670
|
{
|
|
764
671
|
// ... 既存のTypeScript設定
|
|
765
672
|
"include": [
|
|
766
|
-
// ... 既存の
|
|
673
|
+
// ... 既存のTypeScript設定
|
|
767
674
|
".intlayer/**/*.ts", // 自動生成された型を含める
|
|
768
675
|
],
|
|
769
676
|
}
|
|
770
677
|
```
|
|
771
678
|
|
|
772
|
-
### Git
|
|
679
|
+
### Gitの設定
|
|
773
680
|
|
|
774
|
-
Intlayer
|
|
681
|
+
Intlayerによって生成されたファイルは無視することを推奨します。これにより、Gitリポジトリへの不要なコミットを防ぐことができます。
|
|
775
682
|
|
|
776
|
-
これを行うには、`.gitignore
|
|
683
|
+
これを行うには、`.gitignore`ファイルに以下の指示を追加してください。
|
|
777
684
|
|
|
778
685
|
```plaintext fileName=".gitignore"
|
|
779
|
-
# Intlayer
|
|
686
|
+
# Intlayerによって生成されたファイルを無視する
|
|
780
687
|
.intlayer
|
|
781
688
|
```
|
|
782
689
|
|
|
783
|
-
### VS Code
|
|
690
|
+
### VS Code拡張機能
|
|
784
691
|
|
|
785
|
-
Intlayer
|
|
692
|
+
Intlayerでの開発体験を向上させるために、公式の**Intlayer VS Code拡張機能**をインストールできます。
|
|
786
693
|
|
|
787
|
-
[VS Code
|
|
694
|
+
[VS Codeマーケットプレイスからインストール](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
788
695
|
|
|
789
696
|
この拡張機能は以下を提供します:
|
|
790
697
|
|
|
791
|
-
-
|
|
792
|
-
-
|
|
793
|
-
-
|
|
794
|
-
-
|
|
698
|
+
- 翻訳キーの**オートコンプリート**。
|
|
699
|
+
- 欠落している翻訳の**リアルタイムエラー検出**。
|
|
700
|
+
- 翻訳されたコンテンツの**インラインプレビュー**。
|
|
701
|
+
- 翻訳を簡単に作成・更新できる**クイックアクション**。
|
|
795
702
|
|
|
796
703
|
拡張機能の使い方の詳細については、[Intlayer VS Code拡張機能のドキュメント](https://intlayer.org/doc/vs-code-extension)を参照してください。
|
|
797
704
|
|
|
798
705
|
---
|
|
799
706
|
|
|
800
|
-
###
|
|
801
|
-
|
|
802
|
-
さらに進むには、[ビジュアルエディター](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)を使用してコンテンツを外部化することができます。
|
|
707
|
+
### さらに進む
|
|
803
708
|
|
|
804
|
-
|
|
709
|
+
さらに進めるには、[ビジュアルエディター](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)を使用してコンテンツを外部化することができます。
|