Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter rockfaceit

    (@rockfaceit)

    Thanks! I got something nice working:

    https://staging.alanonventura.org

    Thread Starter rockfaceit

    (@rockfaceit)

    URL: https://staging.alanonventura.org/design-gallery

    If current_language is blank I want to display a shortcode for the ‘Spanish’ version. If current_language = ‘es’ I want to display a shortcode for ‘Inglés’ to display the ‘English’ version. Thanks

    Thread Starter rockfaceit

    (@rockfaceit)

    I have this code but it's not working because the current_language variable only updates upon page load and the gTranslate options do not reload the page

    <input type="button" id="YourButtonES" value="Español" />
    <input type="button" id="YourButtonEN" value="Inglés" />

    <script>

    buttonES = document.getElementById("YourButtonES");
    buttonEN = document.getElementById("YourButtonEN");
    buttonES.style.visibility = 'visible';
    buttonEN.style.visibility = 'hidden';

    var current_language = gt_get_cookie('googtrans').split('/').pop();
    console.log("current lang " + current_language);

    if (current_language === 'es') {
    buttonES.style.visibility = 'hidden';
    buttonEN.style.visibility = 'visible';
    } else {
    buttonES.style.visibility = 'visible';
    buttonEN.style.visibility = 'hidden';
    }

    //GTranslate code
    function gt_get_cookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');

    for(var i = 0; i <ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') {
    c = c.substring(1);
    }

    if (c.indexOf(name) == 0) {
    console.log(name.length);
    return c.substring(name.length, c.length);
    }
    }
    console.log('return');
    return "";
    }
    </script>

Viewing 3 replies - 1 through 3 (of 3 total)