简体   繁体   中英

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.

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); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM