התחלה
התקנה
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 כדי ללמוד עוד על האופן שבו ניתן להגדיר את TacoTranslate במיוחד עבור מקרה השימוש שלך, למשל עם Next.js App Router, או באמצעות Create React App.
בנוסף, יש לנו CodeSandbox שהגדרנו שתוכלו לצפות בו כאן.