Here is what I'm stuck on. I'm working on Symfony2 and trying to make the translations working. But somehow, I can't make it work as it should. Here's what I got. In the config.yml
translator: { fallback: de }
session:
default_locale: en
In messages.en.yml
I have this structure:
Please log in: Bitte melden Sie sich an
I also have similar files for messages.en_US.yml
, messages.ru.yml
, etc.
In the code I use $this->get('session')->setLocale('ru_RU');
to change the locale.
But the translation works only when the locale is set to "en_US" or "de_DE". In any other case it returns the key, not the value. I try the translation with this code
return new Response($this->get('translator')->trans('Please log in').' '.$this->get('session')->getLocale());
and it returns the locale I have set.
So what can cause this problem?