Search code examples
phpsymfonyinternationalizationtranslationxliff

Symfony2.3 issue with translations


I just try to translate my symfony 2.3 website, but I have an issue that I can not understand.

Here are my steps:

  1. added translator: { fallback: %locale% } in my config.yml, where %locale% is 'en' in my parameters
  2. I use the filters in my templates and extract all translatable texts with the JMS translate commande in app\Resources\translations\messages.fr.xliff.
    1. set the local of the users in a listener.

Now, 60% of my XLIFF is translated in french, And when I try to test the result, symfony does not use my file (in the cache folder I just have catalogue.en.php)

I'm working on this for hours and I reaaly don't know why it does not work.

Thank in advance for your help.


Solution

  • Thanks to meteor, I understood why my listener was not working.

    Here is how I set my local to make it work in all cases:

     $request->attributes->set('_locale', $locale);
     $request->getSession()->set('_locale', $locale);
     $request->setLocale($locale);