Add language button and remove all others
This commit is contained in:
19
extensions/fix_buttons/static/switch-language.js
Normal file
19
extensions/fix_buttons/static/switch-language.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const switchLanguage = () => {
|
||||
// Get current URL
|
||||
let url = window.location.href;
|
||||
let path = window.location.pathname;
|
||||
let filename = path.split("/").pop();
|
||||
|
||||
// Detect if it's an English page
|
||||
if (filename.endsWith(".en.html")) {
|
||||
// Switch to German: remove ".en"
|
||||
let newFilename = filename.replace(".en.html", ".html");
|
||||
let newUrl = url.replace(filename, newFilename);
|
||||
window.location.href = newUrl;
|
||||
} else if (filename.endsWith(".html")) {
|
||||
// Switch to English: add ".en"
|
||||
let newFilename = filename.replace(".html", ".en.html");
|
||||
let newUrl = url.replace(filename, newFilename);
|
||||
window.location.href = newUrl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user