• Hi, is there a way to use this in the menu, where only one language option is displayed, and it toggles when clicked?

    For instance, my site is English by default, and the only other language I am using is Spanish. I would like for it to say ESPA?OL, but when it is clicked, for it to switch to ENGLISH, so only one language choice is shown? Right now I have 2 menu links using the shortcode for each language, but would like for only one to be available at a time.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi jacquid, can you please contact me here?

    info @ wp-studio dot net

    This would be a very small paid project. I don’t like charging but it’s my time involved. Let me know if you need my help.

    Thanks, Rob

    Thread Starter jacquid

    (@jacquid)

    I got this figured out- thanks!

    parkersteelco

    (@parkersteelco)

    @jacquid I am trying to accomplish this as well. Can you share what you were able to figure out?

    Thanx!

    Thread Starter jacquid

    (@jacquid)

    I ended up using the GTranslate plugin (https://www.ads-software.com/plugins/gtranslate/) because Google Language Translator had issues with functionality on tablet and mobile devices.

    However, my solution carried over, using CSS and js to target classes, and locale storage to set the user’s language and display the appropriate link.

    <script>
    (function($) { 
    var lang = localStorage.getItem('currentlang');
    $('.menu-item-gtranslate').eq(0).click(function() {
            localStorage.setItem('currentlang','eng');
            $('.menu-item-gtranslate').eq(1).css('display', 'inline-block');
            $('.menu-item-gtranslate').eq(0).css('display', 'none');
        });
    $('.glink').eq(2).click(function() {
            localStorage.setItem('currentlang','eng');
            $(this).next().css('display', 'block');
            $(this).css('display', 'none');
    //console.log(lang);
        });
    $('.menu-item-gtranslate').eq(1).click(function() {
            localStorage.setItem('currentlang','spn');
            $('.menu-item-gtranslate').eq(0).css('display', 'inline-block');
            $('.menu-item-gtranslate').eq(1).css('display', 'none');
        });
    $('.glink').eq(3).click(function() {
            localStorage.setItem('currentlang','spn');
            $(this).prev().css('display', 'block');
            $(this).css('display', 'none');
    //console.log(lang);
        });
    
    $(window).load(function() {
        if (lang=='eng'){
          $('.menu-item-gtranslate').eq(1).css('display', 'inline-block');
        }else{
          $('.menu-item-gtranslate').eq(0).css('display', 'inline-block');
        };
      });
    })(jQuery);
    </script>
    parkersteelco

    (@parkersteelco)

    Awesome! Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Toggle selection?’ is closed to new replies.