Domanda

I am trying to translate articles/nodes on my site. I installed all required modules. enter image description here

I have a custom node type.

enter image description here

This custom node type has some fields that are translatable and not translatable.

enter image description here

I checked this checkbox enter image description here

I created custom view for the front page that contains nodes of custom type. But when I switch the language translation doesn't work.

Menu translation works. But the view nodes are not translated.

The interesting thing that if I visit my node by a full url path like this

http://test.net/node/1

Translation works fine.

I am outputting node properties in my template in the following way

          {{ node.title.value }}
   {{ node.field_description.value|raw }}
    {{ node.field_custom_body.value|raw }}

What can be wrong ?

EDIT

I have no option Content language selected for page

enter image description here

My view looks like this now

P.S I am using language switcher block to change language and it sets the session variable

enter image description here

È stato utile?

Soluzione

You have to configure a filter for the language in the the view:

FILTER CRITERIA

"Content: Translation language (= Content language selected for page)"


Btw. you have a big security problem in the node template, it is not allowed to apply the raw filter on a field that contains user input. You should use

{{ content.field_custom_body }}

instead to print the field.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a drupal.stackexchange
scroll top