@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,325 +1,123 @@
1
1
  ---
2
2
  createdAt: 2025-01-02
3
- updatedAt: 2025-06-29
4
- title: Intlayerreact-intl
5
- description: Reactアプリにreact-intlとIntlayerを統合する
3
+ updatedAt: 2025-10-29
4
+ title: Intlayerを使ったreact-intl JSON翻訳の自動化方法
5
+ description: Reactアプリケーションの国際化を強化するために、Intlayerとreact-intlを使ってJSON翻訳を自動化する方法。
6
6
  keywords:
7
7
  - react-intl
8
8
  - Intlayer
9
9
  - 国際化
10
- - ドキュメンテーション
11
- - Next.js
10
+ - ブログ
11
+ - i18n
12
12
  - JavaScript
13
13
  - React
14
+ - FormatJS
14
15
  slugs:
15
16
  - blog
16
17
  - intlayer-with-react-intl
18
+ history:
19
+ - version: 7.0.0
20
+ date: 2025-10-29
21
+ changes: syncJSONプラグインへの変更
17
22
  ---
18
23
 
19
- # React Internationalization (i18n) with **react-intl** and Intlayer
24
+ # Intlayerを使ったreact-intl JSON翻訳の自動化方法
20
25
 
21
- このガイドでは、React アプリケーションでの翻訳管理のために **Intlayer** を **react-intl** と統合する方法を示します。あなたは Intlayer で翻訳可能なコンテンツを宣言し、その後 **react-intl** を使用してそれらのメッセージを利用します。このライブラリは [FormatJS](https://formatjs.io/docs/react-intl) エコシステムの人気のあるライブラリです。
26
+ ## Intlayerとは何か?
22
27
 
23
- ## 概要
28
+ **Intlayer**は、従来のi18nソリューションの欠点を解決するために設計された革新的なオープンソースの国際化ライブラリです。Reactアプリケーションにおけるコンテンツ管理に対して、モダンなアプローチを提供します。
24
29
 
25
- - **Intlayer** は、プロジェクト内の **コンポーネントレベル** のコンテンツ宣言ファイル(JSON、JS、TS など)に翻訳を格納することを可能にします。
26
- - **react-intl** は、ローカライズされた文字列を表示するための React コンポーネントやフック( `<FormattedMessage>` や `useIntl()` など)を提供します。
30
+ 具体的な比較については、当社のブログ記事[react-i18next vs. react-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/react-i18next_vs_react-intl_vs_intlayer.md)をご覧ください。
27
31
 
28
- Intlayer **export** 設定して、 **react-intl 互換**の形式で翻訳を生成できるようにすると、自動的に **生成** および **更新** されるメッセージファイルを `<IntlProvider>` ( react-intl から) に要求されます。
32
+ ## なぜIntlayerをreact-intlと組み合わせるのか?
29
33
 
30
- ---
34
+ Intlayerは優れた単独のi18nソリューションを提供します([React統合ガイド](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite+react.md)をご覧ください)が、いくつかの理由でreact-intlと組み合わせたい場合があります:
31
35
 
32
- ## なぜ Intlayer を react-intl と一緒に使うべきか?
36
+ 1. **既存のコードベース**: 既にreact-intlの実装があり、Intlayerの優れた開発者体験へ段階的に移行したい場合。
37
+ 2. **レガシー要件**: プロジェクトが既存のreact-intlプラグインやワークフローとの互換性を必要とする場合。
38
+ 3. **チームの慣れ親しみ**: チームがreact-intlに慣れているが、より良いコンテンツ管理を求めている場合。
33
39
 
34
- 1. **コンポーネントごとのコンテンツ宣言**
35
- Intlayer のコンテンツ宣言ファイルは、あなたの React コンポーネントと一緒に存在できるため、コンポーネントが移動または削除された場合の「孤立した」翻訳を防ぐことができます。例えば:
40
+ **そのために、Intlayerはreact-intlのアダプターとして実装でき、CLIやCI/CDパイプラインでのJSON翻訳の自動化、翻訳のテストなどを支援します。**
36
41
 
37
- ```bash
38
- .
39
- └── src
40
- └── components
41
- └── MyComponent
42
- ├── index.content.ts # Intlayer コンテンツ宣言
43
- └── index.tsx # React コンポーネント
44
- ```
42
+ このガイドでは、react-intlとの互換性を保ちながら、Intlayerの優れたコンテンツ宣言システムを活用する方法を示します。
45
43
 
46
- 2. **集中管理された翻訳**
47
- 各コンテンツ宣言ファイルは、コンポーネントが必要とするすべての翻訳を集めます。これは特に TypeScript プロジェクトに役立ちます:欠落した翻訳は **コンパイル時** に検出できます。
44
+ ## 目次
48
45
 
49
- 3. **自動ビルドと再生成**
50
- 翻訳を追加または更新するたびに、Intlayer はメッセージ JSON ファイルを再生成します。次に、これらを react-intl の `<IntlProvider>` に渡すことができます。
46
+ <TOC/>
51
47
 
52
- ---
48
+ ## react-intlとIntlayerをセットアップするステップバイステップガイド
53
49
 
54
- ## インストール
50
+ ### ステップ1: 依存関係のインストール
55
51
 
56
- 通常の React プロジェクトでは、以下のパッケージをインストールします。
52
+ 必要なパッケージをインストールします:
57
53
 
58
- ```bash
59
- # npm
60
- npm install intlayer react-intl
54
+ ```bash packageManager="npm"
55
+ npm install intlayer @intlayer/sync-json-plugin
56
+ ```
61
57
 
62
- # yarn で
63
- yarn add intlayer react-intl
58
+ ```bash packageManager="pnpm"
59
+ pnpm add intlayer @intlayer/sync-json-plugin
60
+ ```
64
61
 
65
- # pnpm で
66
- pnpm add intlayer react-intl
62
+ ```bash packageManager="yarn"
63
+ yarn add intlayer @intlayer/sync-json-plugin
67
64
  ```
68
65
 
69
- ### なぜこれらのパッケージを?
66
+ **パッケージの説明:**
70
67
 
71
- - **intlayer**: コンテンツ宣言をスキャン、マージし、辞書出力を生成するコア CLI とライブラリ。
72
- - **react-intl**: `<IntlProvider>`、 `<FormattedMessage>`、 `useIntl()` およびその他の国際化の基本的な機能を提供する FormatJS のメインライブラリ。
68
+ - **intlayer**: 国際化管理、コンテンツ宣言、およびビルドのためのコアライブラリ
69
+ - **@intlayer/sync-json-plugin**: Intlayerのコンテンツ宣言をreact-intl互換のJSON形式にエクスポートするプラグイン
73
70
 
74
- > まだ React 自体をインストールしていない場合は、`react` と `react-dom` も必要です。
71
+ ### ステップ2: JSONをラップするためのIntlayerプラグインの実装
75
72
 
76
- ## Intlayer を設定して react-intl メッセージをエクスポートする
73
+ サポートするロケールを定義するためにIntlayerの設定ファイルを作成します:
77
74
 
78
- プロジェクトのルートに **`intlayer.config.ts`** (または `.js`、 `.mjs`、 `.cjs`) を次のように作成します。
75
+ **react-intl用のJSON辞書もエクスポートしたい場合は、`syncJSON`プラグインを追加してください:**
79
76
 
80
- ```typescript title="intlayer.config.ts"
77
+ ```typescript fileName="intlayer.config.ts"
81
78
  import { Locales, type IntlayerConfig } from "intlayer";
79
+ import { syncJSON } from "@intlayer/sync-json-plugin";
82
80
 
83
81
  const config: IntlayerConfig = {
84
82
  internationalization: {
85
- // 必要なロケールを追加
86
83
  locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
87
84
  defaultLocale: Locales.ENGLISH,
88
85
  },
89
- content: {
90
- // Intlayer に react-intl 用のメッセージファイルを生成するよう伝えます
91
- dictionaryOutput: ["react-intl"],
92
-
93
- // Intlayer がメッセージ JSON ファイルを書き込むディレクトリ
94
- reactIntlMessagesDir: "./react-intl/messages",
95
- },
96
- };
97
-
98
- export default config;
99
- ```
100
-
101
- > **注**: 他のファイル拡張子( `.mjs`、 `.cjs`、 `.js`)については、[Intlayer ドキュメント](https://intlayer.org/ja/doc/concept/configuration)を参照してください。
102
-
103
- ---
104
-
105
- ## Intlayer コンテンツ宣言の作成
106
-
107
- Intlayer は、デフォルトで `./src` 内のコードベースをスキャンし、 `*.content.{ts,tsx,js,jsx,mjs,mjx,cjs,cjx,json}` に一致するファイルを探します。
108
- 以下は **TypeScript** の例です:
109
-
110
- ```typescript title="src/components/MyComponent/index.content.ts"
111
- import { t, type Dictionary } from "intlayer";
112
-
113
- const content = {
114
- // "key" は react-intl JSON ファイル内のトップレベルメッセージキーになります
115
- key: "my-component",
116
-
117
- content: {
118
- // t() への各呼び出しは翻訳可能なフィールドを宣言します
119
- helloWorld: t({
120
- en: "Hello World",
121
- es: "Hola Mundo",
122
- fr: "Bonjour le monde",
86
+ plugins: [
87
+ syncJSON({
88
+ source: ({ key, locale }) => `./intl/messages/${locale}/${key}.json`,
123
89
  }),
124
- description: t({
125
- en: "This is a description",
126
- fr: "Ceci est une description",
127
- es: "Esta es una descripción",
128
- }),
129
- },
130
- } satisfies Dictionary;
131
-
132
- export default content;
133
- ```
134
-
135
- JSON や異なる JS フレーバー( `.cjs`、 `.mjs`)を好む場合、構造はほぼ同じです, [Intlayer ドキュメントのコンテンツ宣言](https://intlayer.org/ja/doc/concept/content) を参照してください。
136
-
137
- ---
138
-
139
- ## react-intl メッセージのビルド
140
-
141
- **react-intl** の実際のメッセージ JSON ファイルを生成するには、次を実行します。
142
-
143
- ```bash
144
- # npm で
145
- npx intlayer dictionaries build
146
-
147
- # yarn で
148
- yarn intlayer build
149
-
150
- # pnpm で
151
- pnpm intlayer build
152
- ```
153
-
154
- これにより、すべての `*.content.*` ファイルがスキャンされ、コンパイルされ、あなたの **`intlayer.config.ts`** の例では、 `./react-intl/messages` に結果が書き込まれます。
155
- 典型的な出力は次のようになります。
156
-
157
- ```bash
158
- .
159
- └── react-intl
160
- └── messages
161
- ├── en.json
162
- ├── fr.json
163
- └── es.json
164
- ```
165
-
166
- 各ファイルは、 **トップレベルキー** がそれぞれの **`content.key`** に対応する JSON オブジェクトです。 **サブキー**( `helloWorld` のような)は、該当するコンテンツ項目内で宣言された翻訳を反映しています。
167
-
168
- 例えば、 **en.json** は次のようになるかもしれません:
169
-
170
- ```json fileName="react-intl/messages/en/my-component.json"
171
- {
172
- "helloWorld": "Hello World",
173
- "description": "This is a description"
174
- }
175
- ```
176
-
177
- ---
178
-
179
- ## React アプリにおける react-intl の初期化
180
-
181
- ### 1. 生成されたメッセージを読み込む
182
-
183
- アプリのルートコンポーネントを設定する場所(例: `src/main.tsx` または `src/index.tsx`)では、次を行う必要があります。
184
-
185
- 1. **生成されたメッセージファイルをインポート** (静的または動的に)。
186
- 2. **それらを `<IntlProvider>` に提供する** `react-intl` から。
187
-
188
- 簡単なアプローチは、メッセージを **静的に** インポートすることです:
189
-
190
- ```typescript title="src/index.tsx"
191
- import React from "react";
192
- import ReactDOM from "react-dom/client";
193
- import { IntlProvider } from "react-intl";
194
- import App from "./App";
195
-
196
- // ビルド出力から JSON ファイルをインポートします。
197
- // または、ユーザーが選んだロケールに基づいて動的にインポートすることもできます。
198
- import en from "../react-intl/messages/en.json";
199
- import fr from "../react-intl/messages/fr.json";
200
- import es from "../react-intl/messages/es.json";
201
-
202
- // ユーザーの言語を検出するメカニズムがある場合は、ここで設定します。
203
- // 簡単のために、英語を選びましょう。
204
- const locale = "en";
205
-
206
- // メッセージをオブジェクトにまとめる(または動的に選択する)
207
- const messagesRecord: Record<string, Record<string, any>> = {
208
- en,
209
- fr,
210
- es,
90
+ ],
211
91
  };
212
92
 
213
- ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
214
- <React.StrictMode>
215
- <IntlProvider locale={locale} messages={messagesRecord[locale]}>
216
- <App />
217
- </IntlProvider>
218
- </React.StrictMode>
219
- );
220
- ```
221
-
222
- > **ヒント**: 実際のプロジェクトでは、以下のことを行うかもしれません:
223
- >
224
- > - ランタイムで JSON メッセージを動的に読み込む。
225
- > - 環境ベース、ブラウザベース、またはユーザーアカウントベースのロケール検出を使用する。
226
-
227
- ### 2. `<FormattedMessage>` または `useIntl()` を使用する
228
-
229
- メッセージが `<IntlProvider>` に読み込まれると、すべての子コンポーネントは react-intl を使用してローカライズされた文字列にアクセスできます。主なアプローチは二つです:
230
-
231
- - **`<FormattedMessage>`** コンポーネント
232
- - **`useIntl()`** フック
233
-
234
- ---
235
-
236
- ## React コンポーネントでの翻訳の使用
237
-
238
- ### アプローチ A: `<FormattedMessage>`
239
-
240
- インラインでの簡単な使用:
241
-
242
- ```tsx title="src/components/MyComponent/index.tsx"
243
- import React from "react";
244
- import { FormattedMessage } from "react-intl";
245
-
246
- export default function MyComponent() {
247
- return (
248
- <div>
249
- <h1>
250
- {/* “my-component.helloWorld” は en.json、fr.json などのキーを参照します。 */}
251
- <FormattedMessage id="my-component.helloWorld" />
252
- </h1>
253
-
254
- <p>
255
- <FormattedMessage id="my-component.description" />
256
- </p>
257
- </div>
258
- );
259
- }
93
+ export default config;
260
94
  ```
261
95
 
262
- > **`id`** プロパティは、 `<FormattedMessage>` 内で **トップレベルキー**( `my-component`)およびサブキー( `helloWorld`)と一致する必要があります。
263
-
264
- ### アプローチ B: `useIntl()`
265
-
266
- より動的な使用のために:
96
+ `syncJSON` プラグインは JSON を自動的にラップします。コンテンツの構造を変更することなく、JSON ファイルの読み書きを行います。
267
97
 
268
- ```tsx title="src/components/MyComponent/index.tsx"
269
- import React from "react";
270
- import { useIntl } from "react-intl";
98
+ JSON と intlayer のコンテンツ宣言ファイル(`.content` ファイル)を共存させたい場合、Intlayer は以下の手順で処理します:
271
99
 
272
- export default function MyComponent() {
273
- const intl = useIntl();
100
+ 1. JSON ファイルとコンテンツ宣言ファイルの両方を読み込み、intlayer の辞書に変換します。
274
101
 
275
- return (
276
- <div>
277
- <h1>{intl.formatMessage({ id: "my-component.helloWorld" })}</h1>
278
- <p>{intl.formatMessage({ id: "my-component.description" })}</p>
279
- </div>
280
- );
281
- }
282
- ```
283
-
284
- どちらのアプローチも有効です , アプリに合ったスタイルを選択してください。
102
+ 2. JSONとコンテンツ宣言ファイル間に競合がある場合、Intlayerはすべての辞書をマージします。プラグインの優先度やコンテンツ宣言ファイルの優先度に応じて処理されます(すべて設定可能です)。
285
103
 
286
- ---
104
+ CLIを使用してJSONの翻訳を行った場合やCMSを使用した場合、Intlayerは新しい翻訳でJSONファイルを更新します。
287
105
 
288
- ## 翻訳の更新または追加
106
+ `syncJSON`プラグインの詳細については、[syncJSONプラグインのドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/plugins/sync-json.md)をご参照ください。
289
107
 
290
- 1. どの `*.content.*` ファイルにでも **コンテンツを追加または修正** します。
291
- 2. `intlayer build` を再実行して、 `./react-intl/messages` 以下の JSON ファイルを再生成します。
292
- 3. React(および react-intl)は、次回アプリケーションを再ビルドまたはリロードする際にアップデートを取得します。
293
-
294
- ---
108
+ ## Git設定
295
109
 
296
- ## TypeScript 統合(オプション)
110
+ 自動生成されたIntlayerファイルは無視することを推奨します:
297
111
 
298
- TypeScript を使用している場合、Intlayer は翻訳のための **型定義** を **生成** できます。
299
-
300
- - `tsconfig.json` にあなたが `types` フォルダー(または Intlayer が生成する任意の出力フォルダー)を `"include"` 配列に含めてください。
301
-
302
- ```json5
303
- {
304
- "compilerOptions": {
305
- // ...
306
- },
307
- "include": ["src", "types"],
308
- }
112
+ ```plaintext fileName=".gitignore"
113
+ # Intlayerによって生成されたファイルを無視
114
+ .intlayer
309
115
  ```
310
116
 
311
- 生成された型は、コンパイル時に React コンポーネント内の欠落した翻訳や無効なキーを検出するのに役立ちます。
117
+ これらのファイルはビルドプロセス中に再生成可能であり、バージョン管理にコミットする必要はありません。
312
118
 
313
- ---
119
+ ### VS Code 拡張機能
314
120
 
315
- ## Git 設定
316
-
317
- Intlayer の内部ビルドの成果物をバージョン管理から **除外する** ことが一般的です。あなたの `.gitignore` に追加してください:
318
-
319
- ```plaintext
320
- # intlayer ビルド成果物を無視する
321
- .intlayer
322
- react-intl
323
- ```
121
+ 開発者体験を向上させるために、公式の **Intlayer VS Code 拡張機能** をインストールしてください:
324
122
 
325
- あなたのワークフローによっては、 `./react-intl/messages` 内の最終辞書を無視したりコミットしたりしたい場合もあります。もし CI/CD パイプラインがそれらを再生成する場合は、安全に無視できます;さもなければ、プロダクションデプロイメントのためにコミットする必要があります。
123
+ [VS Code Marketplace からインストール](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  createdAt: 2024-12-24
3
- updatedAt: 2025-06-29
4
- title: Intlayer i18next
5
- description: 최적의 국제화를 위해 Intlayer i18next 통합하세요. 프레임워크를 비교하고 함께 구성하는 방법을 알아보세요.
3
+ updatedAt: 2025-10-29
4
+ title: Intlayer 사용하여 i18next JSON 번역 자동화하는 방법
5
+ description: JavaScript 애플리케이션에서 향상된 국제화를 위해 Intlayer i18next 사용하여 JSON 번역을 자동화하세요.
6
6
  keywords:
7
7
  - Intlayer
8
8
  - i18next
@@ -14,149 +14,133 @@ keywords:
14
14
  - Next.js
15
15
  - JavaScript
16
16
  - TypeScript
17
+ - 마이그레이션
18
+ - 통합
17
19
  slugs:
18
20
  - blog
19
21
  - intlayer-with-i18next
22
+ history:
23
+ - version: 7.0.0
24
+ date: 2025-10-29
25
+ changes: syncJSON 플러그인으로 변경
20
26
  ---
21
27
 
22
- # 국제화 Intlayer i18next 사용하기
28
+ # Intlayer 사용하여 i18next JSON 번역 자동화하는 방법
23
29
 
24
- i18next는 JavaScript 응용 프로그램을 위한 오픈 소스 국제화(i18n) 프레임워크입니다. 소프트웨어 프로젝트에서 번역, 지역화 및 언어 전환을 관리하는 데 널리 사용됩니다. 그러나 이는 확장성 및 개발을 복잡하게 만들 수 있는 몇 가지 제한 사항이 있습니다.
30
+ ## Intlayer란 무엇인가요?
25
31
 
26
- Intlayer 이러한 제한 사항을 해결하는 다른 국제화 프레임워크로, 콘텐츠 선언 관리를 위한 보다 유연한 접근 방식을 제공합니다. i18next와 Intlayer의 주요 차이점을 살펴보고, 최적의 국제화를 위해 두 프레임워크를 구성하는 방법을 알아보겠습니다.
32
+ **Intlayer**는 전통적인 i18n 솔루션의 한계를 극복하기 위해 설계된 혁신적이고 오픈 소스인 국제화 라이브러리입니다. JavaScript 애플리케이션에서 현대적인 콘텐츠 관리를 제공합니다.
27
33
 
28
- ## Intlayer와 i18next: 주요 차이점
34
+ i18next와의 구체적인 비교는 저희 블로그 게시물 [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md)에서 확인할 수 있습니다.
29
35
 
30
- ### 1. 콘텐츠 선언
36
+ ## Intlayer와 i18next를 함께 사용해야 할까요?
31
37
 
32
- i18next의 경우 번역 사전을 특정 폴더에 선언해야 하며, 이는 애플리케이션의 확장성을 복잡하게 만들 있습니다. 반면 Intlayer는 컴포넌트와 동일한 디렉토리 내에서 콘텐츠를 선언할 있게 해줍니다. 이는 몇 가지 장점을 제공합니다:
38
+ Intlayer는 훌륭한 독립형 i18n 솔루션을 제공하지만(자세한 내용은 [Next.js 통합 가이드](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/intlayer_with_nextjs_16.md)를 참조), 다음과 같은 여러 이유로 i18next와 함께 사용하고자 있습니다:
33
39
 
34
- - **간소화된 콘텐츠 편집**: 사용자는 수정할 올바른 사전을 찾을 필요가 없어져 오류 가능성이 줄어듭니다.
35
- - **자동 적응**: 만약 컴포넌트의 위치가 변경되거나 제거되면, Intlayer는 이를 자동으로 감지하여 적응합니다.
40
+ 1. **기존 코드베이스**: 이미 구축된 i18next 구현이 있으며 Intlayer의 향상된 개발자 경험으로 점진적으로 이전하고자 할 때.
41
+ 2. **레거시 요구사항**: 프로젝트가 기존 i18next 플러그인 또는 워크플로우와의 호환성을 필요로 때.
42
+ 3. **팀 친숙도**: 팀이 i18next에 익숙하지만 더 나은 콘텐츠 관리를 원할 때.
36
43
 
37
- ### 2. 구성 복잡성
44
+ **이를 위해 Intlayer는 i18next의 어댑터로 구현되어 CLI 또는 CI/CD 파이프라인에서 JSON 번역 자동화, 번역 테스트 등 다양한 작업을 지원할 수 있습니다.**
38
45
 
39
- i18next의 구성은 복잡할 있으며, 특히 서버 측 컴포넌트와 통합하거나 Next.js와 같은 프레임워크를 위한 미들웨어를 구성할 때 더욱 그렇습니다. Intlayer 과정을 간소화하여 보다 직관적인 구성을 제공합니다.
46
+ 가이드는 i18next와의 호환성을 유지하면서 Intlayer 우수한 콘텐츠 선언 시스템을 활용하는 방법을 보여줍니다.
40
47
 
41
- ### 3. 번역 사전의 일관성
48
+ ## 목차
42
49
 
43
- i18next에서는 다양한 언어 간에 번역 사전의 일관성을 보장하는 것이 어려울 수 있습니다. 이러한 불일치는 적절히 관리되지 않으면 애플리케이션 충돌로 이어질 수 있습니다. Intlayer는 번역된 콘텐츠에 제약을 설정하여 모든 번역이 누락되지 않고 정확하게 이루어지도록 합니다.
50
+ <TOC/>
44
51
 
45
- ### 4. TypeScript 통합
52
+ ## i18next와 함께 Intlayer 설정 단계별 가이드
46
53
 
47
- Intlayer는 TypeScript와의 나은 통합을 제공하여 코드 내에서 콘텐츠에 대한 자동 제안을 가능하게 하여 개발 효율성을 향상시킵니다.
54
+ ### 1단계: 의존성 설치
48
55
 
49
- ### 5. 애플리케이션 간 콘텐츠 공유
56
+ 필요한 패키지를 설치하세요:
50
57
 
51
- Intlayer는 여러 애플리케이션 및 공유 라이브러리 간에 콘텐츠 선언 파일을 공유하는 것을 용이하게 합니다. 이 기능은 더 큰 코드베이스에 걸쳐 일관된 번역을 유지하는 데 도움이 됩니다.
58
+ ```bash packageManager="npm"
59
+ npm install intlayer @intlayer/sync-json-plugin
60
+ ```
61
+
62
+ ```bash packageManager="pnpm"
63
+ pnpm add intlayer @intlayer/sync-json-plugin
64
+ ```
65
+
66
+ ```bash packageManager="yarn"
67
+ yarn add intlayer @intlayer/sync-json-plugin
68
+ ```
52
69
 
53
- ## Intlayer로 i18next 사전 생성하기
70
+ **패키지 설명:**
54
71
 
55
- ### i18next 사전을 내보내기 위한 Intlayer 구성
72
+ - **intlayer**: 국제화 관리, 콘텐츠 선언 및 빌드를 위한 핵심 라이브러리
73
+ - **@intlayer/sync-json-plugin**: Intlayer 콘텐츠 선언을 i18next 호환 JSON 형식으로 내보내는 플러그인
56
74
 
57
- > 중요 사항
75
+ ### 2단계: JSON을 래핑하기 위한 Intlayer 플러그인 구현
58
76
 
59
- > i18next 사전의 내보내기는 현재 베타 버전이며 다른 프레임워크와의 1:1 호환성을 보장하지 않습니다. 문제가 발생하지 않도록 Intlayer 기반 구성의 사용을 권장합니다.
77
+ 지원하는 로케일을 정의하기 위해 Intlayer 구성 파일을 만드세요:
60
78
 
61
- i18next 사전을 내보내려면 Intlayer를 적절히 구성해야 합니다. 아래는 Intlayer를 설정하여 Intlayer 및 i18next 사전을 모두 내보내는 방법의 예입니다.
79
+ **i18next JSON 사전도 내보내고 싶다면**, `syncJSON` 플러그인을 추가하세요:
62
80
 
63
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
81
+ ```typescript fileName="intlayer.config.ts"
64
82
  import { Locales, type IntlayerConfig } from "intlayer";
83
+ import { syncJSON } from "@intlayer/sync-json-plugin";
65
84
 
66
85
  const config: IntlayerConfig = {
67
- content: {
68
- // Intlayer가 Intlayer와 i18next 사전을 모두 내보낸다는 것을 나타냅니다.
69
- dictionaryOutput: ["intlayer", "i18next"],
70
- // i18n 사전이 내보낼 디렉토리까지의 프로젝트 루트에서의 상대 경로
71
- i18nextResourcesDir: "./i18next/dictionaries",
86
+ internationalization: {
87
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
88
+ defaultLocale: Locales.ENGLISH,
72
89
  },
90
+ plugins: [
91
+ syncJSON({
92
+ source: ({ key, locale }) => `./intl/messages/${locale}/${key}.json`,
93
+ }),
94
+ ],
73
95
  };
74
96
 
75
97
  export default config;
76
98
  ```
77
99
 
78
- ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
79
- import { Locales } from "intlayer";
100
+ `syncJSON` 플러그인은 JSON을 자동으로 래핑합니다. 콘텐츠 구조를 변경하지 않고 JSON 파일을 읽고 씁니다.
80
101
 
81
- /** @type {import('intlayer').IntlayerConfig} */
82
- const config = {
83
- content: {
84
- // Intlayer가 Intlayer와 i18next 사전을 모두 내보낸다는 것을 나타냅니다.
85
- dictionaryOutput: ["intlayer", "i18next"],
86
- // i18n 사전이 내보낼 디렉토리까지의 프로젝트 루트에서의 상대 경로
87
- i18nextResourcesDir: "./i18next/dictionaries",
88
- },
89
- };
102
+ 만약 JSON과 intlayer 콘텐츠 선언 파일(`.content` 파일) 공존시키고 싶다면, Intlayer는 다음과 같이 처리합니다:
90
103
 
91
- export default config;
92
- ```
104
+ 1. JSON과 콘텐츠 선언 파일을 모두 로드하여 intlayer 사전(dictionary)으로 변환합니다.
93
105
 
94
- ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
95
- const { Locales } = require("intlayer");
106
+ 2. JSON과 콘텐츠 선언 파일 간에 충돌이 있을 경우, Intlayer는 모든 사전을 병합하는 과정을 진행합니다. 이는 플러그인의 우선순위와 콘텐츠 선언 파일의 우선순위에 따라 결정되며(모두 구성 가능합니다).
96
107
 
97
- /** @type {import('intlayer').IntlayerConfig} */
98
- const config = {
99
- content: {
100
- // Intlayer가 Intlayer와 i18next 사전을 모두 내보낸다는 것을 나타냅니다.
101
- dictionaryOutput: ["intlayer", "i18next"],
102
- // i18n 사전이 내보낼 디렉토리까지의 프로젝트 루트에서의 상대 경로
103
- i18nextResourcesDir: "./i18next/dictionaries",
104
- },
105
- };
108
+ CLI를 사용하여 JSON을 번역하거나 CMS를 통해 변경 사항이 발생하면, Intlayer는 새로운 번역으로 JSON 파일을 업데이트합니다.
109
+
110
+ ## Git 구성
106
111
 
107
- module.exports = config;
112
+ 자동 생성된 Intlayer 파일을 무시하는 것이 권장됩니다:
113
+
114
+ ```plaintext fileName=".gitignore"
115
+ # Intlayer에서 생성된 파일 무시
116
+ .intlayer
108
117
  ```
109
118
 
110
- ' i18next'를 구성에 포함시킴으로써 Intlayer는 Intlayer 사전과 함께 전용 i18next 사전을 생성합니다. 'intlayer'를 구성에서 제거하면 React-Intlayer 또는 Next-Intlayer와의 호환성이 깨질 수 있습니다.
119
+ 파일들은 빌드 과정 중에 다시 생성될 있으므로 버전 관리에 커밋할 필요가 없습니다.
111
120
 
112
- ### i18next 구성으로 사전 가져오기
121
+ ### VS Code 확장 프로그램
113
122
 
114
- 생성된 사전을 i18next 구성으로 가져오려면 'i18next-resources-to-backend'를 사용할 있습니다. 다음은 생성한 i18next 사전을 가져오는 방법의 예입니다.
123
+ 개발자 경험을 향상시키기 위해 공식 **Intlayer VS Code 확장 프로그램**을 설치하세요:
115
124
 
116
- ```typescript fileName="i18n/client.ts" codeFormat="typescript"
117
- // i18n/client.ts
125
+ [VS Code 마켓플레이스에서 설치하기](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
118
126
 
119
- import i18next from "i18next";
120
- import resourcesToBackend from "i18next-resources-to-backend";
127
+ 2. JSON과 콘텐츠 선언 파일 간에 충돌이 있는 경우, Intlayer는 모든 사전을 병합하여 처리합니다. 플러그인의 우선순위와 콘텐츠 선언 파일의 우선순위에 따라 달라집니다(모두 구성 가능).
121
128
 
122
- i18next
123
- // 여기에 i18next 구성 작성
124
- .use(
125
- resourcesToBackend(
126
- (language: string, namespace: string) =>
127
- import(`../i18next/dictionaries/${language}/${namespace}.json`)
128
- )
129
- );
130
- ```
129
+ CLI를 사용하여 JSON을 번역하거나 CMS를 사용하여 변경 사항이 이루어지면, Intlayer는 새로운 번역으로 JSON 파일을 업데이트합니다.
131
130
 
132
- ```javascript fileName="i18n/client.mjs" codeFormat="esm"
133
- // i18n/client.mjs
131
+ ## Git 구성
134
132
 
135
- import i18next from "i18next";
136
- import resourcesToBackend from "i18next-resources-to-backend";
133
+ 자동 생성된 Intlayer 파일을 무시하는 것이 권장됩니다:
137
134
 
138
- i18next
139
- // 여기에 i18next 구성 작성
140
- .use(
141
- resourcesToBackend(
142
- (language, namespace) =>
143
- import(`../i18next/dictionaries/${language}/${namespace}.json`)
144
- )
145
- );
135
+ ```plaintext fileName=".gitignore"
136
+ # Intlayer에서 생성된 파일 무시
137
+ .intlayer
146
138
  ```
147
139
 
148
- ```javascript fileName="i18n/client.cjs" codeFormat="commonjs"
149
- // i18n/client.cjs
140
+ 파일들은 빌드 과정 중에 다시 생성될 수 있으므로 버전 관리에 커밋할 필요가 없습니다.
150
141
 
151
- const i18next = require("i18next");
152
- const resourcesToBackend = require("i18next-resources-to-backend");
142
+ ### VS Code 확장 프로그램
153
143
 
154
- i18next
155
- // 여기에 i18next 구성 작성
156
- .use(
157
- resourcesToBackend(
158
- (language, namespace) =>
159
- import(`../i18next/dictionaries/${language}/${namespace}.json`)
160
- )
161
- );
162
- ```
144
+ 개발자 경험 향상을 위해 공식 **Intlayer VS Code 확장 프로그램**을 설치하세요:
145
+
146
+ [VS Code 마켓플레이스에서 설치하기](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)