简体   繁体   中英

Symfony Translation not work

I've override FosUser profile templates in app/Resources/FosUserBundle

Every thing is ok but translations not working!.

example:

in app/Resources/translations/messages.en.yml :

foo.bar: baz

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

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

and there is no problem with locale: app.request.locale --> en

$ php bin/console debug:translation en

在此处输入图片说明

Has suggested by @gp_sflover symfony is not using the default messages catalog for manage the template, so you can add the new files FOSUserBundle.en.yml with the translation of force the trans filter to use the messages catalog as follow:

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

Hope this help

文档中所述 ,您应该将翻译消息文件messages.en.yml放置在文件夹app/Resources/FOSUserBundle/translations/

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