Drupal Translation Doesn't work
-
24-12-2020 - |
题
I am trying to translate articles/nodes on my site. I installed all required modules.
I have a custom node type.
This custom node type has some fields that are translatable and not translatable.
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
My view looks like this now
P.S I am using language switcher block to change language and it sets the session variable
解决方案
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.