Should it work automatically or would I have to enable it?

In #1443646: Multilingual site search it says to add "AND n.language = :curr_lang" to the query. I tried it. This seems to limit the suggestions to the language the user set in his profile. But I want it to use the active language of the site. So if a German user visits the English site, the search should suggest terms in English.

What would I have to change for that?

Related:
#192424: Language sensitive Search Autocomplete
#1443646: Multilingual site search

Comments

dom.’s picture

Hi!

In line 55 in search_autocomplete.module, the :curr_lang callback is replaced by $language->language. From what I see here, it seems it should work:
http://api.drupal.org/api/drupal/developer%21globals.php/global/language/7
#277675: Get current selected language

However, there's a difference between interface language and content language. You might consider changing $language to $language_content if you want the other one. (it's tricky to have a user who choosed German as a language but visits the English website). See here:
http://realguess.net/node/177

The best way would be for you to add a new callback in line 57:

if (strpos($query, ':site_lang')!== false) {
   $params[':site_lang'] = $language_content->language;
}

I guess you can determine the priority between site and user language at: admin/config/regional/language/configure but I never really tried!

Miro.

dom.’s picture

Status: Active » Fixed
dom.’s picture

Status: Fixed » Closed (fixed)
no2e’s picture

Status: Closed (fixed) » Active

To describe my use case:
I use i18n. If someone searches on the English site (example.org/en/…), he only gets English nodes -- no matter which user language he selected in his profile or what language he used for the search query.

So it isn't helpful when it (AND n.language = :curr_lang) displays the autocomplete terms in the user language, because those search terms only work for the site in that specific language.

You might consider changing $language to $language_content if you want the other one.

Do you mean AND n.language_content = :curr_lang?

Or do I have to edit/patch the module?

dom.’s picture

Hi !

See my answer number #1:
I would advice you to patch the module as suggested and use the :site_lang in your SQL query.

This kind of issue so much urgies me to finish 3.x version rapidely ! Using View to build your suggestions would solve all that kind of problems "magically" !

Miro

dom.’s picture

Status: Active » Closed (fixed)

Hi !

Have yuo tried 7.x-3.x ? It should solve your issue using VIEWS to create your suggestion list !