I'm using Symfony 2.6 and I'm trying to use translations inside my \Twig_Extension but translator always use and return the default_locale translated text. (in my case "EN")
I created a service in services.yml:
utils.twig_extension:
class: Skaphandrus\AppBundle\Twig\UtilsExtension
public: false
arguments: ["@service_container", "@translator.default"]
tags:
- { name: twig.extension, alias: utils.twig_extension }
and inside my extension:
private $container;
private $translator;
public function __construct($container, Translator $translator) {
$this->container = $container;
$this->translator = $translator;
}
And inside my method I have:
return $this->translator->trans('message');
But when I run the code it always return the "EN" locale message.
Thanks in advance for any help.