Question

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?

Was it helpful?

Solution 2

I found the answer myself. Just needed to clean up the cache for Symfony. Used console to do so. Changed directory to myProject/app and used this commands to clean the cache and logs:

sudo rm -R cache/
sudo rm -R logs/

OTHER TIPS

you should clear the cache by using the symfony comand

app/console cache:clear --no-debug

then eventually restore write permission on cache/ and log/ folders as described here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top