作成:2026-06-13最終更新:2026-06-13
このドキュメントをあなたの好きなAIアシスタントに参照してくださいChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
このページとあなたの好きなAIアシスタントを使ってドキュメントを要約します
バージョン履歴
- "Init history"v9.0.02026/6/13
このページのコンテンツはAIを使用して翻訳されました。
英語の元のコンテンツの最新バージョンを見るEdit this doc
If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy
Copy doc Markdown to clipboard
react-i18next から Intlayer への移行
完全で詳細なステップバイステップチュートリアルについては、react-i18next 移行ガイドをご覧ください。
Intlayer の compat adapter を使用することで、ソースコードのインポート変更なしに react-i18next から移行できます。
何をするか
プロジェクトを初期化するには、次を実行します:
bash
コードをコピー
コードをクリップボードにコピー
npx intlayer init初期化中に、Intlayer は @intlayer/react-i18next をインストールし、intlayer.config.ts を作成します。バンドラー(Vite など)で、Intlayer プラグインを適用します:
vite.config.ts
コードをコピー
コードをクリップボードにコピー
import { defineConfig } from "vite";import react from "@vitejs/plugin-react";import { reactI18nextVitePlugin } from "@intlayer/react-i18next/plugin";export default defineConfig({ plugins: [react(), reactI18nextVitePlugin()],});内部的な動作
reactI18nextVitePlugin は、コアの vite-intlayer プラグインをラップし、react-i18next と i18next のリゾルブエイリアスを注入して、@intlayer/react-i18next と @intlayer/i18next にリダイレクトします。
内部的には:
useTranslation&withTranslation: Intlayer のネイティブフックを使用するように書き直されており、辞書キーの自動 TypeScript 補完を提供します。namespaces をシームレスにサポートしています (例:t('namespace:key'))。- Plurals & Context: i18next のサフィックスベースの複数形処理 (
key_one、key_other) をネイティブIntl.PluralRulesとコンテキストサフィックス (key_male) を使用して処理します。 <Trans>Component:componentsプロップ、object と array の形式、および番号付きタグ<1>...</1>をサポートするように再実装され、React ノードに直接マップされます。i18ninstance: 大規模な JSON ファイルを取得せずに Intlayer からキーを直接リゾルブするため、バンドルサイズが大幅に削減されます。