Search code examples
drupal-viewsmultilingualdrupal-8

Filters Raw value in Views on multilingual site?


On Drupal8, I have a View who filter nodes from 2 parameters (each is a Taxonomy ID from different vocabulary). So I have a path like /filter1/%/filter2/% where filter1 raw value is the path component 2 filter2 raw value is the path component 4.

It works fine on the default language on the site cause there's no langcode in the url. But when I switch to a different language the langcode is added to the path and it becomes /zh-hans/filter1/%/filter2/% or /fr/filter1/%/filter2/%.

At this point the view is not working correctly anymore cause filter1 raw value is the path component 3 and filter2 raw value is the path component 5.

Anybody knows how to solve that?


Solution

  • After working around I find out that my question was dumb. The view didn't worked in chinese but it was not about the thing I mentionned. I take a look to the condition with a hook_views_query_alter and saw that the arguments where retrieved correctly in the url whatever language the page is in...

    My problem was a I put a filter criteria on "Content: Translation language (= Interface text language selected for page)". I usually use it to display the result in the correct language. But in this case, it avoid results to display on other language than the default one. I don't understand why but it works without it and it serves the right translated nodes.