function properties_tmgmt_source_translation_structure in Dynamic properties 7
Implements hook_tmgmt_source_translation_structure().
Allows properties' values to be extracted and translated within TMGMT.
File
- ./
properties.module, line 981 - This module provides a dynamic property field that can contain an unlimited number of attribute value pairs.
Code
function properties_tmgmt_source_translation_structure($field_name, $entity_type, $entity, $field_instance) {
$field_lang = field_language($entity_type, $entity, $field_name);
$structure = array();
if (!empty($entity->{$field_name}[$field_lang])) {
$structure['#label'] = check_plain($field_instance['label']);
foreach ($entity->{$field_name}[$field_lang] as $delta => $value) {
$structure[$delta]['#label'] = t('Delta #@delta', array(
'@delta' => $delta,
));
$attribute = properties_attribute_load($value['attribute']);
// Translatable user text of attribute.
$structure[$delta]['value'] = array(
'#label' => $attribute->label,
'#text' => $value['value'],
'#translate' => TRUE,
);
// Machine name for attribute.
$structure[$delta]['attribute'] = array(
'#label' => $structure['#label'],
'#text' => $value['attribute'],
'#translate' => FALSE,
);
// Machine name for category.
$structure[$delta]['category'] = array(
'#label' => $structure['#label'],
'#text' => $value['category'],
'#translate' => FALSE,
);
}
}
return $structure;
}