I have set language selection to "current language ande language neutral". If I search for, let's say "xyz" from Drupals standard search block form, the search result shows up correctly on the search results page. In the search box on that page (and also in the url) it shows:

"xyz language:en,und"

Is that how it is supposed to work? Seems a little bit strange and not so user friendly to add that string visibly.

And also: if I make a new search from the search results page and search for a new word using the search box on this page (deleting everything that was previously in the search box), then the i18n setting is no longer respected and "language:en,und" is not added to the search string in the search box (or url).

So, how should it work? A bug?

/Bengt

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jdanthinne’s picture

For the "language:en,und" added to the search box, it's the way the core search works. If you select a content type in the advanced search, you'll see that it adds a "type:article" in the query as well.
I recently made a patch in the Backdrop version that reselects checkboxes in the advanced search from and removes the "language:" and "type:" args in the query. I'll try to backport that to the D7 version.

jdanthinne’s picture

Status: Active » Needs work
jdanthinne’s picture

Status: Needs work » Needs review
FileSize
6.33 KB

That was easy…
Can you try this patch?

bengt’s picture

Thanks @jdanthinne, that seems to work!

But still there are maybe a coupel of modifications to do - or maybe I misunderstand something.

1. Language switching from search page
If I do a search, let's say in Swedish and get the results, and then on the Search results page change language to English using - in my case - Language Switcher Dropdown module - the search still shows the Swedish results and the url still shows

/search/node/meter language%3Asv%2Cund

And under Advanced search "Swedish" is still checked. So if I go on searching from the Search page, it will give me English results (if I don't manually change that under Advanced search.

2. Language options under Advanced search
Under Advanced search "Language neutral" is not an option, only (in my case) English and Swedish (by the way, I don't seem to be able to translate these two strings?). Shouldn't "Language neutral" be an option?

/Bengt

  • jdanthinne committed 5beac9a on 7.x-1.x
    [#2429531] : reselect types and languages in the advanced form, and adds...
jdanthinne’s picture

1. Language switching from search page
This is not a Custom Search issue. You can test it with Custom Search and you'll see the same result.
Switching language doesn't perform the search again, but reloads the url, and the search query doesn't change. Perhaps you should open an issue for the Language Switcher Dropdown that analyses the url and replaces the language code with the new one…

2. Language options under Advanced search
I've attached a new version of the patch that adds "Language neutral" to the list. Once more, the list is provided by Drupal core, so it's not really a Custom Search issue, but it's a nice idea to add it.
For the translations, just use the core translation page to do that (/admin/config/regional/translate/translate), I think that should work.