התחלה
התקנה
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 שהקמנו, שניתן לבדוק כאן.