简体   繁体   English

Symfony2.3翻译问题

[英]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. 我只是尝试翻译我的symfony 2.3网站,但是我有一个我无法理解的问题。

Here are my steps: 这是我的步骤:

  1. added translator: { fallback: %locale% } in my config.yml, where %locale% is 'en' in my parameters 在我的config.yml中添加了翻译器:{fallback:%locale%},其中我的参数中%locale%是'en'
  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. 我使用模板中的过滤器,并使用app \\ Resources \\ translations \\ messages.fr.xliff中的JMS转换命令提取所有可翻译的文本。
    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) 现在,我的XLIFF中有60%是用法语翻译的,当我尝试测试结果时,symfony不使用我的文件(在缓存文件夹中,我只有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); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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