Initialization
After installing the AutoLocalise SDK, you need to initialize it with your API key. This guide will walk you through the initialization process for different platforms.
Getting Your API Key
To use AutoLocalise, you'll need an API key. You can get one by:
- Creating an account on the AutoLocalise Dashboard
- Creating a new project
- Copying the API key from your project token tab
Initialization
Based on your platform, wrap your app or root layout with the TranslationProvider component:
import { TranslationProvider } from "react-autolocalise";
const App = () => {
return (
<TranslationProvider
config={{
apiKey: "your-api-key",
sourceLocale: "en", // Your source language
targetLocale: "fr", // The language to translate to
}}
>
<YourApp />
</TranslationProvider>
);
};
The TranslationProvider makes translations available throughout your application.
- For NextJs Server Side rendering, follow guide here
Configuration Options
The config object accepts the following properties:
- apiKey (required): Your AutoLocalise API key
- sourceLocale (required): The language your content is written in
- targetLocale (required): The language to translate to, refer Language Support
- cacheTTL (optional): Cache validity in hours (defaults to 24)
Next Steps
Now that you've initialized the SDK, proceed to the Translation Guide to learn how to use AutoLocalise in your application.