はじめに
インストール
To install TacoTranslate in your application, open your terminal and navigate to the root directory of your project. Then, run the following command to install with npm:
npm install tacotranslateThis assumes you already have an application set up. See examples for more information.
基本的な使い方
以下の例では、TacoTranslate クライアントを作成し、アプリケーションを TacoTranslate プロバイダーでラップし、Translate コンポーネントを使用して翻訳された文字列を表示する方法を示します。
import createTacoTranslateClient from 'tacotranslate';
import {TacoTranslate, Translate} from 'tacotranslate/react';
const tacoTranslateClient = createTacoTranslateClient({apiKey: 'YOUR_API_KEY'});
function Page() {
return <Translate string="Hello, world!" />;
}
export default function App() {
return (
<TacoTranslate client={tacoTranslateClient} locale="es">
<Page />
</TacoTranslate>
);
}この例はスペイン語(locale="es")に設定されているため、 Translate コンポーネントは "¡Hola, mundo!" を出力します。
例
当社の GitHub サンプルフォルダ にアクセスして、例えば Next.js App Router を使う場合や Create React App を利用する場合など、特定のユースケース向けに TacoTranslate を設定する方法について詳しく学んでください。
また、CodeSandbox を用意しており、こちらでご覧いただけます。