Score:0

EntityReference display french item when no english translation

cn flag

Ok... Maybe I don't understand the correct way to do this, but...

I have a (translatable) entity (entity1) with a entity_reference field embed by code (declared with baseFieldDefinitions method). This field is not translatable. The field embed another type of entity (entity2), which is translatable too.

I create two "entity2" entities in french, and translate only one. These two entities are attached to the field previously defined in entity1.

When displaying my instance of entity1 :

  1. In french, it display the two sub-entities in french
  2. In english, it display one sub-entity in english (the translated one) and the second in french (the not translated).

I tried to install entity_language_fallback without success, I tried some configuration without success too...

How to set my display showing ONLY existing sub-items switch language ?? I tried the same implementation with nodes (my node type embed an entity-reference field that can reference same type of nodes) and I have the same result... Is my logic wrong ? In d7, I remember that when a translation didn't exists, field display showed a "translation unavailable" for admin and didn't show any information for anonymous users...

Must I create a new entity-reference formatter and override the "getEntitiesToView" method to filter on language ?? I don't see other way actually, and I'm a little disappointed that the entity-reference field (and core itself) doesn't take care on language behavior.

If anyone has a suggestion it would be helpful.

Thanks in advance.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.