Steps to reproduce:
* Enable Content Translation.
* Add a language (eg: French).
* Enable translation for a content type, eg: Page.
* Add some content, and translate it. I created nodes "Dog" (en) and "Chien" (fr).
* Add a view over your content type, with a page display, showing a table of fields.
* Add a field to the view "Link to Content".
* Look at the view output. Hover your cursor over the French link, notice it goes to an English path. See LinkResult.png

There's some code in LinkBase::addLangCode() that sounds like it should be relevant, but I see no evidence that it actually does anything. It looks like cruft left over from an old implementation. @dwehner in IRC agreed.

I guess we should add in EntityTranslationRenderTrait to LinkBase.

Comments

vasi created an issue. See original summary.

vasi’s picture

Status: Needs review » Active
vasi’s picture

Issue tags: +Needs tests
StatusFileSize
new3.93 KB
vasi’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: 2667086-3.patch, failed testing.

The last submitted patch, 3: 2667086-3.patch, failed testing.

vasi’s picture

Status: Needs work » Needs review
StatusFileSize
new5.51 KB
new1.57 KB
dawehner’s picture

Status: Needs review » Needs work

Looks perfectly, now we just need some additional test coverage

aerozeppelin’s picture

Status: Needs work » Needs review
StatusFileSize
new3.16 KB
new3.16 KB
new8.67 KB

Tests for #7.

The last submitted patch, 9: 2667086-9-test-only.patch, failed testing.

dawehner’s picture

Thank you @aerozeppelin for trying to write a test!

+++ b/core/modules/views_ui/src/Tests/TranslatedViewTest.php
@@ -86,4 +110,20 @@ public function testTranslatedStrings() {
+    $node = $this->drupalCreateNode(['type' => 'article']);
+    $this->drupalPostForm('fr/node/1/translations/add/en/fr', ['title[0][value]' => 'Translated article'], t('Save and keep published (this translation)'));
+    $edit = ['name[node.view_node]' => TRUE];
+    $this->drupalPostForm('admin/structure/views/nojs/add-handler/content_recent/block_1/field', $edit, t('Add and configure fields'));
+    $this->drupalPostForm('admin/structure/views/nojs/handler/content_recent/block_1/field/view_node', [], t('Apply'));
+    $this->drupalPostForm('admin/structure/views/nojs/handler/content_recent/block_1/filter/langcode', [], t('Remove'));
+    $this->drupalPostForm('admin/structure/views/view/content_recent', [], t('Save'));
+    $this->drupalPostForm('admin/structure/views/view/content_recent', [], t('Update preview'));

This test coverage does many things which are unrelated with the bug. a) It uses the UI to create nodes b) it uses the UI to configure the view and c) it uses the UI to look at the view. For faster and more safe tests we should a) Create the article via API b) Provide a preconfigured view and c) visit this view path rather than the preview.

aerozeppelin’s picture

StatusFileSize
new7.49 KB
new11.48 KB

Hopefully this is an improvement over #9.

dawehner’s picture

Oh yes, this is much better!

+++ b/core/modules/views_ui/src/Tests/TranslatedViewTest.php
@@ -15,7 +15,7 @@
-class TranslatedViewTest extends WebTestBase {
+class TranslatedViewTest extends UITestBase {

Do we need this?

aerozeppelin’s picture

I am assuming, we need it to load the pre reconfigured view.

dawehner’s picture

Sorry for being annoying, to be clear, this functionality is not about views_ui but rather about views itself, so ideally the test would live inside views. There you can still load the pre-configured view, when you use the ViewTestBase class.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

aerozeppelin’s picture

StatusFileSize
new11.65 KB
new4.37 KB

No worries, you are not being annoying. :D Thank you for taking your time out to critique my code, it helps me learn. Here is an attempt to write tests using ViewTestBase class.

Status: Needs review » Needs work

The last submitted patch, 17: 2667086-17.patch, failed testing.

dawehner’s picture

Sadly the patch doesn't apply :(

aerozeppelin’s picture

Status: Needs work » Needs review
StatusFileSize
new11.68 KB

Updated the patch for 8.1.x.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ckaotik’s picture

Status: Needs review » Needs work

Looks good so far! There's one thing we should keep in mind, though, and that is the access check in checkUrlAccess.

  protected function checkUrlAccess(ResultRow $row) {
    $url = $this->getUrlInfo($row);
    return $this->accessManager->checkNamedRoute($url->getRouteName(), $url->getRouteParameters(), $this->currentUser(), TRUE);
  }

I suspect this will lead to incorrect results when e.g. the translation source is published (= access granted) but the displayed translation is unpublished and the user doesn't have access to such unpublished entities. getUrlInfo() is implemented by the inheriting field plugins (e.g. EntityLink) and only uses $this->getEntity(). Thus, $url->getRouteParameters() contains the (source) language, so I'd guess we could fix this by overriding this?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
quietone’s picture

Status: Needs work » Closed (duplicate)
Issue tags: +Bug Smash Initiative
Related issues: +#2877994: Entity Links fields does not have translation support

This was fixed in a later issue #2877994: Entity Links fields does not have translation support. I am closing this as a duplicate and moving credit over to the other issue.

If that is wrong, reopen the issue, by setting the status to 'Active', and add a comment.

Thanks!