I use a lot of Views tables and I haven't managed to translate their labels.

Is it possible already and I simply haven't managed to get it set up properly or could it be added in the future?

Comments

dalekseenko’s picture

Yeah, I have the same exact issue. View fields can be set up using only one language.

benCorpo’s picture

Category: feature » support
Status: Active » Needs review

In order to be able to translate labels, I have changed the following lines of codes to use the core "Locale" functionnality.

File views.module
In function: views_get_title()
Change all "returns" to include the t()

In function: theme_views_view_list()
Changed line (#1420):
$item .= "

" . $field['label'] . "

";
For:
$item .= "

" . t($field['label']) . "

";

In function: theme_views_view_table()
Added lines (around #1449)
foreach ($view->table_header as $idx => $col) {
$view->table_header[$idx] = t($col['data']);
}

Of course, once it is done, all you need is to go and translate the string using the regular "Translate" interface.

Hope this is usefull to some people.

lupus78’s picture

Thanks, this is very usefull!

Rob L’s picture

I'm trying to use the above technique to translate an option on one of my view fields.

My field name is 'Node: view link' and the option is 'read more'.

Should this option be picked up and translated by the changes from above, or do I need to apply the t() function somewhere else?

Thanks in advance.

rolodmonkey’s picture

Status: Needs review » Closed (won't fix)

This issue is two years old and for a version of Drupal that is no longer supported.