Drupal - View: Link to content is always rendering in the default language

It's a bug and it's being worked on, the solution is provided and it's currently labeled as Needs review. Perhaps you can apply the patch and test yourself:

Entity Links fields does not have translation support

In Drupal 8.4 and earlier versions it was possible to use the workaround of Path field and using Custom text field to construct the link:

<a href="{{ path }}">{% trans %} View more {% endtrans %}</a>

The Path field output correctly translated links with correct path prefix, see here: Translate Content: Link to Content field on Views in Drupal 8. But in Drupal 8.5 the Path field is no longer supported, so you have to patch or wait for the update to gets released.


Add 2 fields to your view:

  1. a "Content: Node ID (Node ID)" field
  2. a "Content: Translation language (Translation language)" field.

Exclude the "Content: Node ID" field from display.


Override the output of this field with custom text:

{% trans %} View more {% endtrans %}

Rewrite the "Content: Translation Language" field as a custom link:

{{ langcode_value }}/node/{{ nid }}

Then go to admin/config/regional/translate.

You may translate View more in any desired language: FILTER TRANSLATABLE STRINGS (View more) and translate it according to language

Tags:

Views

8

I18N L10N