You are here

function i18n_field_field_attach_view_alter in Internationalization 7

Implements hook_field_attach_view_alter().

File

i18n_field/i18n_field.module, line 319
Internationalization (i18n) module - Field handling

Code

function i18n_field_field_attach_view_alter(&$output, $context) {
  foreach (element_children($output) as $field_name) {
    $element =& $output[$field_name];
    if (!empty($element['#entity_type']) && !empty($element['#field_name']) && !empty($element['#bundle'])) {
      $instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);

      // Translate field title if set
      if (!empty($instance['label'])) {
        $element['#title'] = i18n_field_translate_property($instance, 'label');
      }

      // Translate field description if set
      if (!empty($instance['description'])) {
        $element['#description'] = i18n_field_translate_property($instance, 'description');
      }
    }
  }
}