WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
Making Relevanssi better at multilanguage (5 posts)

  1. Alex Ciobica
    Member
    Posted 3 years ago #

    Hello.

    I installed the plugin on a multilanguage site with qtranslate. The problem was that the results returned were displayed in both languages, as qtranslate saves multiple language versions in the field by encapsulating them in specialized tags. For example a title field would hold <!--:lang1-->Lang1 title<!--:--><!--:lang2-->Lang2 title<!--:-->.

    Now this is a creates a problem when activating Relevanssi with highlighting turned on as the titles are stripped of their tags before highlighting them, which outputs search results as "Lang1 titleLang2 title", for the example above.

    As simple fix for this would be to use the __() localization function.

    Transforming line 658 from:
    $post->post_title = strip_tags($post->post_title);
    to
    $post->post_title = strip_tags(__($post->post_title));
    would fix the problem.

    I hope you'll consider adding this to the next update.
    Thank you for all your hard work on this plugin!

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    Is that one occasion of the title the only place that needs fixing, or should I fix every place that accesses $post data? If it's just that then the fix is trivial.

  3. Alex Ciobica
    Member
    Posted 3 years ago #

    That seems to be the only place that produces the issue with qtranslate since the title is stripped of the language tags.

    I haven't tested your plugin exhaustively, and if I encounter other issues I'll let you know. For now, that sole change will do a world of good.

    Thank you!

  4. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    Ok, consider it done.

    Oh, does this work:

    $post->post_title = strip_tags(qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($post->post_title));

    Because it would seem to be a better option (with, of course, a check to see if the function exists).

  5. Alex Ciobica
    Member
    Posted 3 years ago #

    qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage works great.

    Thank you again!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags