view raw
eav eav - 5 months ago 72
Twig Question

Translate messages inside twig in symfony2

I'm trying to access to the translations via twig.

For example, I have the name of my application inside my


My controller does only a render of the twig file.

And inside my twig-file I want to access to the property which is defined inside the messages-file (yml)

How can I access to this property to get the application name (let's say it contains some language-specific information)

I tried these methods, and failed:

  • {{ }}

    • Looks more like for variables which have been sent through the controller, I've got an error, that the variable 'application' was not found

  • {% trans% } {% endtrans %}

    • displays

  • {% trans% } '' {% endtrans %}

    • displays ''


With inline notation you should use filter:

{{ ''|trans }}

With trans tag I think problem in whitespaces around