Streaming live at 10am (PST)

Multi language switch help (custom code)

I’m currently updating my website that is in 2 languages. I used the multi folder method with a custom code switch to navigate between both languages while staying on the same page. Thing is, the home page I want to use as the landing page is in a folder. How can I edit my code to make things work?

My custom code

<script>

/*

  • switch current url
  • based on current language folder
  • short version :brain:
    */
    (function switchLanguage() {
    const switchButton = document.getElementById(‘switchLink’);
    let protocol = window.location.protocol;
    let currentHost = window.location.host;
    let pathNameArray = window.location.pathname.split(’/’);
    switchButton.addEventListener(‘click’, function() {
    if (pathNameArray1 == ‘fr’) {
    window.open(protocol + ‘//’ + currentHost + ‘/en/’ + pathNameArray2, ‘_self’);
    } else if (pathNameArray1 == ‘en’) {
    window.open(protocol + ‘//’ + currentHost + ‘/fr/’ + pathNameArray2, ‘_self’);
    }
    }
    );
    })();

Here is my site Read-Only: https://preview.webflow.com/preview/pointcinq?utm_medium=preview_link&utm_source=dashboard&utm_content=pointcinq&preview=9132407ef56b78c9a46235987868129f&mode=preview

Just thinking of a code-free solution here (because I suck at code!) - why not just have a “splash screen” as your Home, and from there the user selects whether they want the English or French version of the website?

This is what I currently use but I would like to eliminate the need to go through this aditionnal page.