function i18n_taxonomy_field_attach_prepare_translation_alter in Internationalization 7
Implements hook_field_attach_prepare_translation_alter().
Prepare and synchronize translation for term reference fields.
File
- i18n_taxonomy/
i18n_taxonomy.module, line 329 - i18n taxonomy module
Code
function i18n_taxonomy_field_attach_prepare_translation_alter(&$entity, $context) {
$entity_type = $context['entity_type'];
$source_entity = $context['source_entity'];
$options = array(
'default' => FALSE,
'deleted' => FALSE,
'language' => NULL,
);
// Determine the list of instances to iterate on.
list(, , $bundle) = entity_extract_ids($entity_type, $source_entity);
$instances = _field_invoke_get_instances($entity_type, $bundle, $options);
if (!empty($instances)) {
foreach ($instances as $field_info) {
$field = field_info_field($field_info['field_name']);
if ($field['type'] == 'taxonomy_term_reference' && isset($entity->{$field_info['field_name']})) {
// iterate over languages.
foreach ($entity->{$field_info['field_name']} as $language => &$items) {
i18n_taxonomy_field_prepare_translation($entity_type, $entity, $field, $field_info, $entity->language, $items, $source_entity, $source_entity->language);
}
}
}
}
}