To support localization efforts, follow these steps to extract translatable strings and update translations.
To extract translatable text and generate .pot files, run:
sphinx-build -b gettext DISCOVER/ DISCOVER/_build/gettextThis will store extracted strings in .pot files inside DISCOVER/_build/gettext.
Note
We have set gettext_uuid to True which can be slow.
The cookbook isn't very large so it will generally not be relevant, but the linked sphinx docs have tips on accelerating that if relevant.
To update existing translations, use the following command:
sphinx-intl update -p DISCOVER/_build/gettext -l <language-code>Replace with your target language (e.g., en, fr, de).
Once .po files are updated, compile them to .mo for use in the built documentation:
WEBSITE_LANGUAGE=<language-code> sphinx-build -b html DISCOVER/ DISCOVER/_build/html
After compiling, rebuild the book to see the translations applied:
Run the following command to start a local server:
python -m http.server 8000 --directory DISCOVER/_build/html/Then, open http://localhost:8000 in your browser.
Alternatively, you can open the book directly by navigating to:
DISCOVER/_build/html/index.html
and opening it in your browser.
Note: Contributors working on multilingual support should ensure .po file updates are included in commits.
We use Transifex to manage translations for the DISCOVER Cookbook. This guide outlines when and how to interact with Transifex during development. You likely won’t need every step each time—focus on the ones relevant to your task.
Transifex provides a Go-based CLI for syncing translation files. Follow the (official installation instructions)[https://developers.transifex.com/docs/cli] for your operating system.
Verify installation:
tx --versionExpected output:
TX CLient, version=1.6.x
To authenticate, create a .transifexrc file in your home directory. Refer to the official authentication guide for details.
Get your token from Transifex Account Settings.
The .tx/config file maps source files to Transifex resources. You’ll only need to modify this whenever a new release is made:
Use the CLI to register new resources:
tx add \
--organization numfocus \
--project DISCOVER-Cookbook \
--resource <resource_name> \
--file-filter locales/<lang>/LC_MESSAGES/<filename>.po \
--type PO \
DISCOVER/_build/gettext/<filename>.pot
Refer to the Transifex CLI reference for more information.
Perform the following steps only when a release is made:
- Regenerate
.pofiles usingsphinx-gettextandsphinx-intl. - Open a PR with the updated files.
- Push to Transifex:
tx push -s -t
This uploads both source and translation files.
To fetch updated translations from Transifex (done manually before publishing):
tx pull -a -m reviewed
To add multiplt resorces, use CLI setup.