Issue with: Redirect based on browser language, but with a manual override

Hello,

I followed this tutorial and was able to implement the auto-language switch successfully:

My issue is that some users will WANT to browse in a language different from their browser language.

Example: a user with an “fr” browser wants to read content in English, it will automatically redirect them back to French…

Can this be overriden?
Is there some stipulation I can add that prompts WIX to switch lanuage automatically ONLY on the first page load? User can then change language at will.

FYI: I am not using wix-multilingual.


Preview of my code below:

Summary

import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;

$w.onReady(function () {

let url = wixLocation.url;
if (url === ‘https://www.URL.com/’) {

switch (wixWindow.browserLocale) {

case ‘fr’:
case ‘fr-CA’:
case ‘fr-FR’:
case ‘fr-CH’:
case ‘fr-LU’:
case ‘fr-MC’:
case ‘fr-BE’:
wixLocation.to(‘https://www.URL.com/accueil’);
break ;

case ‘es’:
case ‘es-ES’:
case ‘es-CR’:
wixLocation.to(‘https://www.URL.com/inicio’);
break ;
}
}

else if (url === ‘https://www.URL.com/’){
switch (wixWindow.browserLocale) {
case ‘en’:
wixLocation.to(‘https://www.URL.com/’);
break ;
}
}
});


Thanks in advance for any insight you may have.