@intlayer/docs 7.0.3 → 7.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blog/ar/intlayer_with_i18next.md +68 -106
- package/blog/ar/intlayer_with_next-i18next.md +84 -288
- package/blog/ar/intlayer_with_next-intl.md +58 -337
- package/blog/ar/intlayer_with_react-i18next.md +68 -290
- package/blog/ar/intlayer_with_react-intl.md +63 -266
- package/blog/de/intlayer_with_i18next.md +77 -97
- package/blog/de/intlayer_with_next-i18next.md +69 -296
- package/blog/de/intlayer_with_next-intl.md +59 -340
- package/blog/de/intlayer_with_react-i18next.md +68 -290
- package/blog/de/intlayer_with_react-intl.md +62 -264
- package/blog/en/intlayer_with_i18next.md +67 -103
- package/blog/en/intlayer_with_next-i18next.md +69 -294
- package/blog/en/intlayer_with_next-intl.md +48 -300
- package/blog/en/intlayer_with_react-i18next.md +61 -289
- package/blog/en/intlayer_with_react-intl.md +61 -284
- package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +1 -1
- package/blog/en-GB/intlayer_with_i18next.md +67 -103
- package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
- package/blog/en-GB/intlayer_with_next-intl.md +58 -337
- package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
- package/blog/en-GB/intlayer_with_react-intl.md +61 -264
- package/blog/es/intlayer_with_i18next.md +67 -103
- package/blog/es/intlayer_with_next-i18next.md +71 -296
- package/blog/es/intlayer_with_next-intl.md +57 -338
- package/blog/es/intlayer_with_react-i18next.md +68 -290
- package/blog/es/intlayer_with_react-intl.md +62 -265
- package/blog/fr/intlayer_with_i18next.md +66 -104
- package/blog/fr/intlayer_with_next-i18next.md +82 -285
- package/blog/fr/intlayer_with_next-intl.md +57 -338
- package/blog/fr/intlayer_with_react-i18next.md +67 -289
- package/blog/fr/intlayer_with_react-intl.md +61 -264
- package/blog/hi/intlayer_with_i18next.md +68 -104
- package/blog/hi/intlayer_with_next-i18next.md +74 -299
- package/blog/hi/intlayer_with_next-intl.md +57 -239
- package/blog/hi/intlayer_with_react-i18next.md +69 -291
- package/blog/hi/intlayer_with_react-intl.md +65 -268
- package/blog/id/intlayer_with_i18next.md +126 -0
- package/blog/id/intlayer_with_next-i18next.md +142 -0
- package/blog/id/intlayer_with_next-intl.md +113 -0
- package/blog/id/intlayer_with_react-i18next.md +124 -0
- package/blog/id/intlayer_with_react-intl.md +122 -0
- package/blog/it/intlayer_with_i18next.md +67 -103
- package/blog/it/intlayer_with_next-i18next.md +71 -296
- package/blog/it/intlayer_with_next-intl.md +57 -338
- package/blog/it/intlayer_with_react-i18next.md +68 -290
- package/blog/it/intlayer_with_react-intl.md +62 -265
- package/blog/ja/intlayer_with_i18next.md +68 -103
- package/blog/ja/intlayer_with_next-i18next.md +85 -283
- package/blog/ja/intlayer_with_next-intl.md +58 -336
- package/blog/ja/intlayer_with_react-i18next.md +68 -290
- package/blog/ja/intlayer_with_react-intl.md +62 -264
- package/blog/ko/intlayer_with_i18next.md +80 -96
- package/blog/ko/intlayer_with_next-i18next.md +85 -287
- package/blog/ko/intlayer_with_next-intl.md +68 -327
- package/blog/ko/intlayer_with_react-i18next.md +68 -290
- package/blog/ko/intlayer_with_react-intl.md +64 -266
- package/blog/pl/intlayer_with_i18next.md +126 -0
- package/blog/pl/intlayer_with_next-i18next.md +142 -0
- package/blog/pl/intlayer_with_next-intl.md +111 -0
- package/blog/pl/intlayer_with_react-i18next.md +124 -0
- package/blog/pl/intlayer_with_react-intl.md +122 -0
- package/blog/pt/intlayer_with_i18next.md +67 -103
- package/blog/pt/intlayer_with_next-i18next.md +72 -293
- package/blog/pt/intlayer_with_next-intl.md +57 -256
- package/blog/pt/intlayer_with_react-i18next.md +104 -78
- package/blog/pt/intlayer_with_react-intl.md +62 -266
- package/blog/ru/intlayer_with_i18next.md +66 -104
- package/blog/ru/intlayer_with_next-i18next.md +71 -296
- package/blog/ru/intlayer_with_next-intl.md +58 -337
- package/blog/ru/intlayer_with_react-i18next.md +68 -290
- package/blog/ru/intlayer_with_react-intl.md +62 -265
- package/blog/tr/intlayer_with_i18next.md +71 -107
- package/blog/tr/intlayer_with_next-i18next.md +72 -297
- package/blog/tr/intlayer_with_next-intl.md +58 -339
- package/blog/tr/intlayer_with_react-i18next.md +69 -291
- package/blog/tr/intlayer_with_react-intl.md +63 -285
- package/blog/vi/intlayer_with_i18next.md +126 -0
- package/blog/vi/intlayer_with_next-i18next.md +142 -0
- package/blog/vi/intlayer_with_next-intl.md +111 -0
- package/blog/vi/intlayer_with_react-i18next.md +124 -0
- package/blog/vi/intlayer_with_react-intl.md +122 -0
- package/blog/zh/intlayer_with_i18next.md +67 -102
- package/blog/zh/intlayer_with_next-i18next.md +72 -296
- package/blog/zh/intlayer_with_next-intl.md +58 -336
- package/blog/zh/intlayer_with_react-i18next.md +68 -290
- package/blog/zh/intlayer_with_react-intl.md +63 -106
- package/dist/cjs/generated/blog.entry.cjs +13 -1
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +13 -1
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +13 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +13 -1
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +13 -2
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +13 -2
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/esm/generated/frequentQuestions.entry.mjs +13 -2
- package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
- package/dist/esm/generated/legal.entry.mjs +13 -2
- package/dist/esm/generated/legal.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
- package/dist/types/generated/legal.entry.d.ts.map +1 -1
- package/docs/ar/plugins/sync-json.md +244 -0
- package/docs/de/plugins/sync-json.md +244 -0
- package/docs/de/releases/v7.md +1 -18
- package/docs/en/CI_CD.md +1 -1
- package/docs/en/configuration.md +1 -1
- package/docs/en/formatters.md +1 -1
- package/docs/en/how_works_intlayer.md +1 -1
- package/docs/en/intlayer_CMS.md +1 -1
- package/docs/en/intlayer_cli.md +26 -1
- package/docs/en/intlayer_with_nextjs_14.md +3 -1
- package/docs/en/intlayer_with_nextjs_15.md +3 -1
- package/docs/en/intlayer_with_nextjs_16.md +3 -1
- package/docs/en/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/en/intlayer_with_nuxt.md +1 -1
- package/docs/en/intlayer_with_react_native+expo.md +1 -1
- package/docs/en/intlayer_with_react_router_v7.md +1 -1
- package/docs/en/intlayer_with_tanstack.md +1 -1
- package/docs/en/intlayer_with_vite+preact.md +1 -1
- package/docs/en/intlayer_with_vite+react.md +1 -1
- package/docs/en/intlayer_with_vite+solid.md +1 -1
- package/docs/en/intlayer_with_vite+svelte.md +1 -1
- package/docs/en/intlayer_with_vite+vue.md +1 -1
- package/docs/en/plugins/sync-json.md +1 -1
- package/docs/en/roadmap.md +1 -1
- package/docs/en-GB/plugins/sync-json.md +244 -0
- package/docs/es/plugins/sync-json.md +244 -0
- package/docs/es/releases/v7.md +1 -18
- package/docs/fr/intlayer_with_nextjs_16.md +2 -51
- package/docs/fr/plugins/sync-json.md +244 -0
- package/docs/fr/releases/v7.md +1 -18
- package/docs/hi/intlayer_with_nextjs_16.md +3 -2
- package/docs/hi/plugins/sync-json.md +244 -0
- package/docs/id/plugins/sync-json.md +244 -0
- package/docs/id/releases/v7.md +1 -18
- package/docs/it/plugins/sync-json.md +244 -0
- package/docs/it/releases/v7.md +1 -18
- package/docs/ja/intlayer_with_nextjs_16.md +44 -205
- package/docs/ja/plugins/sync-json.md +244 -0
- package/docs/ja/releases/v7.md +1 -18
- package/docs/ko/plugins/sync-json.md +244 -0
- package/docs/ko/releases/v7.md +1 -18
- package/docs/pl/plugins/sync-json.md +244 -0
- package/docs/pt/intlayer_with_nextjs_16.md +1 -52
- package/docs/pt/plugins/sync-json.md +244 -0
- package/docs/ru/plugins/sync-json.md +244 -0
- package/docs/tr/plugins/sync-json.md +245 -0
- package/docs/vi/plugins/sync-json.md +244 -0
- package/docs/zh/plugins/sync-json.md +244 -0
- package/package.json +14 -14
- package/src/generated/blog.entry.ts +26 -3
- package/src/generated/docs.entry.ts +26 -3
- package/src/generated/frequentQuestions.entry.ts +26 -3
- package/src/generated/legal.entry.ts +26 -3
|
@@ -1,363 +1,165 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-08-23
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title: Intlayerとnext-i18next
|
|
5
|
-
description: Next.js
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
|
+
title: Intlayer と next-i18next
|
|
5
|
+
description: 包括的な Next.js 国際化ソリューションのために Intlayer を next-i18next と統合する
|
|
6
6
|
keywords:
|
|
7
7
|
- i18next
|
|
8
8
|
- next-i18next
|
|
9
9
|
- Intlayer
|
|
10
10
|
- 国際化
|
|
11
|
-
-
|
|
11
|
+
- ブログ
|
|
12
12
|
- Next.js
|
|
13
13
|
- JavaScript
|
|
14
14
|
- React
|
|
15
15
|
slugs:
|
|
16
16
|
- blog
|
|
17
17
|
- intlayer-with-next-i18next
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.0.0
|
|
20
|
+
date: 2025-10-29
|
|
21
|
+
changes: syncJSON プラグインへの変更と包括的な書き直し
|
|
18
22
|
---
|
|
19
23
|
|
|
20
|
-
# Next.js
|
|
24
|
+
# next-i18next と Intlayer を使った Next.js の国際化 (i18n)
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
## 目次
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
<TOC/>
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
- `i18next`の場合は`resource`として名付けられ、コンテンツ宣言は、1つまたは複数の言語の翻訳のためのキー-バリューのペアを含む構造化されたJSONオブジェクトです。詳細については、[i18nextのドキュメント](https://www.i18next.com/translation-function/essentials)を参照してください。
|
|
28
|
-
- `Intlayer`の場合は`content declaration file`として名付けられ、コンテンツ宣言は構造化データをエクスポートするJSON、JS、またはTSファイルになることができます。詳細については、[Intlayerのドキュメント](https://intlayer.org/fr/doc/concept/content)を参照してください。
|
|
30
|
+
## next-i18next とは?
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
**next-i18next** は、Next.js アプリケーション向けの最も人気のある国際化(i18n)フレームワークの一つです。強力な **i18next** エコシステムの上に構築されており、Next.js プロジェクトにおける翻訳、ローカリゼーション、言語切り替えの管理に包括的なソリューションを提供します。
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
しかし、next-i18next にはいくつかの課題があります:
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
- **複雑な設定**:next-i18next のセットアップには複数の設定ファイルが必要であり、サーバーサイドとクライアントサイドの i18n インスタンスの慎重な設定が求められます。
|
|
37
|
+
- **翻訳ファイルの分散**:翻訳ファイルは通常、コンポーネントとは別のディレクトリに保存されているため、一貫性の維持が難しくなります。
|
|
38
|
+
- **名前空間の手動管理**:開発者は名前空間を手動で管理し、翻訳リソースが適切に読み込まれることを保証する必要があります。
|
|
39
|
+
- **限定的な型安全性**:TypeScript のサポートには追加の設定が必要であり、翻訳の自動型生成は提供されません。
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
## Intlayerとは?
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
**Intlayer** は、従来のi18nソリューションの欠点を解決するために設計された革新的なオープンソースの国際化ライブラリです。Next.jsアプリケーションにおけるコンテンツ管理に対してモダンなアプローチを提供します。
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
[next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md) のブログ記事で next-intl との具体的な比較をご覧ください。
|
|
41
46
|
|
|
42
|
-
Intlayer
|
|
47
|
+
## なぜ Intlayer を next-i18next と組み合わせるのか?
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
Intlayerは優れた単独のi18nソリューションを提供します([Next.js統合ガイド](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_with_nextjs_16.md)を参照)が、次のような理由でnext-i18nextと組み合わせたい場合があります。
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
1. **既存のコードベース**: 既にnext-i18nextの実装があり、Intlayerの改善された開発者体験へ段階的に移行したい場合。
|
|
52
|
+
2. **レガシー要件**: プロジェクトが既存のi18nextプラグインやワークフローとの互換性を必要とする場合。
|
|
53
|
+
3. **チームの慣れ親しみ**: チームがnext-i18nextに慣れているが、より良いコンテンツ管理を望んでいる場合。
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
.
|
|
50
|
-
└── src
|
|
51
|
-
└── components
|
|
52
|
-
└── MyComponent
|
|
53
|
-
├── index.content.ts # コンテンツ宣言ファイル
|
|
54
|
-
└── index.tsx
|
|
55
|
-
```
|
|
55
|
+
**そのために、Intlayerはnext-i18nextのアダプターとして実装でき、CLIやCI/CDパイプラインでのJSON翻訳の自動化、翻訳のテストなどを支援します。**
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
.
|
|
59
|
-
└── src
|
|
60
|
-
└── components
|
|
61
|
-
└── MyComponent
|
|
62
|
-
├── index.content.mjs # コンテンツ宣言ファイル
|
|
63
|
-
└── index.mjx
|
|
64
|
-
```
|
|
57
|
+
このガイドでは、next-i18nextとの互換性を維持しながら、Intlayerの優れたコンテンツ宣言システムを活用する方法を示します。
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
.
|
|
68
|
-
└── src
|
|
69
|
-
└── components
|
|
70
|
-
└── MyComponent
|
|
71
|
-
├── index.content.cjs # コンテンツ宣言ファイル
|
|
72
|
-
└── index.cjx
|
|
73
|
-
```
|
|
59
|
+
---
|
|
74
60
|
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
└── src
|
|
78
|
-
└── components
|
|
79
|
-
└── MyComponent
|
|
80
|
-
├── index.content.json # コンテンツ宣言ファイル
|
|
81
|
-
└── index.jsx
|
|
82
|
-
```
|
|
61
|
+
## next-i18nextとIntlayerをセットアップするステップバイステップガイド
|
|
83
62
|
|
|
84
|
-
|
|
63
|
+
### ステップ1: 依存関係のインストール
|
|
85
64
|
|
|
86
|
-
|
|
65
|
+
お好みのパッケージマネージャーを使って必要なパッケージをインストールしてください:
|
|
87
66
|
|
|
88
67
|
```bash packageManager="npm"
|
|
89
|
-
npm install intlayer
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
```bash packageManager="yarn"
|
|
93
|
-
yarn add intlayer i18next next-i18next i18next-resources-to-backend
|
|
68
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
94
69
|
```
|
|
95
70
|
|
|
96
71
|
```bash packageManager="pnpm"
|
|
97
|
-
pnpm add intlayer
|
|
72
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
98
73
|
```
|
|
99
74
|
|
|
100
|
-
|
|
75
|
+
```bash packageManager="yarn"
|
|
76
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
77
|
+
```
|
|
101
78
|
|
|
102
|
-
|
|
79
|
+
**パッケージの説明:**
|
|
103
80
|
|
|
104
|
-
|
|
81
|
+
- **intlayer**: コンテンツ宣言と管理のためのコアライブラリ
|
|
82
|
+
- **next-intlayer**: ビルドプラグインを備えたNext.js統合レイヤー
|
|
83
|
+
- **i18next**: コアi18nフレームワーク
|
|
84
|
+
- **next-i18next**: i18nextのNext.jsラッパー
|
|
85
|
+
- **i18next-resources-to-backend**: i18nextのための動的リソース読み込み
|
|
86
|
+
- **@intlayer/sync-json-plugin**: Intlayerのコンテンツ宣言をi18nextのJSON形式に同期するプラグイン
|
|
105
87
|
|
|
106
|
-
|
|
107
|
-
import { Locales, type IntlayerConfig } from "intlayer";
|
|
88
|
+
### ステップ2: JSONをラップするためのIntlayerプラグインの実装
|
|
108
89
|
|
|
109
|
-
|
|
110
|
-
internationalization: {
|
|
111
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
112
|
-
defaultLocale: Locales.ENGLISH,
|
|
113
|
-
},
|
|
114
|
-
content: {
|
|
115
|
-
dictionaryOutput: ["i18next"],
|
|
116
|
-
i18nextResourcesDir: "./i18next/resources",
|
|
117
|
-
},
|
|
118
|
-
};
|
|
90
|
+
サポートするロケールを定義するためにIntlayerの設定ファイルを作成します。
|
|
119
91
|
|
|
120
|
-
|
|
121
|
-
```
|
|
92
|
+
**i18next用のJSON辞書もエクスポートしたい場合は、`syncJSON`プラグインを追加してください:**
|
|
122
93
|
|
|
123
|
-
```
|
|
124
|
-
import { Locales } from "intlayer";
|
|
94
|
+
```typescript fileName="intlayer.config.ts"
|
|
95
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
96
|
+
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
125
97
|
|
|
126
|
-
|
|
127
|
-
const config = {
|
|
98
|
+
const config: IntlayerConfig = {
|
|
128
99
|
internationalization: {
|
|
129
100
|
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
130
101
|
defaultLocale: Locales.ENGLISH,
|
|
131
102
|
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
103
|
+
plugins: [
|
|
104
|
+
syncJSON({
|
|
105
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
106
|
+
}),
|
|
107
|
+
],
|
|
136
108
|
};
|
|
137
109
|
|
|
138
110
|
export default config;
|
|
139
111
|
```
|
|
140
112
|
|
|
141
|
-
|
|
142
|
-
const { Locales } = require("intlayer");
|
|
113
|
+
`syncJSON`プラグインはJSONを自動的にラップします。コンテンツの構造を変更することなく、JSONファイルの読み書きを行います。
|
|
143
114
|
|
|
144
|
-
|
|
145
|
-
const config = {
|
|
146
|
-
internationalization: {
|
|
147
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
148
|
-
defaultLocale: Locales.ENGLISH,
|
|
149
|
-
},
|
|
150
|
-
content: {
|
|
151
|
-
dictionaryOutput: ["i18next"],
|
|
152
|
-
i18nextResourcesDir: "./i18next/resources",
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
module.exports = config;
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### i18next構成への辞書のインポート
|
|
160
|
-
|
|
161
|
-
生成されたリソースをi18next構成にインポートするには、`i18next-resources-to-backend`を使用します。以下は例です:
|
|
162
|
-
|
|
163
|
-
```typescript fileName="i18n/client.ts" codeFormat="typescript"
|
|
164
|
-
import i18next from "i18next";
|
|
165
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
166
|
-
|
|
167
|
-
i18next.use(
|
|
168
|
-
resourcesToBackend(
|
|
169
|
-
(language: string, namespace: string) =>
|
|
170
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
171
|
-
)
|
|
172
|
-
);
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
```javascript fileName="i18n/client.mjs" codeFormat="esm"
|
|
176
|
-
import i18next from "i18next";
|
|
177
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
178
|
-
|
|
179
|
-
i18next.use(
|
|
180
|
-
resourcesToBackend(
|
|
181
|
-
(language, namespace) =>
|
|
182
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
183
|
-
)
|
|
184
|
-
);
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
```javascript fileName="i18n/client.cjs" codeFormat="commonjs"
|
|
188
|
-
const i18next = require("i18next");
|
|
189
|
-
const resourcesToBackend = require("i18next-resources-to-backend");
|
|
190
|
-
|
|
191
|
-
i18next.use(
|
|
192
|
-
resourcesToBackend(
|
|
193
|
-
(language, namespace) =>
|
|
194
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
195
|
-
)
|
|
196
|
-
);
|
|
197
|
-
```
|
|
115
|
+
JSONとintlayerのコンテンツ宣言ファイル(`.content`ファイル)を共存させたい場合、Intlayerは以下の手順で処理します:
|
|
198
116
|
|
|
199
|
-
|
|
117
|
+
1. JSONファイルとコンテンツ宣言ファイルの両方を読み込み、intlayerの辞書に変換します。
|
|
200
118
|
|
|
201
|
-
|
|
119
|
+
2. JSONとコンテンツ宣言ファイル間に競合がある場合、Intlayerはすべての辞書をマージします。これはプラグインの優先順位やコンテンツ宣言ファイルの優先順位に依存します(すべて設定可能です)。
|
|
202
120
|
|
|
203
|
-
|
|
204
|
-
import { t, type Dictionary } from "intlayer";
|
|
121
|
+
CLIを使用してJSONの翻訳を行った場合やCMSを使用した場合、Intlayerは新しい翻訳でJSONファイルを更新します。
|
|
205
122
|
|
|
206
|
-
|
|
207
|
-
key: "my-content",
|
|
208
|
-
content: {
|
|
209
|
-
myTranslatedContent: t({
|
|
210
|
-
en: "Hello World",
|
|
211
|
-
es: "Hola Mundo",
|
|
212
|
-
fr: "Bonjour le monde",
|
|
213
|
-
}),
|
|
214
|
-
},
|
|
215
|
-
} satisfies Dictionary;
|
|
216
|
-
|
|
217
|
-
export default content;
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
221
|
-
import { t } from "intlayer";
|
|
222
|
-
|
|
223
|
-
/** @type {import('intlayer').Dictionary} */
|
|
224
|
-
const content = {
|
|
225
|
-
key: "my-content",
|
|
226
|
-
content: {
|
|
227
|
-
myTranslatedContent: t({
|
|
228
|
-
en: "Hello World",
|
|
229
|
-
es: "Hola Mundo",
|
|
230
|
-
fr: "Bonjour le monde",
|
|
231
|
-
}),
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
237
|
-
const { t } = require("intlayer");
|
|
238
|
-
|
|
239
|
-
module.exports = {
|
|
240
|
-
key: "my-content",
|
|
241
|
-
content: {
|
|
242
|
-
myTranslatedContent: t({
|
|
243
|
-
en: "Hello World",
|
|
244
|
-
es: "Hola Mundo",
|
|
245
|
-
fr: "Bonjour le monde",
|
|
246
|
-
}),
|
|
247
|
-
},
|
|
248
|
-
};
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
```json fileName="**/*.content.json" contentDeclarationFormat="json"
|
|
252
|
-
{
|
|
253
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
254
|
-
"key": "my-content",
|
|
255
|
-
"content": {
|
|
256
|
-
"myTranslatedContent": {
|
|
257
|
-
"nodeType": "translation",
|
|
258
|
-
"translation": {
|
|
259
|
-
"en": "Hello World",
|
|
260
|
-
"fr": "Bonjour le monde",
|
|
261
|
-
"es": "Hola Mundo"
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
### next-i18nextリソースをビルドする
|
|
269
|
-
|
|
270
|
-
next-i18nextリソースをビルドするには、以下のコマンドを実行します:
|
|
271
|
-
|
|
272
|
-
```bash packageManager="npm"
|
|
273
|
-
npx run intlayer build
|
|
274
|
-
```
|
|
123
|
+
---
|
|
275
124
|
|
|
276
|
-
|
|
277
|
-
yarn intlayer build
|
|
278
|
-
```
|
|
125
|
+
## Git設定
|
|
279
126
|
|
|
280
|
-
|
|
281
|
-
pnpm intlayer build
|
|
282
|
-
```
|
|
127
|
+
生成されたファイルをバージョン管理から除外します:
|
|
283
128
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
└── i18next
|
|
289
|
-
└── resources
|
|
290
|
-
└── ja
|
|
291
|
-
└── my-content.json
|
|
292
|
-
└── fr
|
|
293
|
-
└── my-content.json
|
|
294
|
-
└── es
|
|
295
|
-
└── my-content.json
|
|
129
|
+
```plaintext fileName=".gitignore"
|
|
130
|
+
# Intlayerによって生成されたファイルを無視する
|
|
131
|
+
.intlayer
|
|
132
|
+
intl
|
|
296
133
|
```
|
|
297
134
|
|
|
298
|
-
|
|
135
|
+
これらのファイルはビルドプロセス中に自動的に再生成されるため、リポジトリにコミットする必要はありません。
|
|
299
136
|
|
|
300
|
-
###
|
|
137
|
+
### VS Code拡張機能
|
|
301
138
|
|
|
302
|
-
|
|
139
|
+
開発者体験を向上させるために、公式の**Intlayer VS Code拡張機能**をインストールしてください:
|
|
303
140
|
|
|
304
|
-
|
|
305
|
-
import { withIntlayer } from "next-intlayer/server";
|
|
141
|
+
[VS Codeマーケットプレイスからインストール](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
306
142
|
|
|
307
|
-
|
|
308
|
-
const nextConfig = {};
|
|
309
|
-
|
|
310
|
-
export default withIntlayer(nextConfig);
|
|
311
|
-
```
|
|
143
|
+
2. JSONとコンテンツ宣言ファイル間に競合がある場合、Intlayerはすべての辞書をマージします。プラグインの優先度とコンテンツ宣言ファイルの優先度に応じて処理されます(すべて設定可能です)。
|
|
312
144
|
|
|
313
|
-
|
|
145
|
+
CLIを使用してJSONの翻訳を変更した場合やCMSを使用した場合、Intlayerは新しい翻訳でJSONファイルを更新します。
|
|
314
146
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
```typescript fileName="src/components/myComponent/index.tsx" codeFormat="typescript"
|
|
318
|
-
import type { FC } from "react";
|
|
319
|
-
import { useTranslation } from "react-i18next";
|
|
147
|
+
---
|
|
320
148
|
|
|
321
|
-
|
|
322
|
-
const { t } = useTranslation();
|
|
149
|
+
## Git設定
|
|
323
150
|
|
|
324
|
-
|
|
325
|
-
<div>
|
|
326
|
-
<h1>{t("my-content.title")}</h1>
|
|
327
|
-
<p>{t("my-content.description")}</p>
|
|
328
|
-
</div>
|
|
329
|
-
);
|
|
330
|
-
};
|
|
151
|
+
生成されたファイルをバージョン管理から除外します:
|
|
331
152
|
|
|
332
|
-
|
|
153
|
+
```plaintext fileName=".gitignore"
|
|
154
|
+
# Intlayerによって生成されたファイルを無視
|
|
155
|
+
.intlayer
|
|
156
|
+
intl
|
|
333
157
|
```
|
|
334
158
|
|
|
335
|
-
|
|
336
|
-
import { useTranslation } from "react-i18next";
|
|
159
|
+
これらのファイルはビルドプロセス中に自動的に再生成されるため、リポジトリにコミットする必要はありません。
|
|
337
160
|
|
|
338
|
-
|
|
339
|
-
const { t } = useTranslation();
|
|
161
|
+
### VS Code拡張機能
|
|
340
162
|
|
|
341
|
-
|
|
342
|
-
<div>
|
|
343
|
-
<h1>{t("my-content.title")}</h1>
|
|
344
|
-
<p>{t("my-content.description")}</p>
|
|
345
|
-
</div>
|
|
346
|
-
);
|
|
347
|
-
};
|
|
348
|
-
```
|
|
163
|
+
開発者体験を向上させるために、公式の**Intlayer VS Code拡張機能**をインストールしてください:
|
|
349
164
|
|
|
350
|
-
|
|
351
|
-
const { useTranslation } = require("react-i18next");
|
|
352
|
-
|
|
353
|
-
const IndexPage = () => {
|
|
354
|
-
const { t } = useTranslation();
|
|
355
|
-
|
|
356
|
-
return (
|
|
357
|
-
<div>
|
|
358
|
-
<h1>{t("my-content.title")}</h1>
|
|
359
|
-
<p>{t("my-content.description")}</p>
|
|
360
|
-
</div>
|
|
361
|
-
);
|
|
362
|
-
};
|
|
363
|
-
```
|
|
165
|
+
[VS Codeマーケットプレイスからインストール](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|