3
votes

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?

2
Maybe a filename convention problem? Try renaming messages.ru.yml to messages.ru_RU.yml - madflow
Have tried. Didn't help. Actually I guess it translates only the de_DE locale. Even in case of en_US, it takes the key. Are there any settings where it might be set to translate only specific language? - ArVan
hi ArVan we got an issue with 'ru' locale, non ASCII characters are not fetched correctly from .xliff; stackoverflow.com/questions/20130580/… did you experience something similar? - ChatCloud

2 Answers

5
votes

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

2
votes

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/