Example set up:
Content type news with fields
- Body (translatable)
- date (another date field beside node published date - translatable)
- type of news (list field - not translatable, the news should be of the same type in every language)
View with filters:
- Published: yes
- Content type: news
- Content language: currently activated interface language
- field "type of news" -> exposed to the user
Default language in the project is German.
When I go to the view in German and choose a type of news in the exposed filter there is no problem - the expected news are listed. The problem appears when I enter the page in English and I choose a type of news -> no results are found although the same nodes are translated into English.
I found out that this is due to the fact that the "type of news" values in the fields table are saved with the language id of the original node which is 'de' but the full view query expects the field value to have a language code 'en' (like the currently activated language has).
See this query and especially the INNER JOIN:
SELECT node__field_date.field_date_value AS node__field_date_field_date_value, node_field_data.nid AS nid, node_field_data.langcode AS node_field_data_langcode
FROM
{node_field_data} node_field_data
INNER JOIN {node__field_news_typ} node__field_news_typ ON node_field_data.nid = node__field_news_typ.entity_id AND (node__field_news_typ.deleted = '0' AND node__field_news_typ.langcode = node_field_data.langcode)
LEFT JOIN {node__field_date} node__field_date ON node_field_data.nid = node__field_date.entity_id AND (node__field_date.deleted = '0' AND node__field_date.langcode = node_field_data.langcode)
WHERE (( (node__field_news_typ.field_news_typ_value = 'press') )AND(( (node_field_data.langcode IN ('en')) AND (node_field_data.status = '1') AND (node_field_data.type IN ('news')) )))
ORDER BY node__field_date_field_date_value DESC
LIMIT 10 OFFSET 0
You may see that the inner join expects the langcode field in node__field_news_typ to be the same value as node_field_data.langcode which is 'en' when I enter the view in English. But looking into the table of node__field_news_typ I do not find one entry with 'en' as the field is not set to be translatable and all the nodes are originally written in German.
Maybe I did not get some basics of the multilanguage architecture in Drupal 8 but I find it a little bit strange that fields which are not translatable filter out nodes in views where a filter is set to "current active language". Is there not UNDEFINED_LANGUAGE ('und') anymore? Why do fields get a fix languagecode when they are not translatable? How can I avoid this behavior?
It seems to me that there is no other way as setting the field to translatable although I want to assure that translated nodes have the same value?!