Documentation Translation Guide
This guide explains how to translate the CryptoBot Python documentation into different languages.
Overview
The documentation uses Sphinx’s internationalization (i18n) support with sphinx-intl for managing translations. Translation files are stored in .po (Portable Object) format under docs/locale/<language>/LC_MESSAGES/.
Available Languages
Currently supported languages:
English (en) - Default
Spanish (es) - Complete translation
Prerequisites
Install documentation dependencies:
uv sync --extra docs
Or directly:
pip install sphinx sphinx-intl sphinx-rtd-theme myst-parser
Quick Start: Adding a New Language
1. Generate Translation Templates
First, generate the .pot (Portable Object Template) files:
cd docs
make gettext
This creates template files in _build/gettext/.
2. Create Translation Catalog
Create .po files for your language (e.g., French):
cd docs
make update-po LANG=fr
This creates locale/fr/LC_MESSAGES/*.po files.
3. Translate Content
Edit the .po files in locale/fr/LC_MESSAGES/ and fill in the msgstr fields:
#: ../../index.md:1
msgid "Welcome to CryptoBot Python's documentation!"
msgstr "Bienvenue dans la documentation de CryptoBot Python!"
Translation Guidelines:
Translate only the
msgstrfieldsKeep code blocks, URLs, and technical identifiers unchanged
Preserve markdown formatting
Maintain consistent terminology
4. Build Translated Documentation
Build the documentation in your target language:
cd docs
make html-lang LANG=fr
The translated HTML will be in _build/html/fr/.
Updating Existing Translations
When the English documentation changes, update translation files:
cd docs
make update-po LANG=es
This updates the .po files with new strings while preserving existing translations. Untranslated or updated strings will be marked as “fuzzy” and need review.
Makefile Commands
The docs/Makefile provides several translation commands:
make gettext
Generates .pot template files from source documentation.
cd docs
make gettext
make update-po LANG=<language>
Updates or creates .po files for a specific language.
cd docs
make update-po LANG=es # Update Spanish
make update-po LANG=fr # Update French
make html-lang LANG=<language>
Builds HTML documentation in a specific language.
cd docs
make html-lang LANG=es # Build Spanish docs
make html-lang LANG=fr # Build French docs
Output location: _build/html/<language>/
File Structure
docs/
├── locale/ # Translation catalogs
│ ├── es/ # Spanish translations
│ │ └── LC_MESSAGES/
│ │ ├── index.po
│ │ ├── installation.po
│ │ ├── usage.po
│ │ └── ...
│ └── fr/ # French translations (example)
│ └── LC_MESSAGES/
│ └── ...
├── _build/
│ ├── gettext/ # Generated .pot templates
│ └── html/
│ ├── en/ # English HTML (default)
│ ├── es/ # Spanish HTML
│ └── fr/ # French HTML (example)
├── conf.py # Sphinx configuration
└── Makefile # Build commands
Translation Workflow
For New Translators
Fork the repository
Create translation files:
cd docs make update-po LANG=<your_language>
Translate:
Edit
.pofiles inlocale/<your_language>/LC_MESSAGES/Use a
.poeditor like Poedit or any text editorFocus on
msgstrfields
Test your translation:
make html-lang LANG=<your_language>
Open
_build/html/<your_language>/index.htmlin a browser
Submit a pull request with your translations
For Maintainers
When documentation is updated:
Regenerate templates:
cd docs make gettext
Update all language catalogs:
make update-po LANG=es make update-po LANG=fr # ... for each language
Review fuzzy translations:
Search for
#, fuzzyin.pofilesUpdate or confirm these translations
Remove the
#, fuzzymarker when done
Build and verify all languages:
make html-lang LANG=es make html-lang LANG=fr
Best Practices
Translation Quality
Consistency: Use consistent terminology throughout
Context: Consider the technical context when translating
Natural language: Translate meaning, not word-for-word
Code preservation: Never translate:
Python code
Variable/function names
URLs
Command-line instructions
API endpoints
Common Patterns
Code comments in examples:
msgid "# Create a client"
msgstr "# Crear un cliente"
Mixed content (keep code unchanged):
msgid "Call `client.create_invoice()` to create invoices"
msgstr "Llama a `client.create_invoice()` para crear facturas"
URLs and links:
msgid "See [documentation](https://example.com) for details"
msgstr "Ver [documentación](https://example.com) para detalles"
Tools
Recommended .po Editors
Poedit - Cross-platform, user-friendly
Lokalize - KDE translation tool
GTranslator - GNOME translation tool
Text editors - VS Code, vim, emacs with syntax highlighting
Validation
Check for errors in .po files:
msgfmt --check locale/es/LC_MESSAGES/index.po
Read the Docs Integration
The project is configured to build multi-language documentation on Read the Docs:
Configuration:
.readthedocs.yamlTranslation files are generated during the build process
Spanish documentation is automatically built and published
Contributing Translations
We welcome translations! Here’s how to contribute:
Check existing translations in the
locale/directoryCreate an issue announcing your translation
Follow the workflow above
Submit a pull request
Maintainers will review and merge
Translation Checklist
All
.pofiles updatedNo
#, fuzzymarkers remainDocumentation builds without errors
Translated pages display correctly
Code examples work as expected
Links and references are functional
Troubleshooting
Build Errors
Error: unsupported locale setting
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
make html-lang LANG=es
Error: sphinx-intl not found
uv sync --extra docs
# or
pip install sphinx-intl
Translation Not Appearing
Check
.mofiles were generated:ls locale/es/LC_MESSAGES/*.moRebuild from scratch:
make clean make html-lang LANG=es
Verify language code in
msgstrheader
Resources
Questions?
For translation questions or issues:
Open an issue on GitHub
Contact the maintainers
Check existing
.pofiles for examples