Skip to:
Content
Pages
Categories
Search
Top
Bottom

qTranslate: internal url links not properly translated


  • jalbaiges
    Participant

    @jalbaiges

    Hello everybody,

    I am using qTranslate with bbPress. Content is properly displayed in every language, but internal links (to forums, to topics, to user profiles, etc.) are not translated, so when clicking on such a link you are always redirected to the main language.

    I believe this can be successfully addressed by applying some filter using “qtrans_convertURL”, but I don’t know where.

    Any suggestion?

    Thank you very much!

Viewing 3 replies - 1 through 3 (of 3 total)

  • jalbaiges
    Participant

    @jalbaiges

    Hello again.

    I have been fighting for a while with the issue and I finally got a solution. I will write it down just in case it could be useful for somebody. Let me say I believe it might exist a smarter solution than mine, so, if you find it, live a comment here, thanks.

    Two steps (bbPress 2.5.3):

    1) In qtranslate/qtranslate_hooks.php, add the following filters:

    add_filter( 'paginate_links', 'qtrans_convertURL' );
    add_filter( 'bbp_get_topic_permalink', 'qtrans_convertURL' );
    add_filter( 'bbp_get_reply_permalink', 'qtrans_convertURL' );
    add_filter( 'bbp_get_forum_permalink', 'qtrans_convertURL' );
    
    add_filter( 'bbp_get_favorites_permalink', 'qtrans_convertURL' );
    add_filter( 'bbp_get_subscriptions_permalink', 'qtrans_convertURL' );
    add_filter( 'bbp_get_user_profile_url', 'qtrans_convertURL' );
    add_filter( 'bbp_get_user_edit_profile_url', 'qtrans_convertURL' );
    add_filter( 'bbp_get_user_replies_created_url', 'qtrans_convertURL' );
    add_filter( 'bbp_get_user_topics_created_url', 'qtrans_convertURL' );

    First four are for the standard navigation inside the forums. Last six are for the user profile menu.

    2) In bbpress/includes/common/template.php, modify a couple of lines in bbp_get_breadcrumb() function:

    In line 2250, replace:

    $crumbs[] = '<a href="' . trailingslashit( home_url() ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';

    with

    $crumbs[] = '<a href="' . trailingslashit( qtrans_convertURL(home_url()) ) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';

    And in line 2267, replace:

    $crumbs[] = '<a href="' . esc_url( $root_url ) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>';

    with

    $crumbs[] = '<a href="' . esc_url( qtrans_convertURL($root_url) ) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>';

    That’s all! Hope it serves.


    ThePixelFirm
    Participant

    @thepixelfirm

    Thank you so much!!


    totorche
    Participant

    @totorche

    Thanks a lot !! Has been really userfull !

    I also had a problem with the login form. When I used the login form, it always redirected me on the main page of the forum but always in the main language.

    Te solve this problem, just modify another line in bbpress/includes/common/template.php on line 1181 :

    On line 1181, replace:
    $redirect_to = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

    with:
    $redirect_to = qtrans_convertURL(( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);

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