WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: qTranslate] Solution: translating nav-menus in admin area

[Resolved] [Plugin: qTranslate] Solution: translating nav-menus in admin area

  • brasofilo
    Member

    @brasofilo

    it’s quite a pain making custom menus with qtranslate code being displayed in WP interface

    i did the following edit to /wp-admin/includes/nav-menu.php:
    – line 82: from esc_html( $title ); to esc_html( __($title) );

    – line 236: encapsulate $title again with __(), so it’ll be:
    $output .= empty( $item->label ) ? esc_html( __($item->title) ) : esc_html( $item->label );

    now i can actually see what i’m doing with custom menus…
    :o)

    ****how can we incorporate this into qtranslate or WP?****

Viewing 15 replies - 1 through 15 (of 16 total)
  • I read fix this probem in Link
    function qtrans_menuitem( $menu_item ) {
    $menu_item->title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $menu_item->title );
    return $menu_item;
    }
    add_filter(‘wp_setup_nav_menu_item’, ‘qtrans_menuitem’, 0);

    brasofilo
    Member

    @brasofilo

    forgot to check qtranslate forums…

    thanks, chudoff.a, works perfectly

    Bev
    Member

    @bstofko

    This filter fix doesn’t work for me. Although the dashboard menu control looks nice and easy to read, the titles of the menus do not translate on the resulting website when I switch languages.

    BStofko, i know bat knonw’t how fix problem =(

    brasofilo
    Member

    @brasofilo

    BStofko & chudoff.a,

    as a matter of fact, the add_filter fix messed up with my page titles,
    they lost their titles’ translations

    i deleted the fix, and got back to the core edit of nav-menu.php

    Bev
    Member

    @bstofko

    I tried the core edit and it works perfectly, thanks for that.

    brasofilo
    Member

    @brasofilo

    forgot to mention, i’m using 2.5.14 and wordpress 3.0.4
    – apparently this shouldn’t be a problem with qtranslate 2.5.18

    Bev
    Member

    @bstofko

    I am using WordPress 3.1 and qtranslate 2.5.18 and it is a problem.

    what you fix in core? sory my englsh so bad =(

    brasofilo
    Member

    @brasofilo

    bad english no problem, me no native english country too..

    but, you read my post number 1??

    line 82 and 236 of wp-admin/includes/nav-menu.php

    hm, not work for User area =(

    i have new fix this problem.

    function qtrans_menuitem2( $item ) {
    	foreach ($item as $key=>$values){
    	$item[$key]->title = qtrans_useTermLib($values->title);
    }
    qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $item->title );
       return $item;
    }
    add_filter('wp_nav_menu_objects',      'qtrans_menuitem2', 0);
    
    function qtrans_menuitem( $menu_item ) {
       $menu_item->title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $menu_item->title );
       $menu_item->title = qtrans_useTermLib( $menu_item->title );
       return $menu_item;
    }
    add_filter('wp_setup_nav_menu_item',      'qtrans_menuitem', 0);

    It fix user-panel and admin panel. Use =)

    works like a charm, chudoff.a, thx

    same code with error prevention* in the pastebin : http://pastebin.com/CxHd8BD3

    * wrap everything with
    if ( function_exists("qtrans_useTermLib") ) { CHUDOFF.CODE }

    Aldi
    Member

    @bedex78

    @brasofilo

    I had tried chudoff.a’s fix but it doesn’t seem to automatically translate the menus in the front-end. Is this the case for you?

    @bedex78

    yes, same here… investigated the issue, but found no solution until now… will have to look at it in another time…

    it would be nice if someone more knowledgeable in wp_nav_menu could jump in

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Resolved] [Plugin: qTranslate] Solution: translating nav-menus in admin area’ is closed to new replies.