How to Add a Translation¶
This page explains how to add or improve a translation of the docs for any language.
The site uses MkDocs + Material + mkdocs-static-i18n. English is the reference (fallback). Any other language mirrors its folder structure. If a page is missing in a target language, the English version is shown automatically.
1. Overview¶
There are three typical scenarios:
- Improve an existing translated page.
- Translate an English page that currently has no localized version.
- Add an entirely new language to the project.
Everything below covers all three.
2. Folder layout¶
/docs
en/
developer-guide/
getting-started/
user-guide/
<locale>/
(mirrors the structure you translate)
Examples of <locale>: pt, es, fr, de, it, ja, zh, ru. Use short IETF / BCP‑47 language tags (no country code unless needed, e.g. pt vs pt-BR only if a regional variant is required). Keep it consistent with mkdocs.yml.
Relative paths must match. Example:
English: docs/en/developer-guide/how-to-add-a-translation.md
Spanish: docs/es/developer-guide/how-to-add-a-translation.md
French: docs/fr/developer-guide/how-to-add-a-translation.md
3. Quick start (improving or adding a translation)¶
- Fork and clone your fork.
- Create / activate a virtual environment.
- Install docs extras:
- Run the local server:
- Open the local URL and switch language with the selector.
Restart the server if new files do not show up (MkDocs sometimes needs a restart after new file additions).
4. Adding a new language (one-time setup)¶
If the language already exists (e.g. pt/), skip this section.
- Pick a locale code (e.g.
es). - Create the folder:
docs/es/. - Copy the English
index.mdtodocs/es/index.mdand translate its visible text. - (Optional) Start by copying only a minimal subset (index + key getting-started pages) to keep the first PR reviewable.
- Update
mkdocs.ymli18n.languagessection: - Do not duplicate nav entries for the new language: the plugin maps them automatically based on folder structure.
- Run
mkdocs serveand confirm the new language appears in the selector.
If you need a regional variant (e.g. pt-BR), use that code consistently in both folder name and mkdocs.yml.
5. Adding a new English page (source language)¶
- Create the file under
docs/en/...in the right section. - Add front matter:
- Add its path to the
navtree inmkdocs.yml(English only). - Verify the site builds.
- (Optional) Add a translator note (HTML comment) for tricky concepts:
6. Creating the translated file¶
-
Mirror the folder path:
docs/<locale>/<same relative path>.md. -
Copy the English file.
-
Translate only human-readable prose. Keep intact:
- Code blocks (except inline comments if clarity improves)
- Identifiers: function/class names, parameters, imports
- File paths, config keys, URLs
- Markdown link targets (unless they refer to a language-specific external resource)
-
Preserve heading hierarchy (
#,##, etc.) but translate heading text itself. -
Keep admonition types (
!!! note,!!! warning, etc.). You may translate the title string after the admonition type. -
For unfinished parts, you can temporarily keep English or add:
-
Remove all "Pending" notes before final review if completed.
7. Internal links¶
Use relative links without language prefixes:
The i18n plugin rewrites them per language. Avoid hardcoding/en/ or another locale path unless you intentionally want a fallback link. Anchor links: if you translate a heading, Material generates a localized slug. Keep anchor usage consistent or adjust any (#anchor) references accordingly.
8. Images and media¶
If screenshots contain embedded language text:
- Option A: replicate and localize the image inside
docs/<locale>/assets/and keep the same filename (per-locale path isolates it). - Option B: reuse the English image if text is minimal or language-agnostic.
SVG diagrams: prefer keeping labels English if they are code or model symbols; translate UI captions where helpful.
9. Formatting & style guidelines¶
| Aspect | Guideline |
|---|---|
| Numbers | Keep numeric precision; adapt decimal separators only if standard for the target audience (optional). |
| Units | Do not translate SI units (e.g. ms, Hz). |
| API names | Never translate identifiers. |
| Quotes | Follow local typographic conventions only if they do not break Markdown. |
| Capitalization | Mirror English capitalization only where it's a proper noun or API name. |
| Tone | Neutral, concise, instructional. |
Avoid machine‑translated chunks without revision. Prefer shorter, unambiguous sentences.
10. Translation glossary¶
Keep these terms consistent across languages. Add target language equivalents as needed:
| English Term | Portuguese (pt) |
|---|---|
| Core concepts | |
| model structure | estrutura do modelo |
| parameter estimation | estimação de parâmetros |
| residual analysis | análise dos resíduos |
| time series | série temporal |
| identification | identificação |
| Technical terms | |
| basis function | função de base |
| regression | regressão |
| algorithm | algoritmo |
| validation | validação |
| simulation | simulação |
| Development terms | |
| feature | funcionalidade |
| pull request (PR) | pull request (PR) |
| branch | branch |
| commit | commit |
| documentation | documentação |
For other languages, follow similar patterns. Prefer clarity over literal translation.
11. Review checklist (per translated file)¶
- Builds locally (
mkdocs serve). - File path mirrors English.
- Relative links work; no
/en/hardcoding. - Code blocks untouched (except explanatory comments if needed).
- Terminology consistent with existing pages.
- No leftover placeholder notes (unless intentionally partial PR).
- Front matter present and
title:localized.
12. Commit & Pull Request¶
Add both English and translated files if you introduce a page + its translation; otherwise just the translated file.
Example:
git add docs/en/developer-guide/new-topic.md docs/es/developer-guide/new-topic.md
git commit -m "docs: add Spanish translation for new-topic"
PR description template:
- Language:
<locale>(e.g.es) - Pages added/updated: list paths
- Sections intentionally left untranslated: (if any)
- Glossary additions: (if any)
- Notes for reviewer: context, tricky terms
Partial translations are acceptable—label them clearly so others can help.
13. Updating existing translations¶
When an English page changes:
- Open the diff to see what changed.
- Apply equivalent edits to the translated file.
- If you cannot translate immediately, keep the English change and add a temporary "Pending translation" note.
- Remove the note once updated.
Aim for incremental PRs rather than large rewrites.
14. Common issues¶
| Symptom | Cause | Fix |
|---|---|---|
| Page shows in English only | Missing localized file or wrong path | Mirror path under new locale folder |
| Build error after adding language | Misconfigured i18n.languages entry | Re-check locale key + indentation |
| 404 on internal link | Link path differs from English | Match relative path to English version |
| Broken anchor | Heading translated; old anchor used | Update anchor or keep similar heading slug |
| Language not in selector | Forgot to add language in mkdocs.yml | Add locale entry and restart server |
15. Automation (optional)¶
You may use external CAT / translation tools, but always manually review technical terms. Avoid committing raw machine output.
If you script copying English files to a new locale, exclude already translated ones to prevent overwriting.
16. Questions & support¶
If you are unsure about terminology, open an Issue or Discussion before translating large sections. Early feedback prevents rework.
Thanks for helping make the documentation accessible to more people.