Views: Field "Translation Links" (& Views Translation)

Events happening in the community are now at Drupal community events on www.drupal.org.
Narretz's picture

Hello,
as I understand it, the Locale Module adds the Language Switcher, and i18n the Translation Links that appear directly in the nodes. So there should be a "Translation Link" Field option in Views, right? I was looking for it, but could not find it. i18n views .inc is only for language negotiation. In the views/modules/translation folder I found a .inc file named "views_handler_field_node_translation_link.inc" It appears that this would provide a translation link (although I am not sure):

<?php
// $Id: views_handler_field_node_translation_link.inc,v 1.1 2008/09/30 22:07:15 merlinofchaos Exp $
/**
* Field handler to present a link to the node.
*/
class views_handler_field_node_translation_link extends views_handler_field {
  function construct() {
    parent::construct();
    $this->additional_fields['nid'] = 'nid';
    $this->additional_fields['tnid'] = 'tnid';
    $this->additional_fields['title'] = 'title';
    $this->additional_fields['language'] = 'language';
  }

  function query() {
    $this->ensure_my_table();
    $this->add_additional_fields();
  }

  function render($values) {
    global $language;
    $tnid = $values->{$this->aliases['tnid']};
    // Only load translations if the node isn't in the current language.
    if ($values->{$this->aliases['language']} != $language->language) {
      $translations = translation_node_get_translations($tnid);
      if (isset($translations[$language->language])) {
        $values->{$this->aliases['nid']} = $translations[$language->language]->nid;
        $values->{$this->aliases['title']} = $translations[$language->language]->title;
      }
    }
    return l($values->{$this->aliases['title']}, "node/" . $values->{$this->aliases['nid']});
  }
}

But I wonder why it does not show in Views directly. This is true for some other handlers, too. Are they outdated or not compatible, and is it possible to fix this?

And another question regarding the translation of views strings via the Translate Interface option of i18n. Is it just me or do views strings appear under "Built-in interface" rather than "Views"? I rewrote the output of a Views field and found it under Built-in interface. Seems a bit strange to me.
And what's more, once I translated the strings from "Submitted by [name] on [created]" to "Verfasst von [name] am [created]", the date shows in English on the translation, when it should be German. In this case it was "Tue" that was not translated. So I searched for "Tue" with Translate interface, and actually found it as a single string in the corresponding node. Day names (abbreviations too) are already translated.
Pretty odd.

Comments

Good question

wobblefoot's picture

I've been wondering the same thing. The i18n module claims to have some views translation capability but for the life of me I can't see it. I've searched and given up on three occasions now for documentation that reveals this secret. If anyone's stumbled upon this functionality, perhaps you could leave a little trail of breadcrumbs on your way back out for the rest of us poor lost souls.

Internationalization

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: