1 field.api.php hook_field_attach_prepare_translation_alter(&$entity, $context)

Perform alterations on field_attach_prepare_translation().

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

Parameters

$entity: The entity being prepared for translation.

$context: An associative array containing:

  • entity_type: The type of $entity; e.g. 'node' or 'user'.
  • langcode: The language the entity has to be translated in.
  • source_entity: The entity holding the field values to be translated.
  • source_langcode: The source language from which translate.

Related topics

File

core/modules/field/field.api.php, line 1557
Hooks provided by the Field module.

Code

function hook_field_attach_prepare_translation_alter(&$entity, $context) {
  if ($context['entity_type'] == 'custom_entity_type') {
    $entity->custom_field = $context['source_entity']->custom_field;
  }
}