Symfony2 translation of long texts Symfony2 translation of long texts symfony symfony

Symfony2 translation of long texts


You can have long texts in .yml translation file as well as html tags. Put your Terms Of Service text in messages.xx.yml file like this:

TermsOfServiceText: >  <p>Here goes my Terms of service code</p>  <p>It can be put in several lines and <strong>can include html tags!</strong></p>  <p>It can also include <a href="http://symfony.com/doc/current/book/translation.html" rel="nofollow">links</a></p>  <p>Just make sure that you put '>' sign after your translation keyword like in the first line of this example code   and start your message in next line with double space indentation</p>

Now, in your twig template call translation with this:

{{ 'TermsOfServiceText'|trans|raw }}

raw is used to skip escaping html tags.


I don't think that different templates could be as solution. But feel free to choose what you prefer. I'll go with https://github.com/stof/StofDoctrineExtensionsBundle in particular with the Translatable behaviour.