Closed (duplicate)
Project:
Drupal core
Version:
8.6.x-dev
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Sep 2016 at 12:06 UTC
Updated:
11 Oct 2023 at 10:33 UTC
Jump to comment: Most recent
Comments
Comment #2
jhalloran commentedI am having the same issue. Any advice would be appreciated.
Comment #3
mrk23 commentedIn 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'
Comment #4
bdeclerc commentedI 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,...)
Comment #5
pavelculacov commentedSame issue, for all. Somebody have solution. In Taxonomy same problem Link to content or Image link to content same bugs.
Comment #6
pavelculacov commentedSolution 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
Comment #7
caspervoogt commented@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)
Comment #8
caspervoogt commentedrelated, possible duplicate: https://www.drupal.org/node/2447821#comment-12058373
Comment #9
pavelculacov commentedSolution for view.
Is here Link to Entity get invalid language link in views.
Comment #10
caspervoogt commentedThanks 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.
Comment #11
nicrodgersStill an issue in 8.3.x-dev
Comment #12
pavelculacov commentedTo 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 :(
Comment #14
adrianavaz commentedTry adding Content: Path and then make a custom link with {{ path }}
That worked for me.
Comment #16
Anonymous (not verified) commentedI 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.
Comment #17
pavelculacov commentedSolution. Enable translation on image field. It more easy
Comment #18
roam2345 commenteddam just killed a fully translated site with this issue
Comment #19
christine2actes commentedSame 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 !
Comment #20
lendudeWorking 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.
Comment #21
kle commentedWorking workaround for me:
First I extend a new Formatter from Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php
Than I changed getEntityUrl() to
Dont know why, but these links contain the actual language...
Comment #23
markdcThis 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?
Comment #24
cri2mars commentedhi 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
Comment #25
bigboy commentedI 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!
Comment #26
cri2mars commentedyour welcome @bigboy
happy to be of some help
Comment #27
ahmed-ayman commentedI'm using the filter translation language set to interface language.
and it's working!
Comment #28
lissy commented@midobel of corse it is important to filter the current languague.
But that does not solve the problem here.
Comment #29
Pascal- commentedDuplicate of https://www.drupal.org/project/drupal/issues/2877994#comment-12915625
Comment #30
ivnishThank you #24!