@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.
Files changed (159) hide show
  1. package/blog/ar/intlayer_with_i18next.md +68 -106
  2. package/blog/ar/intlayer_with_next-i18next.md +84 -288
  3. package/blog/ar/intlayer_with_next-intl.md +58 -337
  4. package/blog/ar/intlayer_with_react-i18next.md +68 -290
  5. package/blog/ar/intlayer_with_react-intl.md +63 -266
  6. package/blog/de/intlayer_with_i18next.md +77 -97
  7. package/blog/de/intlayer_with_next-i18next.md +69 -296
  8. package/blog/de/intlayer_with_next-intl.md +59 -340
  9. package/blog/de/intlayer_with_react-i18next.md +68 -290
  10. package/blog/de/intlayer_with_react-intl.md +62 -264
  11. package/blog/en/intlayer_with_i18next.md +67 -103
  12. package/blog/en/intlayer_with_next-i18next.md +69 -294
  13. package/blog/en/intlayer_with_next-intl.md +48 -300
  14. package/blog/en/intlayer_with_react-i18next.md +61 -289
  15. package/blog/en/intlayer_with_react-intl.md +61 -284
  16. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +1 -1
  17. package/blog/en-GB/intlayer_with_i18next.md +67 -103
  18. package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
  19. package/blog/en-GB/intlayer_with_next-intl.md +58 -337
  20. package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
  21. package/blog/en-GB/intlayer_with_react-intl.md +61 -264
  22. package/blog/es/intlayer_with_i18next.md +67 -103
  23. package/blog/es/intlayer_with_next-i18next.md +71 -296
  24. package/blog/es/intlayer_with_next-intl.md +57 -338
  25. package/blog/es/intlayer_with_react-i18next.md +68 -290
  26. package/blog/es/intlayer_with_react-intl.md +62 -265
  27. package/blog/fr/intlayer_with_i18next.md +66 -104
  28. package/blog/fr/intlayer_with_next-i18next.md +82 -285
  29. package/blog/fr/intlayer_with_next-intl.md +57 -338
  30. package/blog/fr/intlayer_with_react-i18next.md +67 -289
  31. package/blog/fr/intlayer_with_react-intl.md +61 -264
  32. package/blog/hi/intlayer_with_i18next.md +68 -104
  33. package/blog/hi/intlayer_with_next-i18next.md +74 -299
  34. package/blog/hi/intlayer_with_next-intl.md +57 -239
  35. package/blog/hi/intlayer_with_react-i18next.md +69 -291
  36. package/blog/hi/intlayer_with_react-intl.md +65 -268
  37. package/blog/id/intlayer_with_i18next.md +126 -0
  38. package/blog/id/intlayer_with_next-i18next.md +142 -0
  39. package/blog/id/intlayer_with_next-intl.md +113 -0
  40. package/blog/id/intlayer_with_react-i18next.md +124 -0
  41. package/blog/id/intlayer_with_react-intl.md +122 -0
  42. package/blog/it/intlayer_with_i18next.md +67 -103
  43. package/blog/it/intlayer_with_next-i18next.md +71 -296
  44. package/blog/it/intlayer_with_next-intl.md +57 -338
  45. package/blog/it/intlayer_with_react-i18next.md +68 -290
  46. package/blog/it/intlayer_with_react-intl.md +62 -265
  47. package/blog/ja/intlayer_with_i18next.md +68 -103
  48. package/blog/ja/intlayer_with_next-i18next.md +85 -283
  49. package/blog/ja/intlayer_with_next-intl.md +58 -336
  50. package/blog/ja/intlayer_with_react-i18next.md +68 -290
  51. package/blog/ja/intlayer_with_react-intl.md +62 -264
  52. package/blog/ko/intlayer_with_i18next.md +80 -96
  53. package/blog/ko/intlayer_with_next-i18next.md +85 -287
  54. package/blog/ko/intlayer_with_next-intl.md +68 -327
  55. package/blog/ko/intlayer_with_react-i18next.md +68 -290
  56. package/blog/ko/intlayer_with_react-intl.md +64 -266
  57. package/blog/pl/intlayer_with_i18next.md +126 -0
  58. package/blog/pl/intlayer_with_next-i18next.md +142 -0
  59. package/blog/pl/intlayer_with_next-intl.md +111 -0
  60. package/blog/pl/intlayer_with_react-i18next.md +124 -0
  61. package/blog/pl/intlayer_with_react-intl.md +122 -0
  62. package/blog/pt/intlayer_with_i18next.md +67 -103
  63. package/blog/pt/intlayer_with_next-i18next.md +72 -293
  64. package/blog/pt/intlayer_with_next-intl.md +57 -256
  65. package/blog/pt/intlayer_with_react-i18next.md +104 -78
  66. package/blog/pt/intlayer_with_react-intl.md +62 -266
  67. package/blog/ru/intlayer_with_i18next.md +66 -104
  68. package/blog/ru/intlayer_with_next-i18next.md +71 -296
  69. package/blog/ru/intlayer_with_next-intl.md +58 -337
  70. package/blog/ru/intlayer_with_react-i18next.md +68 -290
  71. package/blog/ru/intlayer_with_react-intl.md +62 -265
  72. package/blog/tr/intlayer_with_i18next.md +71 -107
  73. package/blog/tr/intlayer_with_next-i18next.md +72 -297
  74. package/blog/tr/intlayer_with_next-intl.md +58 -339
  75. package/blog/tr/intlayer_with_react-i18next.md +69 -291
  76. package/blog/tr/intlayer_with_react-intl.md +63 -285
  77. package/blog/vi/intlayer_with_i18next.md +126 -0
  78. package/blog/vi/intlayer_with_next-i18next.md +142 -0
  79. package/blog/vi/intlayer_with_next-intl.md +111 -0
  80. package/blog/vi/intlayer_with_react-i18next.md +124 -0
  81. package/blog/vi/intlayer_with_react-intl.md +122 -0
  82. package/blog/zh/intlayer_with_i18next.md +67 -102
  83. package/blog/zh/intlayer_with_next-i18next.md +72 -296
  84. package/blog/zh/intlayer_with_next-intl.md +58 -336
  85. package/blog/zh/intlayer_with_react-i18next.md +68 -290
  86. package/blog/zh/intlayer_with_react-intl.md +63 -106
  87. package/dist/cjs/generated/blog.entry.cjs +13 -1
  88. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  89. package/dist/cjs/generated/docs.entry.cjs +13 -1
  90. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  91. package/dist/cjs/generated/frequentQuestions.entry.cjs +13 -1
  92. package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
  93. package/dist/cjs/generated/legal.entry.cjs +13 -1
  94. package/dist/cjs/generated/legal.entry.cjs.map +1 -1
  95. package/dist/esm/generated/blog.entry.mjs +13 -2
  96. package/dist/esm/generated/blog.entry.mjs.map +1 -1
  97. package/dist/esm/generated/docs.entry.mjs +13 -2
  98. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  99. package/dist/esm/generated/frequentQuestions.entry.mjs +13 -2
  100. package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
  101. package/dist/esm/generated/legal.entry.mjs +13 -2
  102. package/dist/esm/generated/legal.entry.mjs.map +1 -1
  103. package/dist/types/generated/blog.entry.d.ts.map +1 -1
  104. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  105. package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
  106. package/dist/types/generated/legal.entry.d.ts.map +1 -1
  107. package/docs/ar/plugins/sync-json.md +244 -0
  108. package/docs/de/plugins/sync-json.md +244 -0
  109. package/docs/de/releases/v7.md +1 -18
  110. package/docs/en/CI_CD.md +1 -1
  111. package/docs/en/configuration.md +1 -1
  112. package/docs/en/formatters.md +1 -1
  113. package/docs/en/how_works_intlayer.md +1 -1
  114. package/docs/en/intlayer_CMS.md +1 -1
  115. package/docs/en/intlayer_cli.md +26 -1
  116. package/docs/en/intlayer_with_nextjs_14.md +3 -1
  117. package/docs/en/intlayer_with_nextjs_15.md +3 -1
  118. package/docs/en/intlayer_with_nextjs_16.md +3 -1
  119. package/docs/en/intlayer_with_nextjs_page_router.md +1 -1
  120. package/docs/en/intlayer_with_nuxt.md +1 -1
  121. package/docs/en/intlayer_with_react_native+expo.md +1 -1
  122. package/docs/en/intlayer_with_react_router_v7.md +1 -1
  123. package/docs/en/intlayer_with_tanstack.md +1 -1
  124. package/docs/en/intlayer_with_vite+preact.md +1 -1
  125. package/docs/en/intlayer_with_vite+react.md +1 -1
  126. package/docs/en/intlayer_with_vite+solid.md +1 -1
  127. package/docs/en/intlayer_with_vite+svelte.md +1 -1
  128. package/docs/en/intlayer_with_vite+vue.md +1 -1
  129. package/docs/en/plugins/sync-json.md +1 -1
  130. package/docs/en/roadmap.md +1 -1
  131. package/docs/en-GB/plugins/sync-json.md +244 -0
  132. package/docs/es/plugins/sync-json.md +244 -0
  133. package/docs/es/releases/v7.md +1 -18
  134. package/docs/fr/intlayer_with_nextjs_16.md +2 -51
  135. package/docs/fr/plugins/sync-json.md +244 -0
  136. package/docs/fr/releases/v7.md +1 -18
  137. package/docs/hi/intlayer_with_nextjs_16.md +3 -2
  138. package/docs/hi/plugins/sync-json.md +244 -0
  139. package/docs/id/plugins/sync-json.md +244 -0
  140. package/docs/id/releases/v7.md +1 -18
  141. package/docs/it/plugins/sync-json.md +244 -0
  142. package/docs/it/releases/v7.md +1 -18
  143. package/docs/ja/intlayer_with_nextjs_16.md +44 -205
  144. package/docs/ja/plugins/sync-json.md +244 -0
  145. package/docs/ja/releases/v7.md +1 -18
  146. package/docs/ko/plugins/sync-json.md +244 -0
  147. package/docs/ko/releases/v7.md +1 -18
  148. package/docs/pl/plugins/sync-json.md +244 -0
  149. package/docs/pt/intlayer_with_nextjs_16.md +1 -52
  150. package/docs/pt/plugins/sync-json.md +244 -0
  151. package/docs/ru/plugins/sync-json.md +244 -0
  152. package/docs/tr/plugins/sync-json.md +245 -0
  153. package/docs/vi/plugins/sync-json.md +244 -0
  154. package/docs/zh/plugins/sync-json.md +244 -0
  155. package/package.json +14 -14
  156. package/src/generated/blog.entry.ts +26 -3
  157. package/src/generated/docs.entry.ts +26 -3
  158. package/src/generated/frequentQuestions.entry.ts +26 -3
  159. package/src/generated/legal.entry.ts +26 -3
@@ -1,346 +1,124 @@
1
1
  ---
2
2
  createdAt: 2025-01-02
3
- updatedAt: 2025-06-29
4
- title: Intlayerreact-i18next
5
- description: Reactアプリのためにreact-i18nextとIntlayerを比較する
3
+ updatedAt: 2025-10-29
4
+ title: Intlayerを使ったreact-i18nextのJSON翻訳の自動化方法
5
+ description: Reactアプリケーションの国際化を強化するために、Intlayerとreact-i18nextを使ってJSON翻訳を自動化する方法。
6
6
  keywords:
7
7
  - react-i18next
8
8
  - i18next
9
9
  - Intlayer
10
10
  - 国際化
11
- - ドキュメンテーション
12
- - Next.js
13
- - JavaScript
11
+ - i18n
12
+ - ブログ
14
13
  - React
14
+ - JavaScript
15
+ - TypeScript
16
+ - コンテンツ管理
15
17
  slugs:
16
18
  - blog
17
19
  - intlayer-with-react-i18next
20
+ history:
21
+ - version: 7.0.0
22
+ date: 2025-10-29
23
+ changes: syncJSONプラグインへの変更
18
24
  ---
19
25
 
20
- # React Internationalization (i18n) with react-i18next and Intlayer
21
-
22
- ## 概要
23
-
24
- - **Intlayer** は、**コンポーネントレベル**のコンテンツ宣言ファイルを介して翻訳を管理するのに役立ちます。
25
- - **react-i18next** は、コンポーネント内でローカライズされた文字列を取得するための `useTranslation` のようなフックを提供する、**i18next** のための人気のある React 統合です。
26
-
27
- 組み合わせることで、Intlayer は **i18next 互換の JSON** 形式の辞書を **エクスポート** できるため、react-i18next はそれらをランタイムで **利用** できます。
28
-
29
- ## なぜ Intlayerを react-i18next と共に使用するのか?
30
-
31
- **Intlayer** のコンテンツ宣言ファイルは、開発者体験を向上させるための以下の特長があります。
32
-
33
- 1. **ファイル配置の柔軟性**
34
- 各コンテンツ宣言ファイルを必要なコンポーネントのすぐ隣に配置します。この構造により、翻訳を共に維持し、コンポーネントが移動したり削除された場合に孤立した翻訳を防ぐことができます。
35
-
36
- ```bash codeFormat="typescript"
37
- .
38
- └── src
39
- └── components
40
- └── MyComponent
41
- ├── index.content.ts # コンテンツ宣言ファイル
42
- └── index.tsx
43
- ```
44
-
45
- ```bash codeFormat="esm"
46
- .
47
- └── src
48
- └── components
49
- └── MyComponent
50
- ├── index.content.mjs # コンテンツ宣言ファイル
51
- └── index.mjx
52
- ```
53
-
54
- ```bash codeFormat="cjs"
55
- .
56
- └── src
57
- └── components
58
- └── MyComponent
59
- ├── index.content.cjs # コンテンツ宣言ファイル
60
- └── index.cjx
61
- ```
62
-
63
- ```bash codeFormat="json"
64
- .
65
- └── src
66
- └── components
67
- └── MyComponent
68
- ├── index.content.json # コンテンツ宣言ファイル
69
- └── index.jsx
70
- ```
71
-
72
- 2. **集中化された翻訳**
73
- 単一のコンテンツ宣言ファイルが、あるコンポーネントに必要なすべての翻訳を集約し、欠落した翻訳を見つけやすくします。
74
- TypeScript を使用すると、翻訳が欠落している場合はコンパイル時エラーが発生します。
75
-
76
- ## インストール
77
-
78
- Create React App プロジェクトで、これらの依存関係をインストールします。
79
-
80
- ```bash
81
- # npmを使用
82
- npm install intlayer react-i18next i18next i18next-resources-to-backend
83
- ```
26
+ # Intlayerを使ったreact-i18nextのJSON翻訳の自動化方法
84
27
 
85
- ```bash
86
- # yarnを使用
87
- yarn add intlayer react-i18next i18next i18next-resources-to-backend
88
- ```
28
+ ## Intlayerとは何ですか?
89
29
 
90
- ```bash
91
- # pnpmを使用
92
- pnpm add intlayer react-i18next i18next i18next-resources-to-backend
93
- ```
30
+ **Intlayer**は、従来のi18nソリューションの欠点を解決するために設計された革新的なオープンソースの国際化ライブラリです。Reactアプリケーションにおけるコンテンツ管理に対して、モダンなアプローチを提供します。
94
31
 
95
- ### これらのパッケージは何ですか?
32
+ 具体的な比較については、当社のブログ記事[react-i18next vs. react-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/ja/react-i18next_vs_react-intl_vs_intlayer.md)をご覧ください。
96
33
 
97
- - **intlayer** – i18n 構成、コンテンツ宣言、および辞書出力を管理するための CLI およびコアライブラリ。
98
- - **react-intlayer** – 辞書のビルドを自動化するためのスクリプトを提供する、Intlayer の React 特有の統合。
99
- - **react-i18next** – i18next のための React 特有の統合ライブラリで、`useTranslation` フックを含む。
100
- - **i18next** – 翻訳処理の基盤となるフレームワーク。
101
- - **i18next-resources-to-backend** – JSON リソースを動的にインポートする i18next バックエンド。
34
+ ## なぜIntlayerをreact-i18nextと組み合わせるのか?
102
35
 
103
- ## Intlayerを構成してi18next辞書をエクスポートする
36
+ Intlayerは優れた単独のi18nソリューションを提供します([React統合ガイド](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_with_vite+react.md)を参照)が、以下のような理由でreact-i18nextと組み合わせたい場合があります:
104
37
 
105
- プロジェクトのルートに `intlayer.config.ts` を作成(または更新)します。
38
+ 1. **既存のコードベース**: 既にreact-i18nextの実装があり、Intlayerの向上した開発者体験へ段階的に移行したい場合。
39
+ 2. **レガシー要件**: プロジェクトが既存のreact-i18nextプラグインやワークフローとの互換性を必要とする場合。
40
+ 3. **チームの慣れ親しみ**: チームがreact-i18nextに慣れているが、より良いコンテンツ管理を望んでいる場合。
106
41
 
107
- ```typescript title="intlayer.config.ts"
108
- import { Locales, type IntlayerConfig } from "intlayer";
42
+ **そのために、Intlayerはreact-i18nextのアダプターとして実装でき、CLIやCI/CDパイプラインでのJSON翻訳の自動化、翻訳のテストなどを支援します。**
109
43
 
110
- const config: IntlayerConfig = {
111
- internationalization: {
112
- // 必要なロケールを追加します
113
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
114
- defaultLocale: Locales.ENGLISH,
115
- },
116
- content: {
117
- // Intlayer に i18next 互換の JSON を作成するように指示します
118
- dictionaryOutput: ["i18next"],
44
+ このガイドでは、react-i18nextとの互換性を維持しながら、Intlayerの優れたコンテンツ宣言システムを活用する方法を示します。
119
45
 
120
- // 生成されたリソースの出力ディレクトリを選択します
121
- // このフォルダは存在しない場合に作成されます。
122
- i18nextResourcesDir: "./i18next/resources",
123
- },
124
- };
46
+ ## 目次
125
47
 
126
- export default config;
127
- ```
128
-
129
- > **注意**: TypeScript を使用していない場合は、この構成ファイルを `.cjs`、`.mjs`、または `.js` として作成できます(詳細は[Intlayer ドキュメント](https://intlayer.org/ja/doc/concept/configuration)を参照してください)。
130
-
131
- ## i18nextリソースのビルド
132
-
133
- コンテンツ宣言が配置されたら(次のセクション)、**Intlayer ビルドコマンド**を実行します。
134
-
135
- ```bash
136
- # npmを使用
137
- npx run intlayer build
138
- ```
139
-
140
- ```bash
141
- # yarnを使用
142
- yarn intlayer build
143
- ```
48
+ <TOC/>
144
49
 
145
- ```bash
146
- # pnpmを使用
147
- pnpm intlayer build
148
- ```
50
+ ## react-i18nextとIntlayerをセットアップするステップバイステップガイド
149
51
 
150
- > これにより、デフォルトで `./i18next/resources` ディレクトリ内に i18next リソースが生成されます。
52
+ ### ステップ1: 依存関係のインストール
151
53
 
152
- 一般的な出力は次のようになります。
54
+ 必要なパッケージをインストールします:
153
55
 
154
- ```bash
155
- .
156
- └── i18next
157
- └── resources
158
- ├── ja
159
- │ └── my-content.json
160
- ├── fr
161
- │ └── my-content.json
162
- └── es
163
- └── my-content.json
56
+ ```bash packageManager="npm"
57
+ npm install intlayer @intlayer/sync-json-plugin
164
58
  ```
165
59
 
166
- **Intlayer** 宣言キーは **i18next 名前空間** として使用されます(例: `my-content.json`)。
167
-
168
- ## react-i18next 構成に辞書をインポートする
169
-
170
- これらのリソースをランタイムで動的に読み込むには、[`i18next-resources-to-backend`](https://www.npmjs.com/package/i18next-resources-to-backend) を使用します。たとえば、プロジェクトに `i18n.ts`(または `.js`)ファイルを作成します。
171
-
172
- ```typescript title="i18n.ts"
173
- import i18next from "i18next";
174
- import { initReactI18next } from "react-i18next";
175
- import resourcesToBackend from "i18next-resources-to-backend";
176
-
177
- i18next
178
- // react-i18next プラグイン
179
- .use(initReactI18next)
180
- // リソースを動的に読み込む
181
- .use(
182
- resourcesToBackend((language: string, namespace: string) => {
183
- // リソースディレクトリへのインポートパスを調整します
184
- return import(`../i18next/resources/${language}/${namespace}.json`);
185
- })
186
- )
187
- // i18next を初期化
188
- .init({
189
- // フォールバックロケール
190
- fallbackLng: "ja",
191
-
192
- // 他の i18next の構成オプションをここに追加できます。詳細は:
193
- // https://www.i18next.com/overview/configuration-options
194
- });
195
-
196
- export default i18next;
60
+ ```bash packageManager="pnpm"
61
+ pnpm add intlayer @intlayer/sync-json-plugin
197
62
  ```
198
63
 
199
- ```javascript title="i18n.js"
200
- import i18next from "i18next";
201
- import { initReactI18next } from "react-i18next";
202
- import resourcesToBackend from "i18next-resources-to-backend";
203
-
204
- i18next
205
- .use(initReactI18next)
206
- .use(
207
- resourcesToBackend(
208
- (language, namespace) =>
209
- import(`../i18next/resources/${language}/${namespace}.json`)
210
- )
211
- )
212
- .init({
213
- fallbackLng: "ja",
214
- });
215
-
216
- export default i18next;
64
+ ```bash packageManager="yarn"
65
+ yarn add intlayer @intlayer/sync-json-plugin
217
66
  ```
218
67
 
219
- 次に、**ルート** または **インデックス** ファイル(例: `src/index.tsx`)で、この `i18n` セットアップを **App** レンダリング前にインポートします。
68
+ **パッケージの説明:**
220
69
 
221
- ```typescript
222
- import React from "react";
223
- import ReactDOM from "react-dom/client";
224
- // 何よりも前に i18n を初期化します
225
- import "./i18n";
226
- import App from "./App";
70
+ - **intlayer**: 国際化管理、コンテンツ宣言、ビルドのためのコアライブラリ
71
+ - **@intlayer/sync-json-plugin**: Intlayerのコンテンツ宣言をreact-i18next互換のJSON形式にエクスポートするプラグイン
227
72
 
228
- ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
229
- <React.StrictMode>
230
- <App />
231
- </React.StrictMode>
232
- );
233
- ```
73
+ ### ステップ2: JSONをラップするためのIntlayerプラグインの実装
234
74
 
235
- ## コンテンツ宣言の作成と管理
75
+ サポートするロケールを定義するIntlayer設定ファイルを作成します:
236
76
 
237
- Intlayer は、`./src` 以下の任意の場所にある「コンテンツ宣言ファイル」から翻訳を抽出します(デフォルト)。
238
- 以下は TypeScript の簡単な例です。
77
+ **react-i18next用のJSON辞書もエクスポートしたい場合は、`syncJSON`プラグインを追加してください:**
239
78
 
240
- ```typescript title="src/components/MyComponent/MyComponent.content.ts"
241
- import { t, type Dictionary } from "intlayer";
79
+ ```typescript fileName="intlayer.config.ts"
80
+ import { Locales, type IntlayerConfig } from "intlayer";
81
+ import { syncJSON } from "@intlayer/sync-json-plugin";
242
82
 
243
- const content = {
244
- // "key" はあなたの i18next 名前空間(例: "my-component")になります
245
- key: "my-component",
246
- content: {
247
- // 各 "t" コールは別々の翻訳ノードです
248
- heading: t({
249
- ja: "こんにちは世界",
250
- fr: "Bonjour le monde",
251
- es: "Hola Mundo",
252
- }),
253
- description: t({
254
- ja: "私の i18n 説明テキスト...",
255
- fr: "Ma description en i18n...",
256
- es: "Mi descripción en i18n...",
257
- }),
83
+ const config: IntlayerConfig = {
84
+ internationalization: {
85
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
86
+ defaultLocale: Locales.ENGLISH,
258
87
  },
259
- } satisfies Dictionary;
260
-
261
- export default content;
262
- ```
263
-
264
- JSON、`.cjs`、または `.mjs` を好む場合は、[Intlayer ドキュメント](https://intlayer.org/ja/doc/concept/content)を参照してください。
265
-
266
- > デフォルトでは、有効なコンテンツ宣言は次のファイル拡張子パターンと一致します:
267
-
268
- > `*.content.{ts,tsx,js,jsx,mjs,mjx,cjs,cjx,json}`
269
-
270
- ## React コンポーネントでの翻訳の使用
271
-
272
- Intlayer リソースを **ビルド** し、react-i18next を構成した後は、**react-i18next** の `useTranslation` フックを直接使用できます。
273
- たとえば:
274
-
275
- ```tsx title="src/components/MyComponent/MyComponent.tsx"
276
- import type { FC } from "react";
277
- import { useTranslation } from "react-i18next";
278
-
279
- /**
280
- * i18next の "namespace" は "MyComponent.content.ts" の Intlayer `key` です
281
- * そのため、useTranslation() に "my-component" を渡します。
282
- */
283
- const MyComponent: FC = () => {
284
- const { t } = useTranslation("my-component");
285
-
286
- return (
287
- <div>
288
- <h1>{t("heading")}</h1>
289
- <p>{t("description")}</p>
290
- </div>
291
- );
88
+ plugins: [
89
+ syncJSON({
90
+ source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
91
+ }),
92
+ ],
292
93
  };
293
94
 
294
- export default MyComponent;
95
+ export default config;
295
96
  ```
296
97
 
297
- > `t` 関数は、生成された JSON 内の **キー** を参照します。Intlayer コンテンツエントリ名 `heading` の場合、`t("heading")` を使用します。
298
-
299
- ## オプション: Create React App スクリプトとの統合 (CRACO)
98
+ `syncJSON` プラグインは JSON を自動的にラップします。コンテンツの構造を変更することなく、JSON ファイルの読み書きを行います。
300
99
 
301
- **react-intlayer** は、カスタムビルドや開発サーバーの構成のための CRACO ベースのアプローチを提供します。Intlayer のビルドステップをシームレスに統合したい場合は:
100
+ もし JSON と intlayer のコンテンツ宣言ファイル(`.content` ファイル)を共存させたい場合、Intlayer は以下の手順で処理します:
302
101
 
303
- 1. **react-intlayerをインストール**(インストールしていない場合):
304
- ```bash
305
- npm install react-intlayer --save-dev
306
- ```
307
- 2. **package.json スクリプトを調整** して `react-intlayer` スクリプトを使用します:
102
+ 1. JSONファイルとコンテンツ宣言ファイルの両方を読み込み、Intlayerの辞書に変換します。
103
+ 2. JSONファイルとコンテンツ宣言ファイルの間に競合がある場合、Intlayerはすべての辞書をマージします。これはプラグインの優先度やコンテンツ宣言ファイルの優先度に依存します(すべて設定可能です)。
308
104
 
309
- ```jsonc
310
- "scripts": {
311
- "start": "react-intlayer start",
312
- "build": "react-intlayer build",
313
- "transpile": "intlayer build"
314
- }
315
- ```
105
+ CLIを使用してJSONの翻訳を行った場合やCMSを使用した場合、Intlayerは新しい翻訳でJSONファイルを更新します。
316
106
 
317
- > `react-intlayer` スクリプトは [CRACO](https://craco.js.org/) に基づいています。また、intlayer craco プラグインに基づいて独自のセットアップを実装することもできます。 [こちらで例を参照](https://github.com/aymericzip/intlayer/blob/main/examples/react-app/craco.config.js)してください。
107
+ `syncJSON`プラグインの詳細については、[syncJSONプラグインのドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/plugins/sync-json.md)をご参照ください。
318
108
 
319
- これで、`npm run build`、`yarn build`、または `pnpm build` を実行すると、Intlayer と CRA のビルドが両方ともトリガーされます。
109
+ ## Git設定
320
110
 
321
- ## TypeScript 構成
111
+ 自動生成されたIntlayerファイルは無視することを推奨します:
322
112
 
323
- **Intlayer** は、コンテンツのための **自動生成された型定義** を提供します。TypeScript がそれらを認識するために、`tsconfig.json` の **`include`** 配列に **`types`**(または異なる構成をしている場合は `types`)を追加してください。
324
-
325
- ```json5 title="tsconfig.json"
326
- {
327
- "compilerOptions": {
328
- // ...
329
- },
330
- "include": ["src", "types"],
331
- }
113
+ ```plaintext fileName=".gitignore"
114
+ # Intlayerによって生成されたファイルを無視する
115
+ .intlayer
332
116
  ```
333
117
 
334
- > これにより、TypeScript が翻訳の形状を推測し、より良いオートコンプリートとエラーチェックを提供します。
118
+ これらのファイルはビルドプロセス中に再生成可能であり、バージョン管理にコミットする必要はありません。
335
119
 
336
- ## Git 構成
120
+ ### VS Code拡張機能
337
121
 
338
- Intlayer によって自動生成されたファイルやフォルダを **無視** することをお勧めします。この行を `.gitignore` に追加します:
339
-
340
- ```plaintext
341
- # Intlayer によって生成されたファイルを無視する
342
- .intlayer
343
- i18next
344
- ```
122
+ 開発者体験を向上させるために、公式の**Intlayer VS Code拡張機能**をインストールしてください:
345
123
 
346
- 通常、これらのリソースや `.intlayer` 内部ビルドアーティファクトは **コミットしないこと** をお勧めします。これらは、各ビルドごとに再生成可能です。
124
+ [VS Codeマーケットプレイスからインストール](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)