Problem/Motivation

With Umami becoming multilingual #3037111: Import multilingual content into Umami - search should return only the results that are in current language.
Since Drupal core doesn't support such configuration, we should find a way to solve this.

This issue may be blocked by #3045362: Search for node content in current language or duplicates of each other.

Proposed resolution

I found a piece of code to modify search results to current language on https://www.expert-it.com/en/filter-search-results-language-selected-dru...
(didn't test it yet)

I found another code here https://www.drupal.org/project/drupal/issues/3005181
and added it to demo_umami.profile file.
(tested, it works!)

function demo_umami_query_search_node_search_alter(&$query) {
  $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
  $query->condition('i.langcode', array($language, 'und', 'zxx'), 'IN');
}

Another question would be how much customization is OK for an 'out of the box' Drupal demo?

Remaining tasks

Choose the best solution and implement it.

Comments

shaal created an issue. See original summary.

shaal’s picture

Status: Active » Needs review
StatusFileSize
new531 bytes

Initial patch, implementing search modifications.

A problem that needs to be resolved:
'Advanced search results' is not displaying the search result alteration of searching only in the current language, and marking a different language then current language ends up "Your search yielded no results."

Maybe it would be easier & better to modify the URL of the search result page?

for English:
/search/node?f[0]=language:en&keys=

for Spanish:
/search/node?f[0]=language:es&keys=

That way - there's less hacking, and advanced search result are showing the correct filters that are applied.

eli-t’s picture

We shouldn't provide custom functionality via code in Umami. It is to demonstrate what Drupal can do out of the box.

There are only exceptions for theming and the installation process.

gábor hojtsy’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Agree with @Eli-T.

Also how does the "error" look like, what happens when two are found of the same article/recipe translated?

shaal’s picture

StatusFileSize
new110.1 KB

@gabor here's the screenshot of searching for 'chocolate', that has results i both English and Spanish:

search-for-chocolate-in-both-languages

gábor hojtsy’s picture

Yeah hm that is quite unfortunate.

What does advanced search do?

Given #1853536: Reintroduce Views integration for search.module (not supporting backlinks view) umami could be using views as a search facility, since the "search box" is exposed as a views filter, but that would not be so nice either. I tried looking for an existing issue to filter search results by language but did not yet find one.

jasonawant’s picture

Issue summary: View changes

I added reference to #3045362: Search for node content in current language in the issue summary.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Version: 9.5.x-dev » 10.1.x-dev

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.