1

In our current project we use entity reference fields widely. There is quite a lot of content that already has translations.

Now we would like to enable translations of some of these entity reference fields.

When I did so I noticed that only the original language version of the nodes keep the contents of the fields - the translations show up with an empty entity reference field.

Did I just stumble into yet another Drupal gotcha? I looked through Drupal 8's issue queue but could not find anything related.

1

Normally you don't need to make the entity reference field translatable to translate the content. This is only necessary if you want to define for each language different target ids.

But this is a different issue. If you enable translation for a field the translated fields have not yet content. This is not specific to reference fields, it is the same for all field types. Only when you create new translations the field values are copied, so that the form is prefilled with the untranslated values. So if you change the field structure in this way and you want to start with all existing translations prefilled you may need an update script for the existing field data.

  • Thank you for your answer. You are right: We left these reference fields as not translatable on purpose so that it would be easier for the editors to wrap their heads around the system. And now we see that they need to vary content by language. Would you have any update scripts available somewhere for such a change? – Bernt Andreas Drange Sep 15 '17 at 11:24
  • Go through each entity of the content type, load the translations and fill the empty field with the untranslated values. – 4k4 Sep 15 '17 at 11:41

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.