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