Support » Plugins » [qTranslate] HOME menu link resets selected language back to defalut

  • Hello,

    I use qTranslate plugin and WP anniversary theme.

    My default language is Polish. The second one is English.
    When I’m on English version i.e. and click on NEWS (HOME) menu link, my site switches back to default language.

    I saw several answers on qTranslate forum but with no PHP knowledge I can’t say which one is appriopriate.

    Thanks in advance!

Viewing 11 replies - 1 through 11 (of 11 total)
  • I had the same problem and I just found out a way it worked for me. I am using a child theme of TwentyTen and in de wp-nav menu the home link menu item (it is a post home so no page!) switched back to the default language.
    I found it here:link
    Put it in your childtheme functions.php

    // Fix for qTranslate plugin and "Home" menu link reverting back to default language
    if (function_exists('qtrans_convertURL')) {
    function qtrans_in_nav_el($output, $item, $depth, $args) {
    $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
    $attributes .=!empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
    $attributes .=!empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
    // Integration with qTranslate Plugin
    $attributes .=!empty($item->url) ? ' href="' . esc_attr( qtrans_convertURL($item->url) ) . '"' : '';
    $output = $args->before;
    $output .= '<a' . $attributes . '>';
    $output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
    $output .= '</a>';
    $output .= $args->after;
    return $output;
    add_filter('walker_nav_menu_start_el', 'qtrans_in_nav_el', 10, 4);

    Another solution which worked fine for me I found here:

    promopix Your solution is the best !
    Thanks !

    grate solution thanks for promopix

    Thank you promopix for sharing !! 🙂

    For some reason I am not able to use this work around, so I used javascript to fix the menu which I found here.

    var lang = jQuery(“html”).attr(“lang”);
    if ( lang == “en-US”) {
    var href = jQuery(“#menu-item-402”).find(“a”).attr(“href”);
    jQuery(“#menu-item-402”).find(“a”).attr(“href”, href + “/en”);

    Hope this help somebody in future.

    in my opinion the best work arround (works with banner-link and home-nav-link):

    add this code to your functions.php

    function qtrans_convertHomeURL($url, $what) {
        if($what=='/') return qtrans_convertURL($url);
        return $url;
    add_filter('home_url', 'qtrans_convertHomeURL', 10, 2);

    i found this solution here

    i just found out that the additional plugin “qTranslate slug” fixed this problem allready. if you also want to translate url slugs of pages und posts, you want this plugin anyway.

    Tschan, the code you suggested worked perfectly for me!

    Also tried qTranslate slug but found this awkward bug.

    Thank you very much!

    Hi guys,

    I am having the same problem but it is the other menu items that reverts back to default language instead of Home. Any help, or can Tschan modify the code such that it works for my other links generated from the WordPress Menu?

    Thanks in advance.

    Thanks everyone for sharing the solutions.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[qTranslate] HOME menu link resets selected language back to defalut’ is closed to new replies.