When exporting to CSV label is not translated. Adding t() to _views_data_export_header_shared_preprocess() solves the problem.

function _views_data_export_header_shared_preprocess(&$vars) {
  $view     = $vars['view'];
  $fields   = &$view->field;
  $fields_info = $view->display_handler->get_option('fields');
  $vars['header'] = array();
  foreach ($fields as $key => $field) {
    if (empty($field->options['exclude'])) {
      if (isset($fields_info) && isset($fields_info[$key]['label'])) {
        $vars['header'][$key] = t(check_plain($fields_info[$key]['label']));
      }
      else {
        $vars['header'][$key] = t(check_plain($field->label()));
      }
    }
  }
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

enboig created an issue. See original summary.

enboig’s picture

tijsdeboeck’s picture

Ran into the same issue, and made a patch for this (exactly the same result as the original code example)

theemstra’s picture

Status: Active » Closed (duplicate)
theemstra’s picture