Skip to main content

Translations

WriteDocs supports translations to different languages. This section provides a guide on how to add your translated content.

Adding Languages to Project Configurations

To enable different languages in your project, you need to first add the desired languages to the config.json file. Below you find all available languages you can add, and how to add them to the configuration file:

{
"languages": [
"en", // English
"es", // Spanish
"fr", // French
"de", // German
"pt", // Portuguese
"it", // Italian
"ja" // Japanese
]
}
Default Language

It's important to know that the first language will be set as default.

Adding Translated Pages

To add different translated pages to your project, you need to add a translations folder to the root of your project. In it, you will need to add a folder to each language you want to add translations to, using the language abbreviation used previously in this guide. The example folder structure below is used to add translations to both portuguese and spanish:

Your_project_root
├──components
├──docs
├──media
├──openAPI
├──translations
│  ├──es
│  │  └──...
│  ├──pt
│  │  └──...
├──README.md
├──config.json
└──homepage.html

Inside each of these new folders (translations/es, translations/pt), you need to replicate the structure from the original docs folder. Each translated file must keep the original's page slug in the metadata. Beyond this, you can translate all the content in this page. See the example below:

---
title: Translations
slug: /translations
---

WriteDocs supports translations to different languages. This section provides a guide on how to add your translated content.
CLI

WriteDocs CLI currently doesn't preview other languages other than the default.

Category Names and Navbar Titles

To translate content that isn't related to a page, such as category names, and navbar titles, you can use WriteDocs CLI to generate a boilerplate translations.json file. This file allows you to map your current docs content, and translate their values. Run the following command to generate it:

writedocs translate
Installing the CLI

If you don't have WriteDocs CLI installed, refer to the Local Development guide to learn how to use it, or run npm i -g writedocs to install it.

This will generate a file similar to the one below:

translations.json example
{
"es": {
"navbar": {
"Guides": "Guides",
"API Reference": "API Reference",
"v1.0": "v1.0"
},
"sidebars": {
"guides": {
"Getting Started": "Getting Started",
"Creating Pages": "Creating Pages",
"Config File Examples": "Config File Examples"
},
"apiReference": {
"Example": "Example"
}
}
},
"pt": {
"navbar": {
"Guides": "Guides",
"API Reference": "API Reference",
"v1.0": "v1.0"
},
"sidebars": {
"guides": {
"Getting Started": "Getting Started",
"Creating Pages": "Creating Pages",
"Config File Examples": "Config File Examples"
},
"apiReference": {
"Example": "Example"
}
}
}
}