Problem/Motivation
When views are configured to display fields, and 'Rendered entity' is added as one of the fields, if an entity has any translations, for each view row that display that entity or its translation, the rendered entity displayed will ignore the 'Rendering language' configuration of the view display. A good example of such a view is the media_library view in the media_library module.
Steps to reproduce:
- On a multilingual site, configure a content type to be translatable.
- Create a node of that type.
- Add a translation of that node, and change the field values of the translation so differences are obvious.
- Create a content view.
- Configure the view to show fields.
- Add "Rendered entity" field
- Set the "Rendering Language" of the display to "Content language of view row".
- Preview the results, and observe that the node appears twice in the same language.
Proposed resolution
The view
method of \Drupal\views\Plugin\views\field\RenderedEntity
does not pass in a langcode to $view_builder->view()
, so the entity is rendered per the site content language negotiation configuration.
Getting the langcode from the entity translation renderer and passing it into $view_builder->view()
should provide the correct rendering language.