Manage Locales
How to manage your App's locales
Overview
This document provides guidance on how to manage locales in your Next.js application with the gt-next
.
We will walk through configuring the list of locales you want to support, then triggering the generation of translations.
This library uses the BCP-47 standard to define locales. See a list of currently supported locales here.
Configuring Locales
There are two ways to change your locales for production:
- The CLI tool
- The
gt.config.json
file (preferred)
In order for translation to be performed, you must add the translate command to your build script:
This will generate the necessary translations and store them in the cloud or in your local filesystem depending on your configuration.
Managing locales with the CLI tool
The simplest way to manage locales is specifying them through the npx gt-next-cli translate
command by using the --locales
flag.
This will generate translations for Chinese (zh
) and Japanese (jp
).
Using gt.config.json
(preferred)
A more robust way of managing locales is by using the gt.config.json
file.
you can specify the list of locales you want to support with the locales
property.
Whitelisted locales
As an optional feature, you can add a list of whitelisted locales. This is accessible through the dashboard under the Project Locales page. If you enable this feature, any attempts to call npx translate with non-whitelisted locales will fail.
Notes
- You can manage locales through the dashboard, the
gt.config.json
file, or the CLI tool. - Using
gt.config.json
or CLI tool to manage locales will disable the Manage Locales feature in the dashboard.
Next Steps
- Learn about the locale syntax in the Locale Strings reference.