4

I am having a problem with getting Entity Reference to behave with a multilingual Drupal 7 installation using field translation (Entity Translation).

I have a node called 'Features' which has a bunch of dummy content entered in the default English and also in French. I have another node called 'Products' with an Entity Reference field in it for selecting the features.

So far so good, on the English form I see what I expect; I can select some of the references and save out.

What the form looks like in English

When I create a French translation though, I see the following form:

What the form looks like in French

I don't see any of the entities when creating or editing a French translation. Now, this in itself isn't a problem (for me) because the same selections should be made across all translations, but when I go ahead and save the French version, it will deselect all of the references in the English version of the node too.

Might I be missing something obvious with this? Is this expected behavior?

  • I believe to translate title values using Entity Translation you also need to use the Title module. It's a shot in the dark, but it might be worth checking out. – Lester Peabody Aug 24 '14 at 22:11
  • Thanks for the suggestion Les! The title wasn't the issue in the end, but your idea did push me down the correct path. I'll stick an answer below to explain how I got around this. – PUncle Aug 25 '14 at 9:08
  • Glad I was able to give you a push in the right direction. – Lester Peabody Aug 25 '14 at 13:14
1

While this doesn't answer the behavior of the Entity Reference fields over different languages, switching the entity selection mode to a view seems to have solved it.

As suggested by Lester, I'm still unsure if the default 'Simple' selection mode was taking issue with the title of my fields, although rather than using the Title module - which can trip up other modules, i have found - I tend to keep the old title field and label it 'Administrative title' while adding a separate 'Translatable title' to work with - so in that sense there shouldn't have been an issue with the 'Simple' selection method.

Either way, setting up an Entity Reference View which displays and searches the 'Translatable title' of my Features node seems to have worked!


EDIT:

@Dan - these labels, are they node titles or fields which you created?

The issue with standard node titles is that they are different from other fields and as such are not 'entities' - this means that entity translation will not work on them. The workaround is to either use the Title module to replace the default title field with an entity (I had some issues with this), or use a different field which you create yourself.

Once the field you need to translate is an 'entity' (basically an field you create yourself, or one generated by the Title module) you can enable translation for it when adding the field to a content type.

Next you need to create a new view containing whatever content you want to use and click the + button to add an 'entity reference view'. After configuring this view with the fields you want to display and saving you should find that when editing the Entity Reference field in your content type, you can change the Entity selection mode to Views and select your newly created view.

I hope that makes sense!

  • Could you explain your method in more detail? I have the same problem as you and I'm not sure how to get it to work. I have a feed with items and type id which are matched to types with labels (but only in one language). I need to translate those. I tried Translated Entity Reference module but all items would be matched to the original language so I think I need to do it with a view like you did but couldn't figure it out. – dan2k3k4 Nov 21 '14 at 8:45
  • I am adding the contents of this comment to the answer as it was too long! – PUncle Nov 21 '14 at 13:05
  • The way I have it is that I created a content type "Category" and only used the title fields. I use Feeds Processor to fill this in and it's matched up as Entity Reference for my other content types (2 others) - the other content types have for example: 'type = 2' - and I guess Drupal just takes the 2nd Category created? As they were imported in order? No idea how it matches up really but it works :S anyway, I guess I could try the 'titles' module to see if that works for me. – dan2k3k4 Nov 21 '14 at 13:29
1

If you have enabled the i18n_taxonomy module disable it.

The problem is i18n_taxonomy tries to fill the available options, but no options are available by the i18n point of view because the use of two modules for transaltion.

So, again, disable i18n_taxonomy, or go ahead with this module and disable entity translation for taxonomy terms.

I've just come across exactly your behavior and at least, in my case was for having this two modules enabled.

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.