Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qtranslate plus support for Wordpress SEO by Yoast

Im using Qtranlate plus (https://wordpress.org/plugins/qtranslate-xp/) and i also use Wordpress seo by Yoast but the meta title and description fields cant be translated. Anyone have a fix for that or knows a plugin that fixes the issue?

like image 837
user2986959 Avatar asked Jan 20 '26 11:01

user2986959


1 Answers

This Problem exists since qTranslate wasn't plus. There is a fix, from Yoast: http://kb.yoast.com/article/52-wordpress-seo-qtranslate


function qtranslate_filter( $text ) {
  return __( $text );
}

add_filter( 'wpseo_title', 'qtranslate_filter', 10, 1 );
add_filter( 'wpseo_metadesc', 'qtranslate_filter', 10, 1 );
add_filter( 'wpseo_metakey', 'qtranslate_filter', 10, 1 );
add_filter( 'wpseo_opengraph_title', 'qtranslate_filter', 10, 1 );

This wasn't enough for me... i traced the $text and saw that the language syntax was broken. It wasn't

<!--:de-->, it was <!-:de->.

So i added a replacement for that directly in the qtranslate_filter($..).

function qtranslate_filter( $text ) {
    $fixedOpenTag = str_replace("<!-:", "<!--:", $text);
    $fixedCloseTag = str_replace("->", "-->", $fixedOpenTag);
    return __($fixedCloseTag);
}

This works for frontend output. I looked in the sourcecode of yoast but haven't fixed it by now...

like image 106
Julian Kimmig Avatar answered Jan 22 '26 00:01

Julian Kimmig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!