はじめに
インストール
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!" を出力します。
例
ユースケースに合わせた TacoTranslate のセットアップ方法(例えば Next.js App Router の利用や Create React App を使う場合など)について詳しく知るには、当社の GitHub examples フォルダ にアクセスしてください。
また、CodeSandbox を用意しており、こちらでご覧いただけます。