作成:2024-08-11最終更新:2025-06-29
このドキュメントをあなたの好きなAIアシスタントに参照してくださいChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
このページとあなたの好きなAIアシスタントを使ってドキュメントを要約します
このページのコンテンツは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 統合: useIntlayer フック ドキュメント
このセクションでは、React アプリケーション内で useIntlayer フックを使用する方法について詳しく説明し、効率的なコンテンツのローカライズを可能にします。
Reactでの使用例
Reactコンポーネント内でのuseIntlayerフックの使用例:
src/app.tsx
コードをコピー
コードをクリップボードにコピー
import type { FC } from "react";
import { ClientComponentExample, ServerComponentExample } from "@components";
import { IntlayerProvider } from "react-intlayer";
import { useIntlayer, IntlayerServerProvider } from "react-intlayer/server";
import { Locales } from "intlayer";
const App: FC<{ locale: Locales }> = ({ locale }) => {
const content = useIntlayer("homepage", locale);
return (
<>
<p>{content.introduction}</p>
<IntlayerProvider locale={locale}>
<ClientComponentExample />
</IntlayerProvider>
<IntlayerServerProvider locale={locale}>
<ServerComponentExample />
</IntlayerServerProvider>
</>
);
};src/components/ComponentExample.tsx
コードをコピー
コードをクリップボードにコピー
import type { FC } from "react";
import { useIntlayer } from "react-intlayer";
const ComponentExample: FC = () => {
const content = useIntlayer("component-example");
return (
<div>
<h1>{content.title}</h1>
<p>{content.description}</p>
</div>
);
};src/components/ServerComponentExample.tsx
コードをコピー
コードをクリップボードにコピー
import { useIntlayer } from "react-intlayer/server";jsx fileName="src/components/ServerComponentExample.csx" codeFormat="commonjs"const { useIntlayer } = require("react-intlayer/server");const ServerComponentExample = () => { const content = useIntlayer("server-component"); return ( <div> <h1>{content.title}</h1> <p>{content.description}</p> </div> );};追加リソース
- Intlayer ビジュアルエディター: より直感的なコンテンツ管理体験のために、ビジュアルエディターのドキュメントはこちらをご参照ください。
このセクションは特に、Reactアプリケーションにおける useIntlayer フックの統合に焦点を当てており、ローカライズプロセスを簡素化し、異なるロケール間でのコンテンツの一貫性を確保します。