For some of my entity reference fields I'm using "Views: Filter by an entity reference views" as reference method. I've configured those views to use the current interface language for rendering (with fallback to default lang).

enter image description here

The interface language selection basically works (in other view blocks, or when previewing in /admin/structure/views), but it does not work when used as source for an entity reference field:

  • In my admin interface I'm using I've got a paragraph with an ER field using such a view as source. The paragraph always shows the title in default lang
  • On the frontend I've got a webform select field using the same view as source. The select options are always rendering in default lang.
  • When using the default reference method I do get translated titles in both use cases.
  • As stated above, the correct language is used in preview on /admin/structure/views

How can I select the correct language for my view-filtered ER fields?

(Please note that I can not use the interface language as filter criteria, because this would disable the language fallback.)

This question has an open bounty worth +100 reputation from Hudri ending in 7 days.

This question has not received enough attention.

  • Under filter criteria section, remove "Content: Default translation" and add " Content: Translation language (= Interface text language selected for page)" – lamp5 Dec 12 '18 at 15:33
  • This would disable the fallback functionality to default language if the entity is not translated into the current interface language. – Hudri Dec 12 '18 at 15:58
  • Facing the same problem. I'm using the view for getting the list of ER. And inside the view titles are translated. But when I'm using the view from webform module for selecting the options I'm always getting content titles in default language. @Hudri, did you find solution for this? – MilanG 7 hours ago

You'll need to use the translation_views module.

Here's a screenshot of my views filter configuration:

enter image description here

The logic is simple, if the node has no translations then show the original language, otherwise show the translation language.

I use the translation_views module to get the Translation counter filter.

  • Thanks, but this is not feasible in this case, because I need the language fallback (to the default lang, if translation is missing). See @lamp5's comment and the follow-up comment on the original question. – Hudri 1 hour ago
  • Ok, so after 45 minutes of trial and error I finally found the solution. Take a look at the updated answer :) – Jdrupal 25 mins ago
  • Interesting approach, I'm already using translation_views on my projects, but can't test it right now due workload. Why are you using Original language = Site default instead of Default translation = true in the first filter group? I think with default translation the fallback would work in both directions, while original language would only work one-way from default to other. – Hudri 13 mins ago
  • I think that was a mistake, updated the answer. Look forward to hear from you when you have tested it :) – Jdrupal 5 mins ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.