I have standard taxonomy views and some custom blocks.
after click "link to content" field or imagefield linked to content page redirect always to node in source language, not to translation in current language.
how can I fix this?
Rendering language is set to 'Content language of view row', but I check other options

Comments

mrk23 created an issue. See original summary.

jhalloran’s picture

I am having the same issue. Any advice would be appreciated.

mrk23’s picture

In my site I made .tpl for this content type teaser with <a href="{{ url }}">{{ content.field_myimage }}</a> (for image field)
and <a href="{{ url }}">{{ 'Read more'|t }}</a> (for link).
And image field in Manage display > Teaser must be set to 'Link image to Nothing'

bdeclerc’s picture

I see the same behaviour when using the "Content: Path" field in a view configuration - the view language is set to "Content language of view row" but the Path shown is that for the page language, not the view row language.

So a node translated three times will appear three times in the view, with all field content nicely translated for each entry, except the Path, which is identical across the three appearances and matches the language of the view itself (so /en/... in a /en/view , /fr/... in a /fr/view,...)

pavelculacov’s picture

Same issue, for all. Somebody have solution. In Taxonomy same problem Link to content or Image link to content same bugs.

pavelculacov’s picture

Solution is simple create custom View Field that get current language_code and with this code ovverite link for field there you that to be a link to field

caspervoogt’s picture

@Regnoy, that solution would work if all languages on the site have a language code in the URL path, but it doesn't work if your main language does not show a language code in its URL aliases/paths (as in my case).

When adding the Path field to a view, it should show the actual path of the content item in question, without extra steps needed, I would think.
It should not require some special relationship be added... but I tried and could find none that would work for this, anyway. It should not require an extra view field to get the current language code... even if that worked in all cases. I also don't think that making a custom TPL to fix this should be required. The Path view field should work correctly out of the box... no TPLs, no workarounds.

I am still looking for a solution for this one.

(Edit: I am using Drupal 8.2.8)

caspervoogt’s picture

pavelculacov’s picture

caspervoogt’s picture

Thanks Regnoy. I tried that but could not get it to work. I am running 8.2.8 and that issue is for 8.2.x-dev, and there are some code differences I guess. I have a workaround in place using a separate link field, and I will wait until the fix makes it into a release version.

nicrodgers’s picture

Version: 8.1.8 » 8.3.x-dev

Still an issue in 8.3.x-dev

pavelculacov’s picture

To solve this issue you must activate translation for field image(don't forgot to resave content type), after that will work perfect (if not work aplay path from link in comment #9). But i don't live activate translation for image to have link to content :(

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.

adrianavaz’s picture

Try adding Content: Path and then make a custom link with {{ path }}
That worked for me.

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.

Anonymous’s picture

I have the same issue. Does anyone know when this bug will be fixed? I know, that the workaround would be working with the {{ path }} rewriting rule, but I would prefer using the native functionality.

pavelculacov’s picture

Solution. Enable translation on image field. It more easy

roam2345’s picture

dam just killed a fully translated site with this issue

christine2actes’s picture

Same problem. I was using the "path" field to avoid this problem but it is no more available in Drupal 8.5.
All my views configured with the "path" field are no more usable after the update to Drupal 8.5 :-(
If someone has a solution... he's welcome !

lendude’s picture

Working on the fix here #2877994: Entity Links fields does not have translation support. Mostly because that issue has the most complete issue summary of the three duplicates.

kle’s picture

Working workaround for me:
First I extend a new Formatter from Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
Than I changed getEntityUrl() to

 protected function getEntityUrl(EntityInterface $entity) {
      // we want the link corresponding to the actual language: https://www.drupal.org/project/drupal/issues/2877994
    return = Url::fromRoute($entity->toUrl()->getRouteName(), ['node' => $entity->id()]);
 }

Dont know why, but these links contain the actual language...

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.

markdc’s picture

This seems like a duplicate of https://www.drupal.org/node/2862511 where there is a recently uploaded working patch. Can somebody please confirm and consider closing this issue?

cri2mars’s picture

hi all,
here is how i solved this problem

i have a custom entity called toile, fully translated
a view named gallery, overview of these entities, displayed as a grid, each item containing a link pointing to the entity

the problem was as described that whatever was the translation selected of that view, every link was pointing to the default langage entity... bad :-(

fortunately it can be solved using this method:

1- Add the Entity translation language field, in the fields of your view. note that it have to be below the link field, so you can use the link as a token:

2- Change the link field:

exclude from display
render URL as text (that way the pointing URL can be used as a token in URL rewriting...

3- Then we have to change the settings for the new Entity translation language field that way:

rewrite the field as a custom link using the available tokens below: {{ langcode__value }}{{ view_toile }} in my case
render the field as a custom text (as otherwise the URL should really look ugly as a link... {{ 'Zoom' }} in my case, helpful as it only has to be translated in russian ;-)

4- And finally you can add your view translations, and change the translated text displayed in your diferents languages if you have to...

In my case it totally solved the problem, i am using 8.6.2 core
hope it was clear and helpful
cheers

ps pics added to help you if needed in related issue #2877994

bigboy’s picture

I have the same issue and I did everything, like cri2mars described in #24 and it worked great in Views! But when I save it and switch back to home page, which view I'm trying to edit, I still get wrong links!

I just don't get it! It works in views edit form (links are displayed correctly, depending on language), but on frontpage it doesn't!

And the problem is only with node URL, I tried to add link to taxonomy category and it showed up correctly.

Come on, Dries, fix it!!! )))

UPD: somehow I managed to do it. Just was messing around with views and got it working. Thanks cri2mars!

cri2mars’s picture

your welcome @bigboy
happy to be of some help

ahmed-ayman’s picture

I'm using the filter translation language set to interface language.
and it's working!

lissy’s picture

@midobel of corse it is important to filter the current languague.
But that does not solve the problem here.

Pascal-’s picture

ivnish’s picture

Thank you #24!