how am I supposed to get line breaks working in Symfony 2.4?
#messages.de.yml
foo: |
Hello i am a line
Hello i am a new line
and
#messages.de.yml
foo: >
Hello i am a line
Hello i am a new line
twig
#template.html.twig
{{ 'foo'|trans }}
The translation is working but line breaks aren't.
The documentation isn't really clear to me. Hints will be highly appreciated.
In your YAML file use:
foo: |
first line
second line
and in your TWIG file:
<p>{{ 'foo'|trans|nl2br }}</p>
tested on:
Twig does not convert line feeds to <br />
automatically.
Use the nl2br filter.
#template.html.twig
{{ 'foo'|trans|nl2br }}
I'm not quite sure but eventually you'll have to add \n
to the translation strings additonally.
#messages.<locale>.yml
foo: >
Hello i am a line \n
Hello i am a new line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With