function i18n_taxonomy_field_prepare_translation in Internationalization 7
Prepare and synchronize translation for term reference fields
1 call to i18n_taxonomy_field_prepare_translation()
- i18n_taxonomy_field_attach_prepare_translation_alter in i18n_taxonomy/
i18n_taxonomy.module - Implements hook_field_attach_prepare_translation_alter().
1 string reference to 'i18n_taxonomy_field_prepare_translation'
- i18n_taxonomy_field_info_alter in i18n_taxonomy/
i18n_taxonomy.module - Implements hook_field_info_alter()
File
- i18n_taxonomy/
i18n_taxonomy.module, line 358 - i18n taxonomy module
Code
function i18n_taxonomy_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
foreach ($items as $index => $item) {
$term = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
if ($translation = i18n_taxonomy_term_get_translation($term, $langcode)) {
$items[$index] = array(
'taxonomy_term' => $translation,
'tid' => $translation->tid,
);
}
$field['settings']['options_list_callback'] = 'i18n_taxonomy_allowed_values';
}
}