'relationship' => array(
      'title' => t('Translations'),
      'help' => t('Versions of content in different languages.'),
      'base' => 'node',
      'base field' => 'tnid',
      'relationship table' => 'node',
      'relationship field' => 'nid',
      'handler' => 'views_handler_relationship_translation',
      'label' => t('Translations'),
    ),

I believe that should read:
'relationship field' => 'tnid',

Specifying nid restricts the relationship to the translation source, rather than all nodes in the translation set (and I believe the latter is the intention for the relationship).

My use case involves entity reference relationship in conjunction with this Translations relationship, specifying the "current language" as the translation of interest. The translations relationship "uses" the "content entity referenced from (entity reference field)" relationship.

Before I would only see results if the entity reference fields were specifying the source translation nodes.

With the change Views returns the appropriate translations no matter which node in the translation set was specified in the entity reference field.

Recreating the issue

  • Install Drupal 7 with Standard profile, contributed modules ctools, views, i18n, i18nviews, variable, add second language (e.g. German) in Drupal configuration and edit content type Article to be multilingual and translatable.
  • Add an English article and then a German translation of it.
  • Add a new view with a page to list content of type articles with format fields filtered by 'Content: Language' to be German and a menu for easily accessing it
  • Add a required 'Content translation: Translations' relationship with 'Translation option' as English to the view
  • Besides the default 'Content: title' field add a second 'Content: title' field with 'Relationship' set to 'Translations' and save the view
  • Go to the homepage and click on the menu of the new view

Without the patch in #1 you will not see any result, the patch applied corrects this so that the view result is listing one row with the German and the English title.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jweowu’s picture

Status: Active » Needs review
FileSize
1.01 KB
doublejosh’s picture

I have a similar problem, but this patch still does not allow me to display translated versions of referenced entities.
Believe that was the intent.

Relationships in this area get pretty mind-numbing.

broon’s picture

Status: Needs review » Reviewed & tested by the community

I had the same problem. In my view I listed all nodes (regardless of language) and in each row I wanted to display the titles of all translations. It only worked for node that were also the source nodes of a translation set. This patch fixed that issue.

b33tl3’s picture

I'm having the same issue (as Paul #3) with views 7.X-3.7 :
trying to display all translated nodes Id for a given node id.
The pb is I have results only when my input (contextual filter) is the source node of the translation ... no result otherwise.
This patch fixes that issue. :)

Thanks Paul,
Many thanks jweowu.

meichr’s picture

Issue summary: View changes

Added recreation steps.

meichr’s picture

Status: Reviewed & tested by the community » Needs review

Resetting to 'Needs review' to point this issue out to views maintainers.

meichr’s picture

Status: Needs review » Reviewed & tested by the community

Got advice to set this back to "Reviewed & tested by the community" as the correct status. Thanks.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for providing the good issue summary, this really helps.

Committed and pushed

  • dawehner committed f510a92 on 7.x-3.x authored by jweowu
    Issue #1940212 by jweowu: "Content translation: Translations"...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jantoine’s picture

This change causes the node table to join all nodes without any translations to each other because they all have the default tnid value of '0'. See #2638220: "Content translation: Translations" relationship broken for a patch to fix this.