Skip to content

Commit

Permalink
Ensure that the lang URL parameter is always set.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbohacek committed Jan 14, 2024
1 parent b88aae0 commit 73c4e90
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions public/js/modules/language-switcher.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Cookies from './cookies.js';
import {getUrlParam, setUrlParam} from './urlParams.js';

const switchLanguage = () => {
const languageSwitcher = document.getElementById('language-switcher');
Expand All @@ -18,6 +19,12 @@ const switchLanguage = () => {
}
}

const langParam = getUrlParam("lang");

if (!langParam){
setUrlParam("lang", currentLanguage);
}

languageSwitcher.value = currentLanguage;

[...document.querySelectorAll('a:not([href*="://"])')].forEach(a => {
Expand Down

0 comments on commit 73c4e90

Please sign in to comment.