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

|
|
759
|
-
|
|
760
|
-
TypeScriptの設定に自動生成された型が含まれていることを確認してください。
|
|
761
|
-
|
|
762
|
-
```json5 fileName="tsconfig.json"
|
|
763
|
-
{
|
|
764
|
-
// ... 既存のTypeScript設定
|
|
765
|
-
"include": [
|
|
766
|
-
// ... 既存の TypeScript 設定
|
|
767
|
-
".intlayer/**/*.ts", // 自動生成された型を含める
|
|
768
|
-
],
|
|
769
|
-
}
|
|
770
|
-
```
|
|
771
|
-
|
|
772
|
-
### Git 設定
|
|
773
|
-
|
|
774
|
-
Intlayer によって生成されたファイルは無視することを推奨します。これにより、Git リポジトリに誤ってコミットするのを防げます。
|
|
775
|
-
|
|
776
|
-
これを行うには、`.gitignore` ファイルに以下の指示を追加してください。
|
|
655
|
+
これを行うには、`.gitignore`ファイルに以下の指示を追加してください。
|
|
777
656
|
|
|
778
657
|
```plaintext fileName=".gitignore"
|
|
779
|
-
# Intlayer
|
|
658
|
+
# Intlayerによって生成されたファイルを無視する
|
|
780
659
|
.intlayer
|
|
781
660
|
```
|
|
782
661
|
|
|
783
|
-
### VS Code
|
|
662
|
+
### VS Code拡張機能
|
|
784
663
|
|
|
785
|
-
Intlayer
|
|
664
|
+
Intlayerでの開発体験を向上させるために、公式の**Intlayer VS Code拡張機能**をインストールできます。
|
|
786
665
|
|
|
787
|
-
[VS Code
|
|
666
|
+
[VS Codeマーケットプレイスからインストール](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
788
667
|
|
|
789
668
|
この拡張機能は以下を提供します:
|
|
790
669
|
|
|
791
|
-
-
|
|
792
|
-
-
|
|
793
|
-
-
|
|
794
|
-
-
|
|
670
|
+
- 翻訳キーの**オートコンプリート**。
|
|
671
|
+
- 欠落している翻訳の**リアルタイムエラー検出**。
|
|
672
|
+
- 翻訳されたコンテンツの**インラインプレビュー**。
|
|
673
|
+
- 翻訳を簡単に作成・更新できる**クイックアクション**。
|
|
795
674
|
|
|
796
675
|
拡張機能の使い方の詳細については、[Intlayer VS Code拡張機能のドキュメント](https://intlayer.org/doc/vs-code-extension)を参照してください。
|
|
797
676
|
|
|
798
677
|
---
|
|
799
678
|
|
|
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)を使用してコンテンツを外部化することができます。
|
|
679
|
+
### さらに進む
|
|
803
680
|
|
|
804
|
-
|
|
681
|
+
さらに進めるには、[ビジュアルエディター](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)を使用してコンテンツを外部化することができます。
|