Installation & Setup
This section will guide you through installing TranslateSheet, setting up peer dependencies, and configuring your project to start using TranslateSheet in your React or React Native app.
Installation
Install the translate-sheet
package from npm:
Peer Dependencies
TranslateSheet relies on i18next for runtime translations. You need to install i18next
as a peer dependency:
Configuration
To get started, you need to create a TranslateSheet configuration file at the root of your project. This file defines essential options like your API key, primary language, output directory, and more.
Example Configuration File
Create a file named translateSheetConfig.js
in the root of your project:
const translateSheetConfig = {
apiKey: "your-api-key-here",
output: "./i18n",
primaryLanguage: "en",
fileExtension: ".ts",
languages: ["es", "fr", "de", "ja"],
generatePrimaryLanguageFile: false,
};
module.exports = translateSheetConfig;
Configuration Options
Option | Type | Required | Default | Description |
---|---|---|---|---|
apiKey | string | false | null | The API key used for authenticating with the TranslateSheet backend. |
output | string | false | "./i18n" | The directory where the generated translation files will be saved. |
primaryLanguage | string | false | "en" | The primary language of the project (e.g., “en” for English). |
fileExtension | ".ts", ".js", ".json" | false | ".ts" | The file extension for the generated translation files. |
languages | string[] | false | [] | An array of target languages for translation (e.g., [“es”, “ru”, “ja”]). |
generatePrimaryLanguageFile | boolean | false | false | Optionally generate a consolidated file for your primary language |
Note:
Without a valid API key, AI translations will not be available when running the generate
command.
Generating an API Key
To use TranslateSheet’s AI-powered translation feature, you need an API key. Follow these steps to generate your API key:
- Go to the TranslateSheet Dashboard .
- Sign up or log in with your account.
- Create a new project
- Navigate to the API Keys section of your newly created project.
- Copy the generated API key and add it to your
translateSheetConfig.js
file under theapiKey
option
Next Steps
Once you have installed TranslateSheet, set up your configuration file, and generated an API key, you’re ready to start using it in your components. Head over to the Usage section to learn how to define translations and run the gen-translations
command.