lordg
lordg

Reputation: 520

Drupal Views and label Translations

I have a view exported within a Feature. I want to make sure the custom labels are translated. The View display style is a table and I have a few custom labels for the headers instead of using the CCK default label. However, the label does not appear to be translatable.

Is it correct that I modify the line 'label' => 'Participant' to 'label' => t('Participant')? And what will this mean for future exports, will I have to modify the exported output every time when I have a change to make?

The below is a snippet from the $handler->override_option('fields' property of my view, which shows the title field, and the custom label.

'title' => array(
  'label' => 'Participant',
  'alter' => array(
    'alter_text' => 0,
    'text' => '',
    'make_link' => 1,
    'path' => '[field_participant_link_url]',
    'link_class' => '',
    'alt' => '',
    'prefix' => '',
    'suffix' => '',
    'target' => '_blank',
    'help' => '',
    'trim' => 0,
    'max_length' => '',
    'word_boundary' => 1,
    'ellipsis' => 1,
    'html' => 0,
    'strip_tags' => 1,
  ),
  'empty' => '',
  'hide_empty' => 0,
  'empty_zero' => 0,
  'link_to_node' => 0,
  'exclude' => 0,
  'id' => 'title',
  'table' => 'node',
  'field' => 'title',
  'relationship' => 'none',
  'override' => array(
    'button' => 'Use default',
  ),
),

Upvotes: 0

Views: 3321

Answers (3)

mimrock
mimrock

Reputation: 4883

You have two options.

  • Use insert_views module to create a view for every language and insert them in nodes:

  • Use custom labels, and an own module. Put the english strings in your module in a t, then you can export them easily with potx. Custom labels in views will be translated, if a translation is found by Drupal.

Upvotes: 0

lordg
lordg

Reputation: 520

The answer was it was unecessary. Drupal does translate the label if it is custom. If the label uses the default from a CCK, I believe it's up to the CCK module to translate it (didn't confirm this though). I just know that when I customised my labels, and provided a translated string for the label value in "Translate interface", the problem was resolved.

So in essence, I believe it would be wrong to translate 'label' => t('Participant'), in the above.

Upvotes: 0

Daniel Wehner
Daniel Wehner

Reputation: 2189

Alternative use the views3 version. There is some real translatable support via i18nviews.

Views provides some kind of pluggable translation system now.

Upvotes: 2

Related Questions