-
pip install Sphinx sphinx-intl python-levenshtein furo
-
sphinx-quickstart docs
> Separate source and build directories (y/n) [n]: > Project name: Sphinx internationalization test > Author name(s): Damian Krawczyk > Project release []: 0.0.1 > Project language [en]:
-
vi docs/conf.py
# https://www.sphinx-doc.org/en/master/usage/advanced/intl.html#quick-guide
locale_dirs = ['locale/'] # path is example but recommended.
gettext_compact = False # optional.
# https://docs.readthedocs.io/en/stable/guides/manage-translations.html
gettext_uuid = True
-
Set theme to furo
# html_theme = 'alabaster'` html_theme = 'furo'
-
Copy furo's
page.html
todocs/_templates
wget -P docs/_templates https://raw.githubusercontent.com/pradyunsg/furo/main/src/furo/theme/furo/page.html
-
Run VSC tasks to generate files for translation.
NOTE
- Default language is set to
pl
- Polish. - You need to configure first
virtualenvPath
in.vscode/settings.json
to run VCS tasks.
- Internationalization - build gettext
- Internationalization - intl update
- Default language is set to
-
Translate generated
*.po
files. -
Run VSC task to see translated page.
- Internationalization - build html
-
Push to repository.
-
Configure project in RTD.
-
Now you have option to change language for your documentation.
Direct links below:
- https://sphinx-internationalization-test.readthedocs.io
- https://sphinx-internationalization-test.readthedocs.io/pl/latest/
HINT: If you notice below error during build in RTD
Theme error: An error happened in rendering the page index. Reason: TemplateNotFound('base.html')
- Go to your project Admin settings in RTD
- Advanced Settings
- Uncheck option on the bottom - Enable EPUB build