Page translation works, footer translation does not

I work with:

I have pages:

form.en.md
form.cs.md
form.sk.md
...

Everything works as it should, but I also need to translate the footer of the website so that the text in it is translated, I wanted to solve it using the languages.yaml file, but I also need to insert links in the footer, which I can’t do in the .yalm file.

The problem is as follows, the documentation says that I can work with a file in a template, for example: templates/default.sk.html.twig
So I assumed that with the file: templates/partials/footer.sk.html.twig

But I can’t do that, the language isn’t translated and the template still only works with basic files:

templates / default.html.twig
templates / partials / footer.html.twig

What am I doing wrong does this someone understand where I am making a mistake?

Thank you guys!

@Deight

I also need to insert links in the footer

  • How do your Twig snippet for the link look like?

which I can’t do in the .yalm file

  • What have you tried so far?

I don’t know if I understand what you’re asking?

I created a file: default.sk.twig
Into which I changed the path to the base:

{% extends 'partials/base.sk.html.twig' %}

and i created a file: base.sk.html.twig
Into which I changed the path to the footer.

     {% block footer%}
         {% include 'partials / footer.sk.html.twig'%}
     {% endblock%}

I tried:

FOOTER: '<a href="link" target="_blank">Contact</a>'

FOOTER: "<a href='link' target='_blank'>Contact</a>"

"[I'm an inline-style link](https://www.google.com)"

@Deight, No need to use language specific templates.

  • Create file user/languages/sk.yaml and add:

    FOOTER: '<a href="link" target="_blank">Kontakt</a>'
    
  • Create file user/languages/en.yaml and add:

    FOOTER: '<a href="link" target="_blank">Contact</a>'
    
  • In template '/user/themes/your-child-theme/templates/partials/footer.html.twig` add:

    {{ 'FOOTER' | t | raw }}
    

Note that filter raw is required to insert html into the page.

2 Likes

Don’t get me wrong, but I really like you, 2 hours of rehearsals and you helped me a lot again, thank you!