Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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()));
}
}
}
}
Comment | File | Size | Author |
---|---|---|---|
#3 | views-data-export_translate-labels_2895264.patch | 763 bytes | tijsdeboeck |
Comments
Comment #2
enboig CreditAttribution: enboig commentedComment #3
tijsdeboeckRan into the same issue, and made a patch for this (exactly the same result as the original code example)
Comment #4
theemstra CreditAttribution: theemstra at XSbyte commentedPlease see https://www.drupal.org/node/1344592
Comment #5
theemstra CreditAttribution: theemstra at XSbyte commented