I use example from documentation http://symfony.com/doc/current/components/translation/introduction.html
public function mytestAction()
{
$this->get('session')->set('_locale', 'fr_FR');
$this->get('request')->setLocale('fr');
$translator = $this->get('translator');
$translator->addLoader('array', new \Symfony\Component\Translation\Loader\ArrayLoader());
$translator->addResource('array', array(
'Hello World!' => 'Bonjour',
), 'fr_FR');
$Bonjour = $translator->trans('Hello World!');
echo $Bonjour; exit;// I get Hello World
}
What do I wrong?
May be a problem with Symfony 2.5 Translation Component?
You are overriding the locale in your code.
Change $this->get('request')->setLocale('fr');
to $this->get('request')->setLocale('fr_FR');