Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1491394

    Hi,
    I have a problem and maybe somebody can help.
    I use the plugin Gtranslate everything works on desktop view but in mobile view there is no flag in the menu.
    Maybe somebody knows the problem and can help me?
    Thank you and best regards

    #1491440

    Hey walhai,

    Thank you for the update.

    The theme doesn’t natively support the translation plugin, but you can try this script in the functions.php file to move the translation flags inside the mobile menu.

    add_action('wp_footer', function() {
        ?>
        <script>
        jQuery(function($) {
            function moveGTranslate() {
                if ($(window).width() <= 768) {
                    var targetLi = $('.menu-item-3651.av-active-burger-items');
                    if (!targetLi.find('.gtranslate_wrapper').length) {
                        var gtranslate = $('.gtranslate_wrapper');
                        if (gtranslate.length && targetLi.length) {
                            gtranslate.appendTo(targetLi);
                        }
                    }
                }
            }
    
            moveGTranslate();
    
            $(window).on('resize', moveGTranslate);
        });
        </script>
        <?php
    }, 999);
    

    Best regards,
    Ismael

    #1491452

    Thank you very much for your help.
    It partially works. When I open the mobile view the flags are not visible but when I rotate the mobile the flags appear?
    I tried to change the window width but it does not work.
    Any idea??
    Thank you and regards

    #1491497

    Hi,

    Thank you for the update.

    Yes, your solution should work. It moves or creates the translation flags after clicking the mobile menu, ensuring they display correctly when the burger overlay is open.

    Best regards,
    Ismael

    #1491503

    Thank you!
    For everybody this worked for me:

    add_action(‘wp_footer’, function() {
    ?>
    <script>
    jQuery(function($){

    function moveGTranslate() {
    if ($(window).width() > 768) return;

    var targetLi = $(‘.menu-item-3651’); // Ziel-Menu-Punkt
    var gtrans = $(‘.gtranslate_wrapper’);

    // Nur verschieben, wenn beide vorhanden sind
    if (targetLi.length && gtrans.length && !targetLi.find(‘.gtranslate_wrapper’).length) {
    gtrans.appendTo(targetLi);
    }
    }

    // 1) Wiederholen bis GTranslate geladen ist
    var waitGT = setInterval(function(){
    if ($(‘.gtranslate_wrapper’).length) {
    clearInterval(waitGT);
    moveGTranslate();
    }
    }, 300);

    // 2) Wenn Burger-Menü geöffnet wird
    $(document).on(‘click’, ‘.av-hamburger’, function(){
    setTimeout(moveGTranslate, 200);
    });

    // 3) Bei Resize (z. B. Rotation)
    $(window).on(‘resize’, function(){
    setTimeout(moveGTranslate, 150);
    });

    });
    </script>
    <?php
    }, 999);

    This topic can be closed :))

    Best regards
    Barbara

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Problem with GTranslate in mobile menue’ is closed to new replies.