sphinx-doc / sphinx-doc-translations

Translations for Sphinx's documentation
Other
22 stars 16 forks source link

Sphinx theme shown in English for translated Sphinx docs #47

Open rffontenelle opened 5 months ago

rffontenelle commented 5 months ago

Texts from Sphinx themes are not available for translation and are shown in English in every translated Sphinx doc. This impacts the texts Documentation » from upper navigation bar, and On this page and Site navigation (from sidebar).

Their source file is in doc/_themes/sphinx13/layout.html. Note that Documentation is not marked for translation, but On this page and Site navigation are, still it is not extracted for translation in Sphinx UI or docs.

The Sphinx docs' layout.html file extends sphinx/themes/basic/layout.html, which has its strings included for translation in Sphinx UI. The aforementioned strings shown in Sphinx theme are exclusive from doc/_themes/sphinx13/layout.html

image

humitos commented 5 months ago

Note that Documentation is not marked for translation,

If it's not marked as translatable, there isn't too much that we can do at build time here. We need to update the Sphinx code and mark that string translatable as the first step. Then, update the .po file with the translated strings.

but On this page and Site navigation are, still it is not extracted for translation in Sphinx UI or docs.

These strings are not translated in any of the Portuguese variations, that's why they are not translated in the built documentation. They don't appear in any of the following files:

The solution for these is to update the translations from the source language and translate those strings after that.

rffontenelle commented 5 months ago

The POT and PO files are updated daily, so it means that even strings marked for translation are not actually extracted from source files. I assume the Sphinx docs' string extraction should be adjusted to extract from doc/_themes/sphinx13/layout.html as well, just like Sphinx UI extract from sphinx/themes/basic/layout.html. Homework to do... Thanks!

rffontenelle commented 4 months ago

Note to self: Sphinx extracts translation strings from templates using https://github.com/sphinx-doc/sphinx/blob/5750d0e3fe8905fb582a6db95512f28b4c26159e/utils/babel_runner.py and pydata uses https://github.com/pydata/pydata-sphinx-theme/blob/main/noxfile.py