I am trying to set translations for my Symfony 3.1 Project. I have added the following line to my app/config/config.yml
:
translator: { fallback: en }
I have added a messages.en.yaml file in app/Resources/translations/
with just one string:
firstname: Test
Now i am trying to access it on my twig file like :
<h1>{% trans %} firstname {% endtrans %}</h1>
I also tried to translate the string on DefaultController.php and the same error happens there as well:
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\YamlFileLoader;
....
$translatedMessage = $this->get('translator')->trans('firstname');
var_dump($translatedMessage);
return $this->render('Default:index.html.twig');
When i try to access the page it gives me error like this:
The "yaml" translation loader is not registered.
I have tried installing all the following packages into my project as well like:
composer require symfony/yaml
composer require symfony/translation
Please help. I am not sure what to try next.