Skip to content

Commit

Permalink
Fix sphinx-doc#8915: html theme: The translation of sphinx_rtd_theme …
Browse files Browse the repository at this point in the history
…does not work

Since sphinx_rtd_theme-0.5.0, it supports translations.  But Sphinx core
disallows to enable it because theming framework gives special treatment
for the theme for a long time.

This goes to load it via setuptools at first to enable the translations.

Note: The special treatment for sphinx_rtd_theme (< 0.2.0) is not
removed yet.  But it will be removed in the next major release.
  • Loading branch information
tk0miya committed Feb 23, 2021
1 parent faa71ee commit 7c0d2e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -61,6 +61,7 @@ Features added
:confval:`gettext_additional_targets` setting)
* #2018: html: :confval:`html_favicon` and :confval:`html_logo` now accept URL
for the image
* #8915: html theme: The translation of sphinx_rtd_theme does not work
* #8070: html search: Support searching for 2characters word
* #7830: Add debug logs for change detection of sources and templates
* #8201: Emit a warning if toctree contains duplicated entries
Expand Down
16 changes: 7 additions & 9 deletions sphinx/theming.py
Expand Up @@ -178,8 +178,6 @@ def load_extra_theme(self, name: str) -> None:
"""Try to load a theme having specifed name."""
if name == 'alabaster':
self.load_alabaster_theme()
elif name == 'sphinx_rtd_theme':
self.load_sphinx_rtd_theme()
else:
self.load_external_theme(name)

Expand Down Expand Up @@ -237,13 +235,13 @@ def create(self, name: str) -> Theme:
if name not in self.themes:
self.load_extra_theme(name)

if name not in self.themes and name == 'sphinx_rtd_theme':
# sphinx_rtd_theme (< 0.2.0) # RemovedInSphinx50Warning
logger.warning(__('sphinx_rtd_theme (< 0.2.0) found. '
'It will not be available since Sphinx-5.0'))
self.load_sphinx_rtd_theme()

if name not in self.themes:
if name == 'sphinx_rtd_theme':
raise ThemeError(__('sphinx_rtd_theme is no longer a hard dependency '
'since version 1.4.0. Please install it manually.'
'(pip install sphinx_rtd_theme)'))
else:
raise ThemeError(__('no theme named %r found '
'(missing theme.conf?)') % name)
raise ThemeError(__('no theme named %r found (missing theme.conf?)') % name)

return Theme(name, self.themes[name], factory=self)

0 comments on commit 7c0d2e2

Please sign in to comment.