The translate command helps you to manage multiple translations in your Redocly project (Reef, Revel, or Realm only). It creates or updates translations.yaml files, populating them with "translation keys" that map to elements in your documentation's UI.
This command serves two purposes:
- On first run,
translatecreates (or populates) a file with built-in translation keys for common UI elements. - On future runs,
translateadds custom, user-defined translation keys from yourredocly.yamlorsidebars.yamlfiles.
redocly translate <locale>
redocly translate all
redocly translate --help
redocly translate --version| Option | Type | Description |
|---|---|---|
locale | string | REQUIRED Name of a locale folder, inside your project's l10n directory, to generate translations for. Use all for all locales. |
--lint-config | string | Severity level for config file linting. Possible values: warn, error, off. Defaults to warn. |
| --project-dir, -d | string | Path to the project directory. The default value is . (current directory). |
--help | boolean | Show help. |
--version | boolean | Show version number. |
The following sections show some common use cases for the translate command.
The following command generates or updates translations for the Dutch locale:
redocly translate nl-NLThe translations are placed in the file @l10n/nl-NL/translations.yaml. If the file (or folder) doesn't exist, they're created and populated with translation keys.
Use the all keyword to generate translations for all the locale folders inside the @l10n directory:
redocly translate allThis command updates the translation.yaml files for every locale with a folder in @l10n, as shown in the following example:
your-awesome-project
├──@l10n/
│ ├──es-ES/
│ │ ├──transcriptions.yaml
│ │ └──...
│ ├──fr/
│ │ ├──transcriptions.yaml
│ │ └──...
│ └──nl-NL/
│ ├──transcriptions.yaml
│ └──...
├──index.md
├──sidebars.md
├──redocly.yaml
└──...Use the --project-dir option to run the translate command from a parent folder and populate translation keys inside a specific project:
redocly translate all --project-dir='museum-docs'The following project structure represents the output of running this command from the projects folder:
projects/
├──storage-docs/
├──authentication-docs/
└──museum-docs/
├──@l10n/
│ ├──es-ES/
│ │ ├──transcriptions.yaml
│ │ └──...
│ ├──fr/
│ │ ├──transcriptions.yaml
│ │ └──...
│ └──nl-NL/
│ ├──transcriptions.yaml
│ └──...
├──index.md
├──sidebars.md
├──redocly.yaml
└──...The --project-dir option is designed to help manage multiple projects by reducing the need for traversal.
The command is additive; it doesn't overwrite existing translation keys.
Custom translation keys used in React components must be manually added to the
translation.yamlfile. They are not populated by the command.After using the command, review a translation file to ensure new translation keys are present.
Automating this command can help keep translation keys updated across multiple locales.
See how to configure localization in your Redocly project.
Configure which languages users can select using the localization option (
l10n) inredocly.yaml.