Deploying to Production
How to deploy your project to production with General Translation
Overview
This is a guide on how to use the General Translation CLI tool to deploy your site to production.
This CLI tool scans through your project and looks for content to translate. It handles both the dictionary and the <T>
component formats.
Read more about the CLI tool here.
This guide assumes that you have already integrated gt-next
or gt-react
into your project.
If you haven't, please follow the NextJS Quick Start Guide or the React Quick Start Guide before proceeding.
For production only!
Because this CLI tool publishes translated content to the CDN, it is meant to only be used for production builds, and should not be used in development. Before running this command, please make sure you are on the branch that will be used for production. Remember to also use your production API key and Project ID.
Usage
Basic usage
Add your API key and Project ID to your environment variables.
You can do this by adding the following to your .env
file or directly to your environment:
Install the CLI tool:
Next, run the following command:
By default, running the command above will enable on-demand translation for all supported locales.
Translations are usually ready within a minute, but could take up to five minutes in periods of high demand. When translations are ready you should be able to access them via the cache in both your local and production projects.
Pre-Translation
By default, your project will be translated on-demand depending on the locales of the users who visit your site. Since these on-demand translations may take a few seconds to complete, you can pre-translate your project to serve cached translations to your users.
You can select which locales you want to pre-translate by specifying them in the command.
For more information on specifying locales, read our article about locale strings here.
If the script is successful, you should see a similar message to the following:
Dry run
To test a dry run of the CLI tool, you can use the --dry-run
flag. Running the CLI tool with this flag allows
you to validate proper usage of the <T>
components or dictionary formats in your codebase, without actually sending data to our servers.
Notes
- The CLI tool allows you to pre-translate content.
- This is meant to be used for production builds only.
- You can specify which locales you want to pre-translate.
Next steps
- Learn more about the CLI tool and pre-translation.
- Learn more about locale strings.