Reputation: 195
So, i'v used to use such method to prevent the views from being "dirty" with hardcoded values inside of the html tags:
Instead of using:
<div>Greetengs!</div>
I like to use (With Twig):
<div>{{ lang.greetengs }}</div>
With such code in the model:
<?php
/*
* Simple example
*/
$data['lang'] = parse_ini_file(PATH_TO_LANG_FILE);
echo $template->render($data);
Now I want to use Symfony for my projects. And I know that i can do the same thing there, but the question is:
Is there a built-in mechanism in Symfony to do the same thing i'v shown?
Upvotes: 0
Views: 48
Reputation: 983
There is one it's really well documented here : Translation
Then in you're twig view you'll just have to do this :
{{ 'greetengs' | trans }} // Trans being the value of locale stored in session ( 'en', 'de', 'fr' ...) or in the
Upvotes: 2