Skip to content

Commit

Permalink
Remove language switch if there are not translations
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed Sep 19, 2024
1 parent 474290d commit 7b63004
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sphinx_rtd_theme/static/js/versions.js_t
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ if (themeLanguageSelector || themeVersionSelector) {
const versionSwitch = document.querySelector(
"div.switch-menus > div.version-switch",
);
const languageSwitch = document.querySelector(
"div.switch-menus > div.language-switch",
);

if (themeVersionSelector) {
let versions = config.versions.active;
if (config.versions.current.type === "external") {
Expand All @@ -185,6 +181,10 @@ if (themeLanguageSelector || themeVersionSelector) {
versionSwitch.firstElementChild.addEventListener("change", onSelectorSwitch);
}

const languageSwitch = document.querySelector(
"div.switch-menus > div.language-switch",
);

if (themeLanguageSelector) {
if (config.projects.translations.length) {
// Add the current language to the options on the selector
Expand Down Expand Up @@ -214,6 +214,9 @@ if (themeLanguageSelector || themeVersionSelector) {
languageSwitch.innerHTML = languageSelect;
languageSwitch.firstElementChild.addEventListener("change", onSelectorSwitch);
}
else {
languageSwitch.remove();
}
}
});
}

0 comments on commit 7b63004

Please sign in to comment.