diff --git a/_static/theme/language_switcher.js b/_static/theme/language_switcher.js index ad57c4f6..1b5cc991 100644 --- a/_static/theme/language_switcher.js +++ b/_static/theme/language_switcher.js @@ -3,10 +3,14 @@ const CONTRIBUTE_URL = 'https://docs.zammad.org/en/latest/contributing/start.htm // Initialize the switcher only when RTD panel gets loaded. // If the menu has exactly the 6 sections, the first one on top is the language chooser. // We must check it in this way since the label may be translated based on the browser locale. +// Try to do this only for the first 3 seconds or so, otherwise the documentation may not have any translations. $(document).ready(() => { + let count = 0 + const intervalId = setInterval(() => { + if ($('.rst-other-versions dt').length !== 6 && count++ <= 30) return + clearInterval(intervalId) if ($('.rst-other-versions dt').length !== 6) return - clearInterval(intervalId); initLanguageSwitcher() }, 100) }) diff --git a/conf.py b/conf.py index 9b14b41e..22505e98 100644 --- a/conf.py +++ b/conf.py @@ -55,7 +55,6 @@ def setup(app): # ], # } - html_js_files = ['theme/language_switcher.js'] html_css_files = [ 'https://media.readthedocs.org/css/sphinx_rtd_theme.css', 'https://media.readthedocs.org/css/readthedocs-doc-embed.css', @@ -68,11 +67,11 @@ def setup(app): # If we're **not on latest**, we'll display a deprecation warning. if rtd_version == 'latest': branch = rtd_version + + # Inject the language switcher script. + html_js_files = ['theme/language_switcher.js'] elif rtd_version == 'pre-release': branch = "pre-release" - - # Skip the injection of the language switcher. - del html_js_files else: branch = "old-version"