Sphinx Localization and Multi-language

Adding a Locale

To add a locale you’ll need to modify the following files in the project repository:

  • build.sh
  • sphinx-cicd.sh
  • conf.py

First add the locale to the declared language arrays in both bash scripts:

languages=(
    "en"
    "es" # Example
    )

And then add it to the language array in the conf.py file:

# POPULATE LINKS TO OTHER LANGUAGES - (Locale name, Locale path/link)
html_context['languages'] = [ 
    ('en', 'en/'), 
    ('es', 'es/')
]

Editing Translations

To edit translations for a locale head to the locale directory in the repository and modify the msgstr values for whatever section you wish to change, in it’s respective .po file.

#: ../../_templates/navbar-lang-dd.html:4
msgid "Languages"
msgstr "Idioma"

Original Documentation on Sphinx Internationalization: