Repository navigation
Description
Describe the bug
sphinx_rtd_theme has translation support since v0.5.0. However it can't be enabled.
To Reproduce
Steps to reproduce the behavior:
$ make html SPHINXOPTS="-D language=zh_CN -D html_theme=sphinx_rtd_theme"
$ # open _build/html/index and see the message in search box.
Expected behavior
The message in search box has been translated.
Your project
The message in search box is still "Search docs".
Environment info
- OS: [Linux]
- Python version: [e.g. 3.9.1]
- Sphinx version: [e.g. 3.5.1]
- Sphinx extensions: [sphinx-rtd-theme]
- Extra tools: []
Additional context
sphinx-rtd-theme has a setup function to extend locale dir.
https://github.com/readthedocs/sphinx_rtd_theme/blob/3ed52c4df52a4edd4bf3673b7d787b61685e2287/sphinx_rtd_theme/__init__.py#L40
However it's never been called, since sphinx_rtd_theme is a special theme.
Lines 192 to 199 in f8878bb
| def load_sphinx_rtd_theme(self) -> None: | |
| """Load sphinx_rtd_theme theme (if exists).""" | |
| try: | |
| import sphinx_rtd_theme | |
| theme_path = sphinx_rtd_theme.get_html_theme_path() | |
| self.themes['sphinx_rtd_theme'] = path.join(theme_path, 'sphinx_rtd_theme') | |
| except ImportError: | |
| pass |
If I remove these lines, then the translation works fine.
Lines 182 to 183 in f8878bb
| elif name == 'sphinx_rtd_theme': | |
| self.load_sphinx_rtd_theme() |
Activity
tk0miya commentedon Feb 21, 2021
Thank you for reporting. It seems sphinx_rtd_theme has already support loading via entry_point. So special treatment is no longer needed. It's better to remove the code (since 4.0).
Fix sphinx-doc#8915: html theme: The translation of sphinx_rtd_theme …
Fix sphinx-doc#8915: html theme: The translation of sphinx_rtd_theme …
Fix sphinx-doc#8915: html theme: The translation of sphinx_rtd_theme …
Merge pull request #8920 from tk0miya/8915_i18n_for_sphinx_rtd_theme
Master.patch (#1)