Avada Forums Community Forum Changing languages is not detected on some pages (examples in description)

Tagged: 

Viewing 1 post (of 1 total)
  • Author
    Posts
  • sbecer
    Participant
    Post count: 1

    Hi all,

    Been dealing with this headache of an issue for weeks now. We have a product technical support site where the manuals for products can be downloaded in various languages (when said language is available).

    We have JS function set up for when the user changes their language said function runs and redirects the user to the manual download in their set language (again, if the language is available).

    For some reason it works just fine on some pages but not on others. It’s not a complicated function at all and I have cross-referenced the pages where it works and where it does not for any discrepancies and there are none to be noticed. It is a simple If/Else function.

    Hoping for some insight here if anyone has run into the issue.

    Example of code where it works (live site has not been updated and the test site is private for obvious reasons):

    1. Default manual download URL:

    
    <img class="alignnone wp-image-3442" style="margin: 0px 20px 0px 20px;" src="/wp-content/uploads/2017/02/Play-key.png" alt="" width="13" height="12" /><a id="manual" href="https://manuals.seesnake.com/cs6xversa/en/" target="_blank" rel="noopener noreferrer">Download Manual</a>
    

    2. Script initiation:

    
    <script>
        var pathArray = window.location.pathname.split( '/' );
        var secondLevelLocation = pathArray[1];
    </script>
    

    3. Script itself:

    
    <script>
    if (secondLevelLocation == "es") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/es/";
    }else if (secondLevelLocation == "da") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/da/";
    }else if (secondLevelLocation == "nl") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/nl/";
    }else if (secondLevelLocation == "fi") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/fi/";
    }else if (secondLevelLocation == "fr") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/fr/";
    }else if (secondLevelLocation == "de") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/de/";
    }else if (secondLevelLocation == "it") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/it/";
    }else if (secondLevelLocation == "ja") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/ja/";
    }else if (secondLevelLocation == "no") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/no/";
    }else if (secondLevelLocation == "sv") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/cs6xversa/sv/";
    }
    </script>
    

    Example of where the code does NOT work:
    1. Default manual URL:

    
    <img class="alignnone wp-image-3442" style="margin: 0px 20px 0px 20px;" src="/wp-content/uploads/2017/02/Play-key.png" alt="" width="13" height="12" /><a id="manual" href="https://manuals.seesnake.com/Manual/2561" target="_blank" rel="noopener noreferrer">Download Manual</a>
    

    2. Script initiation:

    
    <script>
        var pathArray = window.location.pathname.split( '/' );
        var secondLevelLocation = pathArray[1];
    </script>
    

    3. Script:

    
    <script>
    if (secondLevelLocation == "da") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/sr-20/da/";
    }else if (secondLevelLocation == "ja") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/sr-20/ja/;
    }else if (secondLevelLocation == "pl") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/sr-20/pl/;
    }else if (secondLevelLocation == "pt") {
        document.getElementById('manual').href = "https://manuals.seesnake.com/sr-20/pt/;
    }
    </script>
    

    Live pages (code might not be as updated here as in the test site)
    https://support.seesnake.com/cs6xversa/ (code functions)
    https://support.seesnake.com/sr-20/ (code does not function)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.