ආරම්භ කිරීම
ස්ථාපනය
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 උදාහරණ ෆෝල්ඩරයට පිවිසෙන්න.
අපටත් CodeSandbox එකක් සකසා ඇත; ඔබ එය මෙතැනින් පරීක්ෂා කළ හැක.