function hook_field_attach_prepare_translation_alter

Perform alterations on field_attach_prepare_translation().

This hook is invoked after the field module has performed the operation.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity being prepared for translation.

$context: An associative array containing:

  • langcode: The language the entity will be translated to.
  • source_entity: The entity holding the field values to be translated.
  • source_langcode: The source language from which to translate.

Related topics

File

drupal/core/modules/field/field.api.php, line 1088

Code

function hook_field_attach_prepare_translation_alter(\Drupal\Core\Entity\EntityInterface $entity, $context) {
  if ($entity
    ->entityType() == 'custom_entity_type') {
    $entity->custom_field = $context['source_entity']->custom_field;
  }
}