Symfony的翻译不行

问题描述:

我已经覆盖FosUser配置文件模板在app/Resources/FosUserBundleSymfony的翻译不行

每一件事情是确定的,但翻译不工作!

例如:

app/Resources/translations/messages.en.yml

foo.bar: baz 

app/Resources/FosUserBundle/views/Profile/show_contect.html.twig

{{ 'foo.bar' | trans }} --> output: foo.bar 

并且存在与区域没有问题:app.request.locale - >en

$ php bin/console debug:translation en 

enter image description here

+2

尝试创建'FOSUserBundle.en.yml'并将该文件放在'app/Resources/translations'中,然后让我知道。 PS:我从来没有使用过这个软件包。 –

+0

您的应用程序在得到错误结果时使用的语言环境是什么?您的语言环境相关的Symfony配置如何? – xabbuh

已经@gp_sflover symfony的建议不使用默认的邮件目录管理模板,这样你就可以与力的翻译添加新的文件FOSUserBundle.en.yml的反式过滤器使用messages目录如下:

{{ 'foo.bar' | |trans({}, 'messages') }} 

希望这有助于

正如stated in documentation,您应该将翻译消息文件messages.en.yml放入文件夹app/Resources/FOSUserBundle/translations/