• Resolved Archie Plugins

    (@archieplugins)


    Hello everyone. I have creaed a website and I am using your plugin. I have created a custom shortcode to create language switcher and use it in elementor menus.

    At desktop it works really well but when in mobile it does not work for every link.

    The code I have in the functions.php follows:

    add_shortcode('lang_link', 'trpc_custom_language_switcher_link', 10);
    function trpc_custom_language_switcher_link(){

    if ( apply_filters( 'trp_allow_tp_to_run', true ) ){
    $languages = trp_custom_language_switcher();
    $html = '';
    $current_language = get_locale();
    foreach ($languages as $name => $item) {




    if($item['language_code'] == $current_language){continue;}

    if($current_language == 'el'){
    $html .= $item['current_page_url'];
    }else{

    $cur = $item['current_page_url'];

    $html .= trpc_get_url_for_language('el',$cur);


    }



    }

    return $html;
    }
    }

    function strip_language_code($url, $language_code) {
    // Construct the pattern to match the language code
    $pattern = "/\/" . preg_quote($language_code, '/') . "\//";

    // Use preg_replace to remove the language code
    $cleaned_url = preg_replace($pattern, '/', $url);

    return $cleaned_url;
    }

    function trpc_get_url_for_language($lang = null, $url = null) {
    if ( ! class_exists('TRP_Translate_Press') )
    return $url;

    $trp = TRP_Translate_Press::get_trp_instance();
    $url_converter = $trp->get_component( 'url_converter' );

    return esc_url( $url_converter->get_url_for_language( $lang, $url, '' ) );
    }

    I use the langlink shortcode .When in mobile and when in greek everything works but when I visit the place in english the “EL” link does not work. Can you please help me?

    Thanks in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Alex

    (@alexcozmoslabs)

    Hello,

    Could you please provide some additional information to help us understand the issue better and consequently resolve it?

    Kindly share the exact URL you end up on when you click the “EL” link in English on a mobile device. If possible, could you also provide some screenshots demonstrating the issue? This would be very helpful as it would give us a clearer idea of what is happening.

    Best Regards,

    Thread Starter Archie Plugins

    (@archieplugins)

    Hello .

    The website is the following https://thermaspalesvos.com/ and if you browse it via a mobile device you will notice that the EL / EN on the mobile popup menu it does not work properly but the desktop version- which is the same shortcode (custom one) works great.

    Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    You have a custom language switcher made with Elementor on your website. We suggest using one of our pre defined switchers as we are not offering support for debugging custom ones, except the doc page, https://translatepress.com/docs/developers/custom-language-switcher/, where we try to guide the client though the process of making a custom language switcher.


    Kind Regards,

    • This reply was modified 2 months ago by Alex.
    Thread Starter Archie Plugins

    (@archieplugins)

    Dear @alexcozmoslabs I have used your code to create just a custom lang switcher I am using it with a shortcode via the elementor , but elementor does not interfere. I think that some other users have the same issue only when in mobile. At desktop screens everything runs smoothly.

    Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    Please try including it though a Text Elementor block instead. See if that helps.

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