translationdrupal-8drupal-templates

Drupal 8 - Translate string from template


I have texts in different screens of my template that correspond to headers, links, etc. and that I need them to appear translated in my web page.

How can I enter words, text strings, etc. and put the translation in all the languages of my site from the admin?

Thank you.


Solution

  • in twig template you can translate value by this way :

    {{ "Most Recent"|t }}
    

    another example :

    <a class="button" href="#">{{ "Show most recent item"|t }}</a>
    

    more documentation here : https://www.drupal.org/docs/8/api/translation-api/overview