'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.
Comment | File | Size | Author |
---|---|---|---|
#1 | views-translations_relationship-1940212-1.patch | 1.01 KB | jweowu |
Comments
Comment #1
jweowu CreditAttribution: jweowu commentedComment #2
doublejosh CreditAttribution: doublejosh commentedI 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.
Comment #3
broonI 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.
Comment #4
b33tl3 CreditAttribution: b33tl3 commentedI'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.
Comment #5
meichr CreditAttribution: meichr commentedAdded recreation steps.
Comment #6
meichr CreditAttribution: meichr as a volunteer commentedResetting to 'Needs review' to point this issue out to views maintainers.
Comment #7
meichr CreditAttribution: meichr as a volunteer commentedGot advice to set this back to "Reviewed & tested by the community" as the correct status. Thanks.
Comment #8
dawehnerThank you for providing the good issue summary, this really helps.
Committed and pushed
Comment #11
jantoine CreditAttribution: jantoine as a volunteer commentedThis 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.