0

I have this code inside node.html.twig

{{ 'string'|trans }}` 

I can see the string and translate it inside the UI but the string is never displayed I have also tried {% trans %} string {% endtrans %} and {{ 'string'|t }} and I have also tried using this with default Bartik theme.

NOTE: The site DOES show title and body translations of nodes correctly and I clear cache every time I try.

Getting the string to be translated from inside bartik_preprocess_node

$variables['transvar'] = t('new string for translation');

and inside node.html.twig

{{transvar}}

The string can be translated inside UI but still does not display translated string. Title/body are translated.

Interface and content language is detected by prefix /LANG/node/xx and node is displayed using node.html.twig with default bartik theme.

SOLUTION: Its seems that chrome was suffering from some weird caching problem. I had restarted chrome but apparently a computer restart was all it needed. When I restarted the problem was gone.

  • Can you try doing this in preprocess and send the string to twig – Ajay Reddy May 8 '18 at 6:50
  • Yes I did update my question it seems to be something with my installation I assume – GiorgosK May 8 '18 at 8:43
  • Can you kindly post the screenshot before and after clearing cache if possible? – Ajay Reddy May 8 '18 at 8:46
  • what do you mean ? nothing changes after clearing cache just the message that cache was cleared !!! – GiorgosK May 8 '18 at 9:47
  • The language of title/body (content) and t() (user interface) are not necessarily the same. How do you display the node and determine the language? – 4k4 May 8 '18 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.