WordPress.org

Ready to get started?Download WordPress

Forums

qTranslate
[resolved] Solution: translating nav-menus in admin area (17 posts)

  1. brasofilo
    Member
    Posted 3 years ago #

    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?****

  2. chudoff.a
    Member
    Posted 3 years ago #

    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);

  3. brasofilo
    Member
    Posted 3 years ago #

    forgot to check qtranslate forums...

    thanks, chudoff.a, works perfectly

  4. Bev
    Member
    Posted 3 years ago #

    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.

  5. chudoff.a
    Member
    Posted 3 years ago #

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

  6. brasofilo
    Member
    Posted 3 years ago #

    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

  7. Bev
    Member
    Posted 3 years ago #

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

  8. brasofilo
    Member
    Posted 3 years ago #

    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

  9. Bev
    Member
    Posted 3 years ago #

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

  10. chudoff.a
    Member
    Posted 3 years ago #

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

  11. brasofilo
    Member
    Posted 3 years ago #

    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

  12. chudoff.a
    Member
    Posted 3 years ago #

    hm, not work for User area =(

  13. chudoff.a
    Member
    Posted 3 years ago #

    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 =)

  14. brasofilo
    Member
    Posted 2 years ago #

    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 }

  15. Aldi
    Member
    Posted 2 years ago #

    @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?

  16. brasofilo
    Member
    Posted 2 years ago #

    @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

  17. petemurray
    Member
    Posted 2 years ago #

    Workaround is to go to Appearance > Menu > then click Save Menu, which will update the menus with the new page titles

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic