There are two commits that have been included in the entity_translation-7.x-1.0-beta6 release that impact the current version of field_collection (see issues #2438615 and #2849464). The function call '$handler->getFormLanguage()' returns now the 'active language', which might be different from the field_item_collection stored language.

The file 'includes/translation.handler.filed_collection_item.inc', inside the function 'getLanguage()' used to grab the $langcode from the entity, and if the current field was untranslatable ($lancode == LANGUAGE_NONE), then we tried to inherit the host entity language using 'getFormLanguage()'.

The code comments of this function now say that we can not use $this->entity->langcode() because we will end up in a loop, and we try immediately to grab the $langcode by using 'getFormLanguage()' on the host entity.

I don't know if this way of doing things was working before, but since the release entity_translation-7.x-1.0-beta6, I am not able to translate any fields collections marked as translatable. When updating a translation, for example in dutch, the entity_translation table entry for the french version of the field_collection_item is updated to dutch. For example before doing anything I have this situation:

this corresponds to a content type with a field_collection with one item in french (the original language) and another item in duch.

When I update the dutch version of the node, I would expect that nothing changes in this table regarding the language and source columns, but this is the outcome :

So while I was updating the field_collection_item 1470, the field_collection_item 1463 has changed from french to dutch !!

I have been trying to debug this situation and I have found that this patch solves the issue :

diff --git a/all/modules/contrib/field_collection/includes/translation.handler.field_collection_item.inc b/all/modules/contrib/field_collection/includes/translation.handler.field_collection_item.inc
index 866fdc5..c305b71 100644
--- a/all/modules/contrib/field_collection/includes/translation.handler.field_collection_item.inc
+++ b/all/modules/contrib/field_collection/includes/translation.handler.field_collection_item.inc
@@ -42,7 +42,7 @@
     // language.
     if (($host_entity_type = $this->entity->hostEntityType()) && entity_translation_enabled($host_entity_type) && ($host_entity = $this->entity->hostEntity())) {
       $handler = $this->factory->getHandler($host_entity_type, $host_entity);
-      $langcode = $handler->getFormLanguage();
+      $langcode = $handler->getLanguage();
     }
     // If the host entity is not translatable, use the default language
     // fallback.

This modification solves the issue for me, but I am not expert enough in both field_collection and/or entity_translation modules to be 100% confident about it.

Could anyone please try to reproduce my issue with the above module's versions, and tell me if this is the right thing to do ? To give you more details, the field collection is translatable and all the fields inside it. The content type is configured with multilingual support 'Enabled, with field translation'.

Thanks in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

unknownguy created an issue. See original summary.

yonailo’s picture

Issue summary: View changes
yonailo’s picture

Issue summary: View changes
jmuzz’s picture

Status: Active » Needs review
FileSize
745 bytes

Seems necessary.

CatherineOmega’s picture

This change seems to work for me.

Chris Matthews’s picture

Version: 7.x-1.0-beta12 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

The year old patch in #4 sill applies cleanly to the latest 7.x-1.x dev snapshot and works for me as well so changing the status to RTBC.

  • ram4nd committed f54fe1f on 7.x-1.x authored by jmuzz
    Issue #2907621 by jmuzz, unknownguy: Field collection translation...
ram4nd’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.