Getting started
Installation
To install TacoTranslate in your project, open your terminal and navigate to the root directory of your project. Then, run the following command to install with npm:
npm install tacotranslate
This assumes you already have a project set up. See examples for more information.
Basic usage
The below example demonstrates how to create a TacoTranslate client, wrap your application with the TacoTranslate
provider, and use the Translate
component to display translated strings.
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>
);
}
The example is set to use Spanish (locale="es"
), so the Translate
component will output "¡Hola, mundo!".
Examples
Head on over to our GitHub examples folder to learn more about how to set up TacoTranslate specifically for your use case, such as with the Next.js App Router, or using Create React App.
We also have a CodeSandbox set up that you can check out here.