@intlayer/docs 8.3.0-canary.4 → 8.3.1

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 (240) hide show
  1. package/docs/ar/compiler.md +84 -49
  2. package/docs/ar/configuration.md +80 -37
  3. package/docs/ar/intlayer_with_nextjs_16.md +174 -1
  4. package/docs/ar/intlayer_with_nextjs_compiler.md +174 -1
  5. package/docs/ar/intlayer_with_react_router_v7.md +224 -1
  6. package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +225 -1
  7. package/docs/ar/intlayer_with_svelte_kit.md +175 -2
  8. package/docs/ar/intlayer_with_tanstack.md +176 -1
  9. package/docs/ar/intlayer_with_vite+preact.md +174 -1
  10. package/docs/ar/intlayer_with_vite+react.md +174 -1
  11. package/docs/ar/intlayer_with_vite+solid.md +174 -1
  12. package/docs/ar/intlayer_with_vite+svelte.md +174 -1
  13. package/docs/ar/intlayer_with_vite+vue.md +174 -1
  14. package/docs/de/compiler.md +83 -48
  15. package/docs/de/configuration.md +434 -212
  16. package/docs/de/intlayer_with_nextjs_16.md +176 -1
  17. package/docs/de/intlayer_with_nextjs_compiler.md +106 -349
  18. package/docs/de/intlayer_with_react_router_v7.md +225 -2
  19. package/docs/de/intlayer_with_react_router_v7_fs_routes.md +221 -79
  20. package/docs/de/intlayer_with_svelte_kit.md +158 -2
  21. package/docs/de/intlayer_with_tanstack.md +159 -1
  22. package/docs/de/intlayer_with_vite+preact.md +157 -1
  23. package/docs/de/intlayer_with_vite+react.md +157 -1
  24. package/docs/de/intlayer_with_vite+solid.md +159 -3
  25. package/docs/de/intlayer_with_vite+svelte.md +157 -1
  26. package/docs/de/intlayer_with_vite+vue.md +157 -1
  27. package/docs/en/compiler.md +60 -33
  28. package/docs/en/configuration.md +80 -57
  29. package/docs/en/intlayer_with_nextjs_16.md +176 -0
  30. package/docs/en/intlayer_with_nextjs_compiler.md +179 -1
  31. package/docs/en/intlayer_with_react_router_v7.md +159 -0
  32. package/docs/en/intlayer_with_react_router_v7_fs_routes.md +159 -0
  33. package/docs/en/intlayer_with_svelte_kit.md +159 -0
  34. package/docs/en/intlayer_with_tanstack.md +160 -1
  35. package/docs/en/intlayer_with_vite+preact.md +159 -0
  36. package/docs/en/intlayer_with_vite+react.md +159 -0
  37. package/docs/en/intlayer_with_vite+solid.md +148 -27
  38. package/docs/en/intlayer_with_vite+svelte.md +159 -0
  39. package/docs/en/intlayer_with_vite+vue.md +142 -41
  40. package/docs/en-GB/compiler.md +66 -34
  41. package/docs/en-GB/configuration.md +78 -36
  42. package/docs/es/compiler.md +83 -48
  43. package/docs/es/configuration.md +429 -206
  44. package/docs/es/intlayer_with_adonisjs.md +1 -1
  45. package/docs/es/intlayer_with_express.md +1 -1
  46. package/docs/es/intlayer_with_fastify.md +1 -1
  47. package/docs/es/intlayer_with_hono.md +1 -1
  48. package/docs/es/intlayer_with_nestjs.md +1 -1
  49. package/docs/es/intlayer_with_nextjs_16.md +176 -3
  50. package/docs/es/intlayer_with_nextjs_compiler.md +175 -2
  51. package/docs/es/intlayer_with_nuxt.md +1 -1
  52. package/docs/es/intlayer_with_react_router_v7.md +227 -4
  53. package/docs/es/intlayer_with_react_router_v7_fs_routes.md +162 -4
  54. package/docs/es/intlayer_with_svelte_kit.md +158 -2
  55. package/docs/es/intlayer_with_tanstack.md +160 -2
  56. package/docs/es/intlayer_with_vite+preact.md +162 -6
  57. package/docs/es/intlayer_with_vite+react.md +160 -4
  58. package/docs/es/intlayer_with_vite+solid.md +163 -7
  59. package/docs/es/intlayer_with_vite+svelte.md +157 -1
  60. package/docs/es/intlayer_with_vite+vue.md +165 -9
  61. package/docs/fr/compiler.md +81 -46
  62. package/docs/fr/configuration.md +355 -134
  63. package/docs/fr/intlayer_with_adonisjs.md +1 -1
  64. package/docs/fr/intlayer_with_express.md +1 -1
  65. package/docs/fr/intlayer_with_fastify.md +1 -1
  66. package/docs/fr/intlayer_with_hono.md +1 -1
  67. package/docs/fr/intlayer_with_nestjs.md +1 -1
  68. package/docs/fr/intlayer_with_nextjs_16.md +183 -7
  69. package/docs/fr/intlayer_with_nextjs_compiler.md +179 -3
  70. package/docs/fr/intlayer_with_react_router_v7.md +229 -3
  71. package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +237 -6
  72. package/docs/fr/intlayer_with_svelte_kit.md +158 -2
  73. package/docs/fr/intlayer_with_tanstack.md +159 -1
  74. package/docs/fr/intlayer_with_vite+preact.md +164 -8
  75. package/docs/fr/intlayer_with_vite+react.md +162 -6
  76. package/docs/fr/intlayer_with_vite+solid.md +163 -7
  77. package/docs/fr/intlayer_with_vite+svelte.md +157 -1
  78. package/docs/fr/intlayer_with_vite+vue.md +164 -8
  79. package/docs/hi/compiler.md +81 -46
  80. package/docs/hi/configuration.md +87 -44
  81. package/docs/hi/intlayer_with_nextjs_16.md +174 -1
  82. package/docs/hi/intlayer_with_nextjs_compiler.md +174 -1
  83. package/docs/hi/intlayer_with_react_router_v7.md +224 -1
  84. package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +225 -1
  85. package/docs/hi/intlayer_with_svelte_kit.md +158 -2
  86. package/docs/hi/intlayer_with_tanstack.md +159 -1
  87. package/docs/hi/intlayer_with_vite+preact.md +157 -1
  88. package/docs/hi/intlayer_with_vite+react.md +157 -1
  89. package/docs/hi/intlayer_with_vite+solid.md +157 -1
  90. package/docs/hi/intlayer_with_vite+svelte.md +157 -1
  91. package/docs/hi/intlayer_with_vite+vue.md +157 -1
  92. package/docs/id/compiler.md +84 -51
  93. package/docs/id/configuration.md +83 -45
  94. package/docs/id/intlayer_with_nextjs_16.md +174 -1
  95. package/docs/id/intlayer_with_nextjs_compiler.md +174 -1
  96. package/docs/id/intlayer_with_react_router_v7.md +224 -1
  97. package/docs/id/intlayer_with_react_router_v7_fs_routes.md +225 -1
  98. package/docs/id/intlayer_with_svelte_kit.md +158 -2
  99. package/docs/id/intlayer_with_tanstack.md +159 -1
  100. package/docs/id/intlayer_with_vite+preact.md +157 -1
  101. package/docs/id/intlayer_with_vite+react.md +157 -1
  102. package/docs/id/intlayer_with_vite+solid.md +157 -1
  103. package/docs/id/intlayer_with_vite+svelte.md +157 -1
  104. package/docs/id/intlayer_with_vite+vue.md +157 -1
  105. package/docs/it/compiler.md +81 -46
  106. package/docs/it/configuration.md +426 -204
  107. package/docs/it/intlayer_with_nextjs_16.md +174 -1
  108. package/docs/it/intlayer_with_nextjs_compiler.md +174 -1
  109. package/docs/it/intlayer_with_react_router_v7.md +225 -2
  110. package/docs/it/intlayer_with_react_router_v7_fs_routes.md +226 -2
  111. package/docs/it/intlayer_with_svelte_kit.md +158 -2
  112. package/docs/it/intlayer_with_tanstack.md +159 -1
  113. package/docs/it/intlayer_with_vite+preact.md +157 -1
  114. package/docs/it/intlayer_with_vite+react.md +157 -1
  115. package/docs/it/intlayer_with_vite+solid.md +159 -3
  116. package/docs/it/intlayer_with_vite+svelte.md +157 -1
  117. package/docs/it/intlayer_with_vite+vue.md +157 -1
  118. package/docs/ja/compiler.md +94 -58
  119. package/docs/ja/configuration.md +88 -45
  120. package/docs/ja/intlayer_with_nextjs_16.md +174 -1
  121. package/docs/ja/intlayer_with_nextjs_compiler.md +174 -1
  122. package/docs/ja/intlayer_with_react_router_v7.md +184 -394
  123. package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +226 -2
  124. package/docs/ja/intlayer_with_svelte_kit.md +119 -595
  125. package/docs/ja/intlayer_with_tanstack.md +131 -642
  126. package/docs/ja/intlayer_with_vite+preact.md +111 -1231
  127. package/docs/ja/intlayer_with_vite+react.md +129 -1304
  128. package/docs/ja/intlayer_with_vite+solid.md +159 -3
  129. package/docs/ja/intlayer_with_vite+svelte.md +157 -1
  130. package/docs/ja/intlayer_with_vite+vue.md +157 -1
  131. package/docs/ko/compiler.md +88 -52
  132. package/docs/ko/configuration.md +87 -44
  133. package/docs/ko/intlayer_with_nextjs_16.md +174 -1
  134. package/docs/ko/intlayer_with_nextjs_compiler.md +174 -1
  135. package/docs/ko/intlayer_with_react_router_v7.md +225 -2
  136. package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +226 -2
  137. package/docs/ko/intlayer_with_svelte_kit.md +158 -2
  138. package/docs/ko/intlayer_with_tanstack.md +159 -1
  139. package/docs/ko/intlayer_with_vite+preact.md +157 -1
  140. package/docs/ko/intlayer_with_vite+react.md +157 -1
  141. package/docs/ko/intlayer_with_vite+solid.md +159 -3
  142. package/docs/ko/intlayer_with_vite+svelte.md +157 -1
  143. package/docs/ko/intlayer_with_vite+vue.md +157 -1
  144. package/docs/pl/compiler.md +84 -51
  145. package/docs/pl/configuration.md +83 -37
  146. package/docs/pl/intlayer_with_nextjs_16.md +174 -1
  147. package/docs/pl/intlayer_with_nextjs_compiler.md +174 -1
  148. package/docs/pl/intlayer_with_react_router_v7.md +224 -1
  149. package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +225 -1
  150. package/docs/pl/intlayer_with_svelte_kit.md +158 -2
  151. package/docs/pl/intlayer_with_tanstack.md +159 -1
  152. package/docs/pl/intlayer_with_vite+preact.md +157 -1
  153. package/docs/pl/intlayer_with_vite+react.md +157 -1
  154. package/docs/pl/intlayer_with_vite+solid.md +157 -1
  155. package/docs/pl/intlayer_with_vite+svelte.md +157 -1
  156. package/docs/pl/intlayer_with_vite+vue.md +157 -1
  157. package/docs/pt/compiler.md +81 -46
  158. package/docs/pt/configuration.md +404 -194
  159. package/docs/pt/intlayer_with_nextjs_16.md +174 -1
  160. package/docs/pt/intlayer_with_nextjs_compiler.md +174 -1
  161. package/docs/pt/intlayer_with_react_router_v7.md +224 -1
  162. package/docs/pt/intlayer_with_react_router_v7_fs_routes.md +225 -1
  163. package/docs/pt/intlayer_with_svelte_kit.md +158 -2
  164. package/docs/pt/intlayer_with_tanstack.md +159 -1
  165. package/docs/pt/intlayer_with_vite+preact.md +157 -1
  166. package/docs/pt/intlayer_with_vite+react.md +157 -1
  167. package/docs/pt/intlayer_with_vite+solid.md +157 -1
  168. package/docs/pt/intlayer_with_vite+svelte.md +157 -1
  169. package/docs/pt/intlayer_with_vite+vue.md +157 -1
  170. package/docs/ru/compiler.md +90 -57
  171. package/docs/ru/configuration.md +76 -46
  172. package/docs/ru/intlayer_with_nextjs_16.md +174 -1
  173. package/docs/ru/intlayer_with_nextjs_compiler.md +174 -1
  174. package/docs/ru/intlayer_with_react_router_v7.md +224 -1
  175. package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +225 -1
  176. package/docs/ru/intlayer_with_svelte_kit.md +158 -2
  177. package/docs/ru/intlayer_with_tanstack.md +159 -1
  178. package/docs/ru/intlayer_with_vite+preact.md +157 -1
  179. package/docs/ru/intlayer_with_vite+react.md +157 -1
  180. package/docs/ru/intlayer_with_vite+solid.md +157 -1
  181. package/docs/ru/intlayer_with_vite+svelte.md +157 -1
  182. package/docs/ru/intlayer_with_vite+vue.md +157 -1
  183. package/docs/tr/compiler.md +85 -52
  184. package/docs/tr/configuration.md +83 -40
  185. package/docs/tr/intlayer_with_nextjs_16.md +174 -1
  186. package/docs/tr/intlayer_with_nextjs_compiler.md +174 -1
  187. package/docs/tr/intlayer_with_react_router_v7.md +224 -1
  188. package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +225 -1
  189. package/docs/tr/intlayer_with_svelte_kit.md +158 -2
  190. package/docs/tr/intlayer_with_tanstack.md +159 -1
  191. package/docs/tr/intlayer_with_vite+preact.md +157 -1
  192. package/docs/tr/intlayer_with_vite+react.md +157 -1
  193. package/docs/tr/intlayer_with_vite+solid.md +157 -1
  194. package/docs/tr/intlayer_with_vite+svelte.md +157 -1
  195. package/docs/tr/intlayer_with_vite+vue.md +157 -1
  196. package/docs/uk/compiler.md +96 -61
  197. package/docs/uk/configuration.md +83 -37
  198. package/docs/uk/intlayer_with_nextjs_16.md +174 -1
  199. package/docs/uk/intlayer_with_nextjs_compiler.md +174 -1
  200. package/docs/uk/intlayer_with_react_router_v7.md +224 -1
  201. package/docs/uk/intlayer_with_react_router_v7_fs_routes.md +225 -1
  202. package/docs/uk/intlayer_with_svelte_kit.md +157 -1
  203. package/docs/uk/intlayer_with_tanstack.md +159 -1
  204. package/docs/uk/intlayer_with_vite+preact.md +157 -1
  205. package/docs/uk/intlayer_with_vite+react.md +157 -1
  206. package/docs/uk/intlayer_with_vite+solid.md +157 -1
  207. package/docs/uk/intlayer_with_vite+svelte.md +157 -1
  208. package/docs/uk/intlayer_with_vite+vue.md +157 -1
  209. package/docs/vi/compiler.md +85 -50
  210. package/docs/vi/configuration.md +85 -39
  211. package/docs/vi/intlayer_with_nextjs_16.md +174 -1
  212. package/docs/vi/intlayer_with_nextjs_compiler.md +174 -1
  213. package/docs/vi/intlayer_with_react_router_v7.md +224 -1
  214. package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +225 -1
  215. package/docs/vi/intlayer_with_svelte_kit.md +158 -2
  216. package/docs/vi/intlayer_with_tanstack.md +159 -1
  217. package/docs/vi/intlayer_with_vite+preact.md +157 -1
  218. package/docs/vi/intlayer_with_vite+react.md +157 -1
  219. package/docs/vi/intlayer_with_vite+solid.md +157 -1
  220. package/docs/vi/intlayer_with_vite+svelte.md +157 -1
  221. package/docs/vi/intlayer_with_vite+vue.md +157 -1
  222. package/docs/zh/compiler.md +84 -49
  223. package/docs/zh/configuration.md +80 -37
  224. package/docs/zh/intlayer_with_adonisjs.md +1 -1
  225. package/docs/zh/intlayer_with_express.md +1 -1
  226. package/docs/zh/intlayer_with_fastify.md +1 -1
  227. package/docs/zh/intlayer_with_hono.md +1 -1
  228. package/docs/zh/intlayer_with_nestjs.md +1 -1
  229. package/docs/zh/intlayer_with_nextjs_16.md +174 -1
  230. package/docs/zh/intlayer_with_nextjs_compiler.md +174 -1
  231. package/docs/zh/intlayer_with_react_router_v7.md +227 -4
  232. package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +228 -4
  233. package/docs/zh/intlayer_with_svelte_kit.md +158 -2
  234. package/docs/zh/intlayer_with_tanstack.md +159 -1
  235. package/docs/zh/intlayer_with_vite+preact.md +159 -3
  236. package/docs/zh/intlayer_with_vite+react.md +157 -1
  237. package/docs/zh/intlayer_with_vite+solid.md +161 -5
  238. package/docs/zh/intlayer_with_vite+svelte.md +157 -1
  239. package/docs/zh/intlayer_with_vite+vue.md +158 -2
  240. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2025-04-18
3
- updatedAt: 2025-12-30
3
+ updatedAt: 2026-03-12
4
4
  title: Vite + Preact i18n - Preactアプリの翻訳方法 2026
5
5
  description: Vite と Preact のウェブサイトを多言語対応にする方法を紹介します。国際化(i18n)と翻訳のためのドキュメントに従ってください。
6
6
  keywords:
@@ -64,64 +64,39 @@ Intlayer を使うと、以下が可能です:
64
64
 
65
65
  ## Vite と Preact アプリケーションで Intlayer をセットアップするステップバイステップガイド
66
66
 
67
- ### ステップ 1: 依存関係のインストール
67
+ ### (オプション) ステップ 1 : コンポーネントのコンテンツを抽出する
68
68
 
69
- npm を使って必要なパッケージをインストールします:
69
+ 既存のコードベースがある場合、数千のファイルを変換するのは時間がかかることがあります。
70
70
 
71
- ```bash packageManager="npm"
72
- npm install intlayer preact-intlayer
73
- npm install vite-intlayer --save-dev
74
- npx intlayer init
75
- ```
71
+ このプロセスを容易にするために、Intlayerは、コンポーネントを変換しコンテンツを抽出するための [コンパイラ](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/compiler.md) / [エクストラクタ](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/cli/extract.md) を提案しています。
76
72
 
77
- ```bash packageManager="pnpm"
78
- pnpm add intlayer preact-intlayer
79
- pnpm add vite-intlayer --save-dev
80
- pnpm intlayer init
81
- ```
82
-
83
- ```bash packageManager="yarn"
84
- yarn add intlayer preact-intlayer
85
- yarn add vite-intlayer --save-dev
86
- yarn intlayer init
87
- ```
88
-
89
- ```bash packageManager="bun"
90
- bun add intlayer preact-intlayer
91
- bun add vite-intlayer --dev
92
- bunx intlayer init
93
- ```
94
-
95
- - **intlayer**
96
-
97
- 設定管理、翻訳、[コンテンツ宣言](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)のための国際化ツールを提供するコアパッケージ。
98
-
99
- - **preact-intlayer**
100
- IntlayerをPreactアプリケーションと統合するパッケージです。Preactの国際化のためのコンテキストプロバイダーとフックを提供します。
101
-
102
- - **vite-intlayer**
103
- Intlayerを[Viteバンドラー](https://vite.dev/guide/why.html#why-bundle-for-production)と統合するためのViteプラグイン、およびユーザーの優先ロケール検出、クッキー管理、URLリダイレクト処理のためのミドルウェアを含みます。
104
-
105
- ### ステップ 2: プロジェクトの設定
106
-
107
- アプリケーションの言語を設定するための設定ファイルを作成します:
73
+ セットアップするには、`intlayer.config.ts` ファイルに `compiler` セクションを追加します。
108
74
 
109
75
  ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
110
- import { Locales, type IntlayerConfig } from "intlayer";
76
+ import { type IntlayerConfig } from "intlayer";
111
77
 
112
78
  const config: IntlayerConfig = {
113
- internationalization: {
114
- locales: [
115
- Locales.ENGLISH,
116
- Locales.FRENCH,
117
- Locales.SPANISH,
118
- // 他のロケールをここに追加
119
- ],
120
- defaultLocale: Locales.ENGLISH,
121
- },
122
- routing: {
123
- mode: "prefix-no-default", // デフォルト:デフォルトロケール以外のすべてのロケールにプレフィックスを付ける
124
- storage: ["cookie", "header"], // デフォルト:ロケールをクッキーに保存し、ヘッダーから検出する
79
+ // ... 他の構成
80
+ compiler: {
81
+ /**
82
+ * コンパイラを有効にするかどうかを指定します。
83
+ */
84
+ enabled: true,
85
+
86
+ /**
87
+ * 出力ファイルのパスを定義します。
88
+ */
89
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
90
+
91
+ /**
92
+ * 変換後にコンポーネントを保存するかどうかを指定します。これにより、コンパイラを一度だけ実行してアプリを変換し、その後削除することができます。
93
+ */
94
+ saveComponents: false,
95
+
96
+ /**
97
+ * 辞書キーの接頭辞
98
+ */
99
+ dictionaryKeyPrefix: "",
125
100
  },
126
101
  };
127
102
 
@@ -129,22 +104,29 @@ export default config;
129
104
  ```
130
105
 
131
106
  ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
132
- import { Locales } from "intlayer";
133
-
134
107
  /** @type {import('intlayer').IntlayerConfig} */
135
108
  const config = {
136
- internationalization: {
137
- locales: [
138
- Locales.ENGLISH,
139
- Locales.FRENCH,
140
- Locales.SPANISH,
141
- // 他のロケールをここに追加
142
- ],
143
- defaultLocale: Locales.ENGLISH,
144
- },
145
- routing: {
146
- mode: "prefix-no-default", // デフォルト:デフォルトロケール以外のすべてのロケールにプレフィックスを付ける
147
- storage: ["cookie", "header"], // デフォルト:ロケールをクッキーに保存し、ヘッダーから検出する
109
+ // ... 他の構成
110
+ compiler: {
111
+ /**
112
+ * コンパイラを有効にするかどうかを指定します。
113
+ */
114
+ enabled: true,
115
+
116
+ /**
117
+ * 出力ファイルのパスを定義します。
118
+ */
119
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
120
+
121
+ /**
122
+ * 変換後にコンポーネントを保存するかどうかを指定します。これにより、コンパイラを一度だけ実行してアプリを変換し、その後削除することができます。
123
+ */
124
+ saveComponents: false,
125
+
126
+ /**
127
+ * 辞書キーの接頭辞
128
+ */
129
+ dictionaryKeyPrefix: "",
148
130
  },
149
131
  };
150
132
 
@@ -152,1210 +134,108 @@ export default config;
152
134
  ```
153
135
 
154
136
  ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
155
- const { Locales } = require("intlayer");
156
-
157
137
  /** @type {import('intlayer').IntlayerConfig} */
158
138
  const config = {
159
- internationalization: {
160
- locales: [
161
- Locales.ENGLISH,
162
- Locales.FRENCH,
163
- Locales.SPANISH,
164
- // 他のロケール
165
- ],
166
- defaultLocale: Locales.ENGLISH,
167
- },
168
- routing: {
169
- mode: "prefix-no-default", // デフォルト:デフォルトロケール以外のすべてのロケールにプレフィックスを付ける
170
- storage: ["cookie", "header"], // デフォルト:ロケールをクッキーに保存し、ヘッダーから検出する
139
+ // ... 他の構成
140
+ compiler: {
141
+ /**
142
+ * コンパイラを有効にするかどうかを指定します。
143
+ */
144
+ enabled: true,
145
+
146
+ /**
147
+ * 出力ファイルのパスを定義します。
148
+ */
149
+ output: ({ fileName, extension }) => `./${fileName}${extension}`,
150
+
151
+ /**
152
+ * 変換後にコンポーネントを保存するかどうかを指定します。これにより、コンパイラを一度だけ実行してアプリを変換し、その後削除することができます。
153
+ */
154
+ saveComponents: false,
155
+
156
+ /**
157
+ * 辞書キーの接頭辞
158
+ */
159
+ dictionaryKeyPrefix: "",
171
160
  },
172
161
  };
173
162
 
174
163
  module.exports = config;
175
164
  ```
176
165
 
177
- > この設定ファイルを通じて、ローカライズされたURL、ルーティングモード、ストレージオプション、クッキー名、コンテンツ宣言の場所や拡張子、コンソールでのIntlayerログの無効化などを設定できます。利用可能なパラメータの完全なリストについては、[設定ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/configuration.md)を参照してください。
178
-
179
- ### ステップ 3: Vite 設定に Intlayer を統合する
180
-
181
- 設定に intlayer プラグインを追加します。
182
-
183
- ```typescript fileName="vite.config.ts" codeFormat="typescript"
184
- import { defineConfig } from "vite";
185
- import preact from "@preact/preset-vite";
186
- import { intlayer } from "vite-intlayer";
187
-
188
- // https://vitejs.dev/config/
189
- export default defineConfig({
190
- plugins: [preact(), intlayer()],
191
- });
192
- ```
193
-
194
- ```javascript fileName="vite.config.mjs" codeFormat="esm"
195
- import { defineConfig } from "vite";
196
- import preact from "@preact/preset-vite";
197
- import { intlayer } from "vite-intlayer";
198
-
199
- // https://vitejs.dev/config/
200
- export default defineConfig({
201
- plugins: [preact(), intlayer()],
202
- });
203
- ```
204
-
205
- ```javascript fileName="vite.config.cjs" codeFormat="commonjs"
206
- const { defineConfig } = require("vite");
207
- const preact = require("@preact/preset-vite");
208
- const { intlayer } = require("vite-intlayer");
209
-
210
- // https://vitejs.dev/config/
211
- module.exports = defineConfig({
212
- plugins: [preact(), intlayer()],
213
- });
214
- ```
215
-
216
- > `intlayer()` Viteプラグインは、IntlayerをViteと統合するために使用されます。これにより、コンテンツ宣言ファイルのビルドが保証され、開発モードで監視されます。また、Viteアプリケーション内でIntlayerの環境変数を定義します。さらに、パフォーマンス最適化のためのエイリアスも提供します。
217
-
218
- ### ステップ 4: コンテンツを宣言する
219
-
220
- 翻訳を格納するためのコンテンツ宣言を作成および管理します:
221
-
222
- ```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
223
- import { t, type Dictionary } from "intlayer";
224
- import type { ComponentChildren } from "preact";
225
-
226
- const appContent = {
227
- key: "app",
228
- content: {
229
- viteLogo: t({
230
- en: "Vite logo",
231
- fr: "Logo Vite",
232
- es: "Logo Vite",
233
- }),
234
- preactLogo: t({
235
- en: "Preact logo",
236
- fr: "Logo Preact",
237
- es: "Logo Preact",
238
- }),
239
-
240
- title: "Vite + Preact",
241
-
242
- count: t({
243
- en: "count is ",
244
- fr: "le compte est ",
245
- es: "el recuento es ",
246
- }),
247
-
248
- edit: t<ComponentChildren>({
249
- en: (
250
- <>
251
- Edit <code>src/app.tsx</code> and save to test HMR
252
- </>
253
- ),
254
- fr: (
255
- <>
256
- Éditez <code>src/app.tsx</code> et enregistrez pour tester HMR
257
- </>
258
- ),
259
- es: (
260
- <>
261
- Edita <code>src/app.tsx</code> y guarda para probar HMR
262
- </>
263
- ),
264
- }),
265
-
266
- readTheDocs: t({
267
- en: "Click on the Vite and Preact logos to learn more",
268
- fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
269
- es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
270
- }),
271
- },
272
- } satisfies Dictionary;
273
-
274
- export default appContent;
275
- ```
276
-
277
- ```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
278
- import { t } from "intlayer";
279
- // import { h } from 'preact'; // JSXを.mjsで直接使用する場合に必要
280
-
281
- /** @type {import('intlayer').Dictionary} */
282
- const appContent = {
283
- key: "app",
284
- content: {
285
- viteLogo: t({
286
- en: "Vite logo",
287
- fr: "Logo Vite",
288
- es: "Logo Vite",
289
- }),
290
- preactLogo: t({
291
- en: "Preact logo",
292
- fr: "Logo Preact",
293
- es: "Logo Preact",
294
- }),
295
-
296
- title: "Vite + Preact",
297
-
298
- count: t({
299
- en: "count is ",
300
- fr: "le compte est ",
301
- es: "el recuento es ",
302
- }),
303
-
304
- edit: t({
305
- en: "Edit src/app.jsx and save to test HMR",
306
- fr: "Éditez src/app.jsx et enregistrez pour tester HMR",
307
- es: "Edita src/app.jsx y guarda para probar HMR",
308
- }),
309
-
310
- readTheDocs: t({
311
- en: "Click on the Vite and Preact logos to learn more",
312
- fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
313
- es: "Haga clic en los logotipos de Vite et Preact pour obtenir plus d'informations",
314
- }),
315
- },
316
- };
317
-
318
- export default appContent;
319
- ```
320
-
321
- ```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
322
- const { t } = require("intlayer");
323
- // const { h } = require('preact'); // JSXを.cjsで直接使用する場合に必要
324
-
325
- /** @type {import('intlayer').Dictionary} */
326
- const appContent = {
327
- key: "app",
328
- content: {
329
- viteLogo: t({
330
- en: "Vite logo",
331
- fr: "Logo Vite",
332
- es: "Logo Vite",
333
- }),
334
- preactLogo: t({
335
- en: "Preact logo",
336
- fr: "Logo Preact",
337
- es: "Logo Preact",
338
- }),
339
-
340
- title: "Vite + Preact",
341
-
342
- count: t({
343
- en: "count is ",
344
- fr: "le compte est ",
345
- es: "el recuento es ",
346
- }),
347
-
348
- edit: t({
349
- en: "Edit src/app.tsx and save to test HMR",
350
- fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
351
- es: "Edita src/app.tsx y guarda para probar HMR",
352
- }),
353
-
354
- readTheDocs: t({
355
- en: "Click on the Vite and Preact logos to learn more",
356
- fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
357
- es: "Haga clic en los logotipos de Vite et Preact pour en savoir plus",
358
- }),
359
- },
360
- };
361
-
362
- module.exports = appContent;
363
- ```
364
-
365
- ```json fileName="src/app.content.json" contentDeclarationFormat="json"
366
- {
367
- "$schema": "https://intlayer.org/schema.json",
368
- "key": "app",
369
- "content": {
370
- "viteLogo": {
371
- "nodeType": "translation",
372
- "translation": {
373
- "en": "Vite logo",
374
- "fr": "Logo Vite",
375
- "es": "Logo Vite"
376
- }
377
- },
378
- "preactLogo": {
379
- "nodeType": "translation",
380
- "translation": {
381
- "en": "Preact logo",
382
- "fr": "Logo Preact",
383
- "es": "Logo Preact"
384
- }
385
- },
386
- "title": {
387
- "nodeType": "translation",
388
- "translation": {
389
- "en": "Vite + Preact",
390
- "fr": "Vite + Preact",
391
- "es": "Vite + Preact"
392
- }
393
- },
394
- "count": {
395
- "nodeType": "translation",
396
- "translation": {
397
- "en": "count is ",
398
- "fr": "le compte est ",
399
- "es": "el recuento es "
400
- }
401
- },
402
- "edit": {
403
- "nodeType": "translation",
404
- "translation": {
405
- "en": "Edit src/app.tsx and save to test HMR",
406
- "fr": "Éditez src/app.tsx et enregistrez pour tester HMR",
407
- "es": "Edita src/app.tsx y guarda para probar HMR"
408
- }
409
- },
410
- "readTheDocs": {
411
- "nodeType": "translation",
412
- "translation": {
413
- "en": "Click on the Vite and Preact logos to learn more",
414
- "fr": "Cliquez sur les logos Vite et Preact pour en savoir plus",
415
- "es": "Haga clic en los logotipos de Vite y Preact para obtener más información"
416
- }
417
- }
418
- }
419
- }
420
- ```
421
-
422
- > コンテンツ宣言は、`contentDir` ディレクトリ(デフォルトは `./src`)に含まれている限り、アプリケーションのどこにでも定義できます。また、コンテンツ宣言ファイルの拡張子(デフォルトは `.content.{json,ts,tsx,js,jsx,mjs,cjs}`)に一致する必要があります。
166
+ <Tabs>
167
+ <Tab value='抽出コマンド'>
423
168
 
424
- > 詳細については、[コンテンツ宣言のドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/content_file.md)を参照してください。
169
+ コンポーネントを変換してコンテンツを抽出するためにエクストラクタを実行します
425
170
 
426
- > コンテンツファイルに TSX コードが含まれている場合は、`import { h } from "preact";` をインポートするか、JSX プラグマが Preact 用に正しく設定されていることを確認する必要があります。
427
-
428
- ### ステップ 5: コード内で Intlayer を利用する
429
-
430
- アプリケーション全体でコンテンツ辞書にアクセスします:
431
-
432
- ```tsx {6,10} fileName="src/app.tsx" codeFormat="typescript"
433
- import { useState } from "preact/hooks";
434
- import type { FunctionalComponent } from "preact";
435
- import preactLogo from "./assets/preact.svg"; // preact.svgがあると仮定しています
436
- import viteLogo from "/vite.svg";
437
- import "./app.css"; // CSSファイルがapp.cssという名前であると仮定しています
438
- import { IntlayerProvider, useIntlayer } from "preact-intlayer";
439
-
440
- const AppContent: FunctionalComponent = () => {
441
- const [count, setCount] = useState(0);
442
- const content = useIntlayer("app");
443
-
444
- return (
445
- <>
446
- <div>
447
- <a href="https://vitejs.dev" target="_blank">
448
- <img src={viteLogo} class="logo" alt={content.viteLogo.value} />
449
- </a>
450
- <a href="https://preactjs.com" target="_blank">
451
- <img
452
- src={preactLogo}
453
- class="logo preact"
454
- alt={content.preactLogo.value}
455
- />
456
- </a>
457
- </div>
458
- <h1>{content.title}</h1>
459
- <div class="card">
460
- <button onClick={() => setCount((count) => count + 1)}>
461
- {content.count}
462
- {count}
463
- </button>
464
- <p>{content.edit}</p>
465
- </div>
466
- {/* Markdown コンテンツ */}
467
- <div>{content.myMarkdownContent}</div>
468
-
469
- {/* HTML コンテンツ */}
470
- <div>{content.myHtmlContent}</div>
471
-
472
- <p class="read-the-docs">{content.readTheDocs}</p>
473
- </>
474
- );
475
- };
476
-
477
- const App: FunctionalComponent = () => (
478
- <IntlayerProvider>
479
- <AppContent />
480
- </IntlayerProvider>
481
- );
482
-
483
- export default App;
484
- ```
485
-
486
- ```jsx {5,9} fileName="src/app.jsx" codeFormat="esm"
487
- import { useState } from "preact/hooks";
488
- import preactLogo from "./assets/preact.svg";
489
- import viteLogo from "/vite.svg";
490
- import "./app.css";
491
- import { IntlayerProvider, useIntlayer } from "preact-intlayer";
492
-
493
- const AppContent = () => {
494
- const [count, setCount] = useState(0);
495
- const content = useIntlayer("app");
496
-
497
- return (
498
- <>
499
- <div>
500
- <a href="https://vitejs.dev" target="_blank">
501
- <img src={viteLogo} class="logo" alt={content.viteLogo.value} />
502
- </a>
503
- <a href="https://preactjs.com" target="_blank">
504
- <img
505
- src={preactLogo}
506
- class="logo preact"
507
- alt={content.preactLogo.value}
508
- />
509
- </a>
510
- </div>
511
- <h1>{content.title}</h1>
512
- <div class="card">
513
- <button onClick={() => setCount((count) => count + 1)}>
514
- {content.count}
515
- {count}
516
- </button>
517
- <p>{content.edit}</p>
518
- </div>
519
- <p class="read-the-docs">{content.readTheDocs}</p>
520
- </>
521
- );
522
- };
523
-
524
- const App = () => (
525
- <IntlayerProvider>
526
- <AppContent />
527
- </IntlayerProvider>
528
- );
529
-
530
- export default App;
531
- ```
532
-
533
- ```jsx {5,9} fileName="src/app.cjsx" codeFormat="commonjs"
534
- const { useState } = require("preact/hooks");
535
- const preactLogo = require("./assets/preact.svg");
536
- const viteLogo = require("/vite.svg");
537
- require("./app.css");
538
- const { IntlayerProvider, useIntlayer } = require("preact-intlayer");
539
-
540
- const AppContent = () => {
541
- const [count, setCount] = useState(0);
542
- const content = useIntlayer("app");
543
-
544
- return (
545
- <>
546
- <div>
547
- <a href="https://vitejs.dev" target="_blank">
548
- <img src={viteLogo} class="logo" alt={content.viteLogo.value} />
549
- </a>
550
- <a href="https://preactjs.com" target="_blank">
551
- <img
552
- src={preactLogo}
553
- class="logo preact"
554
- alt={content.preactLogo.value}
555
- />
556
- </a>
557
- </div>
558
- <h1>{content.title}</h1>
559
- <div class="card">
560
- <button onClick={() => setCount((count) => count + 1)}>
561
- {content.count}
562
- {count}
563
- </button>
564
- <p>{content.edit}</p>
565
- </div>
566
- <p class="read-the-docs">{content.readTheDocs}</p>
567
- </>
568
- );
569
- };
570
-
571
- const App = () => (
572
- <IntlayerProvider>
573
- <AppContent />
574
- </IntlayerProvider>
575
- );
576
-
577
- module.exports = App;
578
- ```
579
-
580
- > コンテンツを `alt`、`title`、`href`、`aria-label` などの `string` 属性で使用したい場合は、関数の値を呼び出す必要があります。例:
581
-
582
- > ```jsx
583
- > <img src={content.image.src.value} alt={content.image.value} />
584
- > ```
585
-
586
- > 注意:Preact では、`className` は通常 `class` として記述されます。
587
-
588
- > `useIntlayer` フックの詳細については、[ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/react-intlayer/useIntlayer.md)を参照してください(`preact-intlayer` も同様の API です)。
589
-
590
- > アプリケーションが既に存在する場合は、[Intlayer コンパイラ](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/compiler.md) と [抽出コマンド](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/cli/extract.md) を組み合わせて、1 秒で何千ものコンポーネントを変換できます。
591
-
592
- ### (オプション)ステップ 6:コンテンツの言語を変更する
593
-
594
- コンテンツの言語を変更するには、`useLocale` フックが提供する `setLocale` 関数を使用します。この関数を使うことで、アプリケーションのロケールを設定し、それに応じてコンテンツを更新できます。
595
-
596
- ```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
597
- import type { FunctionalComponent } from "preact";
598
- import { Locales } from "intlayer";
599
- import { useLocale } from "preact-intlayer";
600
-
601
- const LocaleSwitcher: FunctionalComponent = () => {
602
- const { setLocale } = useLocale();
603
-
604
- return (
605
- <button onClick={() => setLocale(Locales.ENGLISH)}>
606
- Change Language to English
607
- </button>
608
- );
609
- };
610
-
611
- export default LocaleSwitcher;
612
- ```
613
-
614
- ```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
615
- import { Locales } from "intlayer";
616
- import { useLocale } from "preact-intlayer";
617
-
618
- const LocaleSwitcher = () => {
619
- const { setLocale } = useLocale();
620
-
621
- return (
622
- <button onClick={() => setLocale(Locales.ENGLISH)}>
623
- Change Language to English
624
- </button>
625
- );
626
- };
627
-
628
- export default LocaleSwitcher;
629
- ```
630
-
631
- ```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
632
- const { Locales } = require("intlayer");
633
- const { useLocale } = require("preact-intlayer");
634
-
635
- const LocaleSwitcher = () => {
636
- const { setLocale } = useLocale();
637
-
638
- return (
639
- <button onClick={() => setLocale(Locales.ENGLISH)}>
640
- Change Language to English
641
- </button>
642
- );
643
- };
644
-
645
- module.exports = LocaleSwitcher;
646
- ```
647
-
648
- > `useLocale` フックの詳細については、[ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/react-intlayer/useLocale.md)を参照してください(`preact-intlayer` でも同様のAPIです)。
649
-
650
- ### (オプション)ステップ 7: アプリケーションにローカライズされたルーティングを追加する
651
-
652
- このステップの目的は、各言語ごとにユニークなルートを作成することです。これはSEOやSEOに適したURLに役立ちます。
653
- 例:
654
-
655
- ```plaintext
656
- - https://example.com/about
657
- - https://example.com/es/about
658
- - https://example.com/fr/about
659
- ```
660
-
661
- > デフォルトでは、ルートはデフォルトロケールに対してプレフィックスが付きません。デフォルトロケールにもプレフィックスを付けたい場合は、設定の `routing.mode` オプションを `"prefix-all"` に設定できます。詳細は[設定ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/configuration.md)を参照してください。
662
-
663
- アプリケーションにローカライズされたルーティングを追加するには、アプリケーションのルートをラップし、ロケールベースのルーティングを処理する `LocaleRouter` コンポーネントを作成できます。以下は [preact-iso](https://github.com/preactjs/preact-iso) を使用した例です。
664
-
665
- ```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
666
- import { localeMap } from "intlayer";
667
- import { IntlayerProvider } from "preact-intlayer";
668
- import { LocationProvider, Router, Route } from "preact-iso";
669
- import type { ComponentChildren, FunctionalComponent } from "preact";
670
-
671
- /**
672
- * ロケール固有のルートを設定するルーターコンポーネント。
673
- * preact-isoを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
674
- */
675
- export const LocaleRouter: FunctionalComponent<{
676
- children: ComponentChildren;
677
- }> = ({ children }) => (
678
- <LocationProvider>
679
- <Router>
680
- {localeMap(({ locale, urlPrefix }) => ({ locale, urlPrefix }))
681
- .sort((a, b) => b.urlPrefix.length - a.urlPrefix.length)
682
- .map(({ locale, urlPrefix }) => (
683
- <Route
684
- key={locale}
685
- path={`${urlPrefix}/:rest*`}
686
- component={() => (
687
- <IntlayerProvider locale={locale}>{children}</IntlayerProvider>
688
- )}
689
- />
690
- ))}
691
- </Router>
692
- </LocationProvider>
693
- );
171
+ ```bash packageManager="npm"
172
+ npx intlayer extract
694
173
  ```
695
174
 
696
- ```jsx fileName="src/components/LocaleRouter.jsx" codeFormat="esm"
697
- import { localeMap } from "intlayer";
698
- import { IntlayerProvider } from "preact-intlayer";
699
- import { LocationProvider, Router, Route } from "preact-iso";
700
-
701
- /**
702
- * ロケール固有のルートを設定するルーターコンポーネント。
703
- * preact-isoを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
704
- */
705
- export const LocaleRouter = ({ children }) => (
706
- <LocationProvider>
707
- <Router>
708
- {localeMap(({ locale, urlPrefix }) => ({ locale, urlPrefix }))
709
- .sort((a, b) => b.urlPrefix.length - a.urlPrefix.length)
710
- .map(({ locale, urlPrefix }) => (
711
- <Route
712
- key={locale}
713
- path={`${urlPrefix}/:rest*`}
714
- component={() => (
715
- <IntlayerProvider locale={locale}>{children}</IntlayerProvider>
716
- )}
717
- />
718
- ))}
719
- </Router>
720
- </LocationProvider>
721
- );
175
+ ```bash packageManager="pnpm"
176
+ pnpm intlayer extract
722
177
  ```
723
178
 
724
- ```jsx fileName="src/components/LocaleRouter.cjsx" codeFormat="commonjs"
725
- const { localeMap } = require("intlayer");
726
- const { IntlayerProvider } = require("preact-intlayer");
727
- const { LocationProvider, Router, Route } = require("preact-iso");
728
-
729
- /**
730
- * ロケール固有のルートを設定するルーターコンポーネント。
731
- * preact-isoを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
732
- */
733
- const LocaleRouter = ({ children }) =>
734
- h(
735
- LocationProvider,
736
- {},
737
- h(
738
- Router,
739
- {},
740
- localeMap(({ locale, urlPrefix }) => ({ locale, urlPrefix }))
741
- .sort((a, b) => b.urlPrefix.length - a.urlPrefix.length)
742
- .map(({ locale, urlPrefix }) =>
743
- h(Route, {
744
- key: locale,
745
- path: `${urlPrefix}/:rest*`,
746
- component: () => h(IntlayerProvider, { locale }, children),
747
- })
748
- )
749
- )
750
- );
751
-
752
- module.exports = { LocaleRouter };
179
+ ```bash packageManager="yarn"
180
+ yarn intlayer extract
753
181
  ```
754
182
 
755
- 次に、アプリケーション内で `LocaleRouter` コンポーネントを使用できます:
756
-
757
- ```tsx fileName="src/app.tsx" codeFormat="typescript"
758
- import { LocaleRouter } from "./components/LocaleRouter";
759
- import type { FunctionalComponent } from "preact";
760
-
761
- // ... AppContent コンポーネント
762
-
763
- const App: FunctionalComponent = () => (
764
- <LocaleRouter>
765
- <AppContent />
766
- </LocaleRouter>
767
- );
768
-
769
- export default App;
183
+ ```bash packageManager="bun"
184
+ bunx intlayer extract
770
185
  ```
771
186
 
772
- ```jsx fileName="src/app.jsx" codeFormat="esm"
773
- import { LocaleRouter } from "./components/LocaleRouter";
774
-
775
- // ... AppContent コンポーネント
187
+ </Tab>
188
+ <Tab value='Babelコンパイラ'>
776
189
 
777
- const App = () => (
778
- <LocaleRouter>
779
- <AppContent />
780
- </LocaleRouter>
781
- );
782
-
783
- export default App;
190
+ ```bash packageManager="npm"
191
+ npm install @intlayer/babel --save-dev
784
192
  ```
785
193
 
786
- ```jsx fileName="src/app.cjsx" codeFormat="commonjs"
787
- const { LocaleRouter } = require("./components/LocaleRouter");
788
-
789
- // ... AppContent コンポーネント
790
-
791
- const App = () => (
792
- <LocaleRouter>
793
- <AppContent />
794
- </LocaleRouter>
795
- );
796
-
797
- module.exports = App;
194
+ ```bash packageManager="pnpm"
195
+ pnpm add @intlayer/babel --save-dev
798
196
  ```
799
197
 
800
- ### (オプション)ステップ 8: ロケールが変更されたときに URL を変更する
801
-
802
- ロケールが変更されたときに URL を変更するには、`useLocale` フックが提供する `onLocaleChange` プロパティを使用できます。同時に、`preact-iso` の `useLocation` から `route` メソッドを使用して URL パスを更新できます。
803
-
804
- ```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
805
- import { useLocation } from "preact-iso";
806
- import {
807
- Locales,
808
- getHTMLTextDir,
809
- getLocaleName,
810
- getLocalizedUrl,
811
- } from "intlayer";
812
- import { useLocale } from "preact-intlayer";
813
- import type { FunctionalComponent } from "preact";
814
-
815
- const LocaleSwitcher: FunctionalComponent = () => {
816
- const { url, route } = useLocation();
817
- const { locale, availableLocales, setLocale } = useLocale({
818
- onLocaleChange: (newLocale) => {
819
- // 更新されたロケールで URL を構築
820
- // 例: /es/about?foo=bar
821
- const pathWithLocale = getLocalizedUrl(url, newLocale);
822
-
823
- // URL パスを更新
824
- route(pathWithLocale, true); // true は置換(replace)
825
- },
826
- });
827
-
828
- return (
829
- <div>
830
- <button popovertarget="localePopover">{getLocaleName(locale)}</button>
831
- <div id="localePopover" popover="auto">
832
- {availableLocales.map((localeItem) => (
833
- <a
834
- href={getLocalizedUrl(url, localeItem)}
835
- hreflang={localeItem}
836
- aria-current={locale === localeItem ? "page" : undefined}
837
- onClick={(e) => {
838
- e.preventDefault();
839
- setLocale(localeItem);
840
- // ロケール設定後のプログラムによるナビゲーションは onLocaleChange で処理されます
841
- }}
842
- key={localeItem}
843
- >
844
- <span>
845
- {/* ロケール - 例: FR */}
846
- {localeItem}
847
- </span>
848
- <span>
849
- {/* その言語自身のロケールでの名称 - 例: Français */}
850
- {getLocaleName(localeItem, localeItem)}
851
- </span>
852
- <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
853
- {/* 現在のロケールでの言語名称 - 例: 現在のロケールが Locales.SPANISH の場合 Francés */}
854
- {getLocaleName(localeItem, locale)}
855
- </span>
856
- <span dir="ltr" lang={Locales.ENGLISH}>
857
- {/* 英語での名称 - 例: French */}
858
- {getLocaleName(localeItem, Locales.ENGLISH)}
859
- </span>
860
- </a>
861
- ))}
862
- </div>
863
- </div>
864
- );
865
- };
866
-
867
- export default LocaleSwitcher;
198
+ ```bash packageManager="yarn"
199
+ yarn add @intlayer/babel --save-dev
868
200
  ```
869
201
 
870
- ```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
871
- import { useLocation } from "preact-iso";
872
- import {
873
- Locales,
874
- getHTMLTextDir,
875
- getLocaleName,
876
- getLocalizedUrl,
877
- } from "intlayer";
878
- import { useLocale } from "preact-intlayer";
879
-
880
- const LocaleSwitcher = () => {
881
- const { url, route } = useLocation();
882
- const { locale, availableLocales, setLocale } = useLocale({
883
- onLocaleChange: (newLocale) => {
884
- const pathWithLocale = getLocalizedUrl(url, newLocale);
885
- route(pathWithLocale, true);
886
- },
887
- });
888
-
889
- return (
890
- <div>
891
- <button popovertarget="localePopover">{getLocaleName(locale)}</button>
892
- <div id="localePopover" popover="auto">
893
- {availableLocales.map((localeItem) => (
894
- <a
895
- href={getLocalizedUrl(url, localeItem)}
896
- hreflang={localeItem}
897
- aria-current={locale === localeItem ? "page" : undefined}
898
- onClick={(e) => {
899
- e.preventDefault();
900
- setLocale(localeItem);
901
- }}
902
- key={localeItem}
903
- >
904
- <span>{localeItem}</span>
905
- <span>{getLocaleName(localeItem, localeItem)}</span>
906
- <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
907
- {getLocaleName(localeItem, locale)}
908
- </span>
909
- <span dir="ltr" lang={Locales.ENGLISH}>
910
- {getLocaleName(localeItem, Locales.ENGLISH)}
911
- </span>
912
- </a>
913
- ))}
914
- </div>
915
- </div>
916
- );
917
- };
918
-
919
- export default LocaleSwitcher;
202
+ ```bash packageManager="bun"
203
+ bun add @intlayer/babel --dev
920
204
  ```
921
205
 
922
- ```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
923
- const { useLocation } = require("preact-iso");
206
+ ```js fileName="babel.config.js"
924
207
  const {
925
- Locales,
926
- getHTMLTextDir,
927
- getLocaleName,
928
- getLocalizedUrl,
929
- } = require("intlayer");
930
- const { useLocale } = require("preact-intlayer");
931
-
932
- const LocaleSwitcher = () => {
933
- const { url, route } = useLocation();
934
- const { locale, availableLocales, setLocale } = useLocale({
935
- onLocaleChange: (newLocale) => {
936
- const pathWithLocale = getLocalizedUrl(url, newLocale);
937
- route(pathWithLocale, true);
938
- },
939
- });
940
-
941
- return h(
942
- "div",
943
- {},
944
- h("button", { popovertarget: "localePopover" }, getLocaleName(locale)),
945
- h(
946
- "div",
947
- { id: "localePopover", popover: "auto" },
948
- availableLocales.map((localeItem) =>
949
- h(
950
- "a",
951
- {
952
- href: getLocalizedUrl(url, localeItem),
953
- hreflang: localeItem,
954
- "aria-current": locale === localeItem ? "page" : undefined,
955
- onClick: (e) => {
956
- e.preventDefault();
957
- setLocale(localeItem);
958
- },
959
- key: localeItem,
960
- },
961
- h("span", {}, localeItem),
962
- h("span", {}, getLocaleName(localeItem, localeItem)),
963
- h(
964
- "span",
965
- { dir: getHTMLTextDir(localeItem), lang: localeItem },
966
- getLocaleName(localeItem, locale)
967
- ),
968
- h(
969
- "span",
970
- { dir: "ltr", lang: Locales.ENGLISH },
971
- getLocaleName(localeItem, Locales.ENGLISH)
972
- )
973
- )
974
- )
975
- )
976
- );
977
- };
978
-
979
- module.exports = LocaleSwitcher;
980
- ```
981
-
982
- > ドキュメント参照:
983
- >
984
- > > - [`useLocale` フック](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/react-intlayer/useLocale.md)(API は `preact-intlayer` でも同様です)> - [`getLocaleName` フック](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/intlayer/getLocaleName.md)> - [`getLocalizedUrl` フック](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/intlayer/getLocalizedUrl.md)> - [`getHTMLTextDir` フック](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/packages/intlayer/getHTMLTextDir.md)> - [`hreflang` 属性](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=ja)> - [`lang` 属性](https://developer.mozilla.org/ja/docs/Web/HTML/Global_attributes/lang)> - [`dir` 属性](https://developer.mozilla.org/ja/docs/Web/HTML/Global_attributes/dir)> - [`aria-current` 属性](https://developer.mozilla.org/ja/docs/Web/Accessibility/ARIA/Attributes/aria-current)> - [Popover API](https://developer.mozilla.org/ja/docs/Web/API/Popover_API)
985
-
986
- ### (オプション)ステップ 9: HTML の言語属性と言語方向属性を切り替える
987
-
988
- アプリケーションが複数言語に対応している場合、`<html>` タグの `lang` 属性と `dir` 属性を現在のロケールに合わせて更新することが非常に重要です。これにより以下が保証されます:
989
-
990
- - **アクセシビリティ**: スクリーンリーダーや支援技術は、正しい `lang` 属性に依存してコンテンツを正確に発音・解釈します。
991
- - **テキストのレンダリング**: `dir`(方向)属性は、テキストが正しい順序(例:英語は左から右、アラビア語やヘブライ語は右から左)で表示されることを保証します。これは読みやすさに不可欠です。
992
- - **SEO**: 検索エンジンは `lang` 属性を使用してページの言語を判断し、適切なローカライズされたコンテンツを検索結果に表示するのに役立てます。
993
-
994
- これらの属性をロケール変更時に動的に更新することで、サポートされているすべての言語においてユーザーに一貫したアクセシブルな体験を提供できます。
995
-
996
- #### フックの実装
997
-
998
- HTML 属性を管理するためのカスタムフックを作成します。このフックはロケールの変更を監視し、それに応じて属性を更新します:
999
-
1000
- ```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
1001
- import { useEffect } from "preact/hooks";
1002
- import { useLocale } from "preact-intlayer";
1003
- import { getHTMLTextDir } from "intlayer";
1004
-
1005
- /**
1006
- * 現在のロケールに基づいて HTML の <html> 要素の `lang` と `dir` 属性を更新します。
1007
- * - `lang`: ブラウザや検索エンジンにページの言語を通知します。
1008
- * - `dir`: 正しい読み順(例:英語は 'ltr'、アラビア語は 'rtl')を保証します。
1009
- *
1010
- * この動的な更新は、適切なテキストレンダリング、アクセシビリティ、および SEO に不可欠です。
1011
- */
1012
- export const useI18nHTMLAttributes = () => {
1013
- const { locale } = useLocale();
1014
-
1015
- useEffect(() => {
1016
- // 言語属性を現在のロケールに更新します。
1017
- document.documentElement.lang = locale;
1018
-
1019
- // 現在のロケールに基づいてテキストの方向を設定します。
1020
- document.documentElement.dir = getHTMLTextDir(locale);
1021
- }, [locale]);
1022
- };
1023
- ```
1024
-
1025
- ```jsx fileName="src/hooks/useI18nHTMLAttributes.jsx" codeFormat="esm"
1026
- import { useEffect } from "preact/hooks";
1027
- import { useLocale } from "preact-intlayer";
1028
- import { getHTMLTextDir } from "intlayer";
1029
-
1030
- /**
1031
- * 現在のロケールに基づいて HTML の <html> 要素の `lang` と `dir` 属性を更新します。
1032
- */
1033
- export const useI18nHTMLAttributes = () => {
1034
- const { locale } = useLocale();
1035
-
1036
- useEffect(() => {
1037
- document.documentElement.lang = locale;
1038
- document.documentElement.dir = getHTMLTextDir(locale);
1039
- }, [locale]);
1040
- };
1041
- ```
1042
-
1043
- ```jsx fileName="src/hooks/useI18nHTMLAttributes.cjsx" codeFormat="commonjs"
1044
- const { useEffect } = require("preact/hooks");
1045
- const { useLocale } = require("preact-intlayer");
1046
- const { getHTMLTextDir } = require("intlayer");
1047
-
1048
- /**
1049
- * 現在のロケールに基づいて HTML の <html> 要素の `lang` と `dir` 属性を更新します。
1050
- */
1051
- const useI18nHTMLAttributes = () => {
1052
- const { locale } = useLocale();
1053
-
1054
- useEffect(() => {
1055
- document.documentElement.lang = locale;
1056
- document.documentElement.dir = getHTMLTextDir(locale);
1057
- }, [locale]);
1058
- };
1059
-
1060
- module.exports = { useI18nHTMLAttributes };
1061
- ```
1062
-
1063
- #### アプリケーションでのフックの使用
1064
-
1065
- ロケールが変更されるたびに HTML 属性が更新されるように、メインコンポーネントにフックを統合します:
1066
-
1067
- ```tsx fileName="src/app.tsx" codeFormat="typescript"
1068
- import type { FunctionalComponent } from "preact";
1069
- import { IntlayerProvider } from "preact-intlayer"; // AppContent で必要なら useIntlayer は既にインポートされています
1070
- import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
1071
- import "./app.css";
1072
- // ステップ 5 の AppContent 定義
1073
-
1074
- const AppWithHooks: FunctionalComponent = () => {
1075
- // ロケールに基づいて <html> タグの lang と dir 属性を更新するためにフックを適用します。
1076
- useI18nHTMLAttributes();
1077
-
1078
- // AppContent がステップ 5 のメインコンテンツ表示コンポーネントであると仮定します
1079
- return <AppContent />;
1080
- };
1081
-
1082
- const App: FunctionalComponent = () => (
1083
- <IntlayerProvider>
1084
- <AppWithHooks />
1085
- </IntlayerProvider>
1086
- );
1087
-
1088
- export default App;
1089
- ```
1090
-
1091
- ```jsx fileName="src/app.jsx" codeFormat="esm"
1092
- import { IntlayerProvider } from "preact-intlayer";
1093
- import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
1094
- import "./app.css";
1095
- // ステップ 5 の AppContent 定義
1096
-
1097
- const AppWithHooks = () => {
1098
- useI18nHTMLAttributes();
1099
- return <AppContent />;
1100
- };
1101
-
1102
- const App = () => (
1103
- <IntlayerProvider>
1104
- <AppWithHooks />
1105
- </IntlayerProvider>
1106
- );
1107
-
1108
- export default App;
1109
- ```
1110
-
1111
- ```jsx fileName="src/app.cjsx" codeFormat="commonjs"
1112
- const { IntlayerProvider } = require("preact-intlayer");
1113
- const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
1114
- require("./app.css");
1115
- // ステップ 5 の AppContent 定義
1116
-
1117
- const AppWithHooks = () => {
1118
- useI18nHTMLAttributes();
1119
- return <AppContent />;
208
+ intlayerExtractBabelPlugin,
209
+ getExtractPluginOptions,
210
+ } = require("@intlayer/babel");
211
+
212
+ module.exports = {
213
+ presets: ["next/babel"],
214
+ plugins: [
215
+ // コンポーネントから辞書へコンテンツを抽出する
216
+ [intlayerExtractBabelPlugin, getExtractPluginOptions()],
217
+ ],
1120
218
  };
1121
-
1122
- const App = () => (
1123
- <IntlayerProvider>
1124
- <AppWithHooks />
1125
- </IntlayerProvider>
1126
- );
1127
-
1128
- module.exports = App;
1129
219
  ```
1130
220
 
1131
- ### (オプション)ステップ 10: ローカライズされたリンクコンポーネントの作成
1132
-
1133
- アプリケーションのナビゲーションが現在のロケールを尊重するようにするために、カスタムの `Link` コンポーネントを作成できます。このコンポーネントは内部 URL に現在の言語を自動的にプレフィックスとして付加します。
1134
-
1135
- この動作は以下の理由で役立ちます:
1136
-
1137
- - **SEO とユーザー体験**: ローカライズされた URL は、検索エンジンが言語固有のページを正しくインデックスするのを助け、ユーザーに好みの言語でコンテンツを提供します。
1138
- - **一貫性**: アプリケーション全体でローカライズされたリンクを使用することで、ナビゲーションが現在のロケール内に留まることを保証し、予期しない言語の切り替えを防ぎます。
1139
- - **保守性**: ローカリゼーションのロジックを単一のコンポーネントに集約することで、URL の管理が簡素化されます。
1140
-
1141
- 以下は、Preact におけるローカライズされた `Link` コンポーネントの実装です:
1142
-
1143
- ```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
1144
- import { getLocalizedUrl } from "intlayer";
1145
- import { useLocale } from "preact-intlayer";
1146
- import { forwardRef } from "preact/compat";
1147
- import type { JSX } from "preact";
1148
-
1149
- export interface LinkProps extends JSX.HTMLAttributes<HTMLAnchorElement> {
1150
- href: string;
1151
- }
1152
-
1153
- /**
1154
- * 指定された URL が外部のものかどうかをチェックするユーティリティ関数。
1155
- * URL が http:// または https:// で始まる場合、外部とみなされます。
1156
- */
1157
- export const checkIsExternalLink = (href?: string): boolean =>
1158
- /^https?:\/\//.test(href ?? "");
1159
-
1160
- /**
1161
- * 現在のロケールに基づいて href 属性を適応させるカスタム Link コンポーネント。
1162
- * 内部リンクの場合、`getLocalizedUrl` を使用して URL にロケールをプレフィックス(例:/fr/about)します。
1163
- * これにより、ナビゲーションが同じロケールコンテキスト内に留まることが保証されます。
1164
- */
1165
- export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
1166
- ({ href, children, ...props }, ref) => {
1167
- const { locale } = useLocale();
1168
- const isExternalLink = checkIsExternalLink(href);
1169
-
1170
- // 内部リンクであり、有効な href が提供されている場合、ローカライズされた URL を取得します。
1171
- const hrefI18n =
1172
- href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
1173
-
1174
- return (
1175
- <a href={hrefI18n} ref={ref} {...props}>
1176
- {children}
1177
- </a>
1178
- );
1179
- }
1180
- );
1181
-
1182
- Link.displayName = "Link";
1183
- ```
1184
-
1185
- ```jsx fileName="src/components/Link.jsx" codeFormat="esm"
1186
- import { getLocalizedUrl } from "intlayer";
1187
- import { useLocale } from "preact-intlayer";
1188
- import { forwardRef } from "preact/compat";
1189
-
1190
- /**
1191
- * 指定された URL が外部のものかどうかをチェックするユーティリティ関数。
1192
- * URL が http:// または https:// で始まる場合、外部とみなされます。
1193
- */
1194
- export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
1195
-
1196
- /**
1197
- * 現在のロケールに基づいて href 属性を適応させるカスタム Link コンポーネント。
1198
- * 内部リンクの場合、`getLocalizedUrl` を使用して URL にロケールをプレフィックス(例:/fr/about)します。
1199
- * これにより、ナビゲーションが同じロケールコンテキスト内に留まることが保証されます。
1200
- */
1201
- export const Link = forwardRef(({ href, children, ...props }, ref) => {
1202
- const { locale } = useLocale();
1203
- const isExternalLink = checkIsExternalLink(href);
1204
-
1205
- // 内部リンクであり、有効な href が提供されている場合、ローカライズされた URL を取得します。
1206
- const hrefI18n =
1207
- href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
1208
-
1209
- return (
1210
- <a href={hrefI18n} ref={ref} {...props}>
1211
- {children}
1212
- </a>
1213
- );
1214
- });
1215
-
1216
- Link.displayName = "Link";
1217
- ```
1218
-
1219
- ```jsx fileName="src/components/Link.cjsx" codeFormat="commonjs"
1220
- const { getLocalizedUrl } = require("intlayer");
1221
- const { useLocale } = require("preact-intlayer");
1222
- const { forwardRef } = require("preact/compat");
1223
-
1224
- /**
1225
- * 指定された URL が外部のものかどうかをチェックするユーティリティ関数。
1226
- * URL が http:// または https:// で始まる場合、外部とみなされます。
1227
- */
1228
- const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
1229
-
1230
- /**
1231
- * 現在のロケールに基づいて href 属性を適応させるカスタム Link コンポーネント。
1232
- * 内部リンクの場合、`getLocalizedUrl` を使用して URL にロケールをプレフィックス(例:/fr/about)します。
1233
- * これにより、ナビゲーションが同じロケールコンテキスト内に留まることが保証されます。
1234
- */
1235
- const Link = forwardRef(({ href, children, ...props }, ref) => {
1236
- const { locale } = useLocale();
1237
- const isExternalLink = checkIsExternalLink(href);
1238
-
1239
- // 内部リンクであり、有効な href が提供されている場合、ローカライズされた URL を取得します。
1240
- const hrefI18n =
1241
- href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
1242
-
1243
- return h(
1244
- "a",
1245
- {
1246
- href: hrefI18n,
1247
- ref: ref,
1248
- ...props,
1249
- },
1250
- children
1251
- );
1252
- });
1253
-
1254
- Link.displayName = "Link";
1255
-
1256
- module.exports = { Link, checkIsExternalLink };
221
+ ```bash packageManager="npm"
222
+ npm run build # または npm run dev
1257
223
  ```
1258
224
 
1259
- #### 動作の仕組み
1260
-
1261
- - **外部リンクの検出**:
1262
- ヘルパー関数 `checkIsExternalLink` は、URL が外部かどうかを判断します。外部リンクはローカライズの必要がないため、変更されません。
1263
- - **現在のロケールの取得**:
1264
- `useLocale` フックは現在のロケール(例:フランス語なら `fr`)を提供します。
1265
- - **URL のローカライズ**:
1266
- 内部リンク(非外部リンク)の場合、`getLocalizedUrl` を使用して、現在のロケールを URL の先頭に自動的に付加します。つまり、ユーザーがフランス語環境にいる場合、`/about` を `href` として渡すと `/fr/about` に変換されます。
1267
- - **リンクの返却**:
1268
- コンポーネントはローカライズされた URL を持つ `<a>` 要素を返し、ナビゲーションがロケールと一貫していることを保証します。
1269
-
1270
- ### (オプション)ステップ 11: Markdown と HTML のレンダリング
1271
-
1272
- Intlayer は Preact での Markdown と HTML コンテンツのレンダリングをサポートしています。
1273
-
1274
- `.use()` メソッドを使用して、Markdown および HTML コンテンツのレンダリングをカスタマイズできます。このメソッドを使用すると、特定のタグのデフォルトのレンダリングを上書きできます。
1275
-
1276
- ```tsx
1277
- import { useIntlayer } from "preact-intlayer";
1278
-
1279
- const { myMarkdownContent, myHtmlContent } = useIntlayer("my-component");
1280
-
1281
- // ...
1282
-
1283
- return (
1284
- <div>
1285
- {/* 基本的なレンダリング */}
1286
- {myMarkdownContent}
1287
-
1288
- {/* Markdown のカスタムレンダリング */}
1289
- {myMarkdownContent.use({
1290
- h1: (props) => <h1 style={{ color: "red" }} {...props} />,
1291
- })}
1292
-
1293
- {/* HTML の基本的なレンダリング */}
1294
- {myHtmlContent}
1295
-
1296
- {/* HTML のカスタムレンダリング */}
1297
- {myHtmlContent.use({
1298
- b: (props) => <strong style={{ color: "blue" }} {...props} />,
1299
- })}
1300
- </div>
1301
- );
225
+ ```bash packageManager="pnpm"
226
+ pnpm run build # または pnpm run dev
1302
227
  ```
1303
228
 
1304
- ### TypeScript の設定
1305
-
1306
- Intlayer はモジュール拡張を使用して TypeScript の利点を得て、コードベースをより強固にします。
1307
-
1308
- ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1309
-
1310
- ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1311
-
1312
- TypeScript 設定に自動生成された型が含まれていることを確認してください。
1313
-
1314
- ```json5 fileName="tsconfig.json"
1315
- {
1316
- // ... 既存の TypeScript 設定
1317
- "compilerOptions": {
1318
- // ...
1319
- "jsx": "react-jsx",
1320
- "jsxImportSource": "preact", // Preact 10+ に推奨
1321
- // ...
1322
- },
1323
- "include": [
1324
- // ... 既存の TypeScript 設定
1325
- ".intlayer/**/*.ts", // 自動生成された型を含める
1326
- ],
1327
- }
229
+ ```bash packageManager="yarn"
230
+ yarn build # または yarn dev
1328
231
  ```
1329
232
 
1330
- > `tsconfig.json` が Preact 用に設定されていることを確認してください。特に `jsx` と `jsxImportSource`、または `preset-vite` のデフォルトを使用していない場合は古い Preact バージョン用の `jsxFactory`/`jsxFragmentFactory` を確認してください。
1331
-
1332
- ### Git 設定
1333
-
1334
- Intlayer によって生成されたファイルを無視することをお勧めします。これにより、それらを Git リポジトリにコミットすることを避けることができます。
1335
-
1336
- これを行うには、`.gitignore` ファイルに以下の指示を追加できます:
1337
-
1338
- ```plaintext
1339
- # Ignore the files generated by Intlayer
1340
- .intlayer
233
+ ```bash packageManager="bun"
234
+ bun run build # Or bun run dev
1341
235
  ```
1342
236
 
1343
- ### VS Code 拡張機能
1344
-
1345
- Intlayer での開発体験を向上させるために、公式の **Intlayer VS Code 拡張機能** をインストールできます。
1346
-
1347
- [VS Code Marketplace からインストール](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
1348
-
1349
- この拡張機能は以下を提供します:
1350
-
1351
- - 翻訳キーの **オートコンプリート**。
1352
- - 翻訳漏れの **リアルタイムエラー検出**。
1353
- - 翻訳されたコンテンツの **インラインプレビュー**。
1354
- - 翻訳を簡単に作成・更新できる **クイックアクション**。
1355
-
1356
- 拡張機能の使用方法の詳細については、[Intlayer VS Code 拡張機能のドキュメント](https://intlayer.org/doc/vs-code-extension)を参照してください。
1357
-
1358
- ---
237
+ </Tab>
238
+ </Tabs>
1359
239
 
1360
240
  ### さらに進む
1361
241