• Resolved rockfaceit

    (@rockfaceit)


    This is what we are trying to do:

    If the default ‘English’ language is displayed then the top right option (or dropdown) should be ‘Español’ (no flag)

    If the current language is ‘Español’ then the top right option (or dropdown) should be ‘Inglés’ (no flag)

    How do I achieve this?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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>

    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

    Plugin Author edo888

    (@edo888)

    Hi,

    You can just use Language names widget look and also add this CSS code: a.gt-current-lang{display:none}

    It will hide the current selected language. There is no point to use the Float look, since you only have 2 languages.

    Thanks! 🙂

    Thread Starter rockfaceit

    (@rockfaceit)

    Thanks! I got something nice working:

    https://staging.alanonventura.org

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.