Skip to content

Commit

Permalink
Follow up for de559d0 - Maintenance: Add language switcher to the pag…
Browse files Browse the repository at this point in the history
…e header.
  • Loading branch information
dvuckovic committed Sep 18, 2023
1 parent 970fcd1 commit d50314a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 5 additions & 1 deletion _static/theme/language_switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
7 changes: 3 additions & 4 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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"

Expand Down

0 comments on commit d50314a

Please sign in to comment.