function hook_field_prepare_translation in Drupal 7
Define custom prepare_translation behavior for this module's field types.
Parameters
$entity_type: The type of $entity.
$entity: The entity for the operation.
$field: The field structure for the operation.
$instance: The instance structure for $field on $entity's bundle.
$langcode: The language associated to $items.
$items: $entity->{$field['field_name']}[$langcode], or an empty array if unset.
$source_entity: The source entity from which field values are being copied.
$source_langcode: The source language from which field values are being copied.
Related topics
1 function implements hook_field_prepare_translation()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- text_field_prepare_translation in modules/
field/ modules/ text/ text.module - Implements hook_field_prepare_translation().
1 invocation of hook_field_prepare_translation()
- field_attach_prepare_translation in modules/
field/ field.attach.inc - Prepares an entity for translation.
File
- modules/
field/ field.api.php, line 670 - Hooks provided by the Field module.
Code
function hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
// If the translating user is not permitted to use the assigned text format,
// we must not expose the source values.
$field_name = $field['field_name'];
$formats = filter_formats();
$format_id = $source_entity->{$field_name}[$source_langcode][0]['format'];
if (!filter_access($formats[$format_id])) {
$items = array();
}
}