Skip to content

Can't enable translation of sphinx_rtd_theme #8915

Closed

Description

@zhsj

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.

sphinx/sphinx/theming.py

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.

sphinx/sphinx/theming.py

Lines 182 to 183 in f8878bb

elif name == 'sphinx_rtd_theme':
self.load_sphinx_rtd_theme()

Activity

  1. added this to the 4.0.0 milestone on Feb 21, 2021
  2. tk0miya commented on Feb 21, 2021

    @tk0miya
    Member

    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).

  3. added 4 commits that reference this issue on Feb 23, 2021
    7c0d2e2
    7c3b422
    ad3edd9
    4392557
  4. added a commit that references this issue on Mar 11, 2021
    3134085
  5. locked as resolved and limited conversation to collaborators on Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions