Saman Mohamadi
Saman Mohamadi

Reputation: 4672

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

enter image description here

Upvotes: 3

Views: 2234

Answers (2)

jkucharovic
jkucharovic

Reputation: 4244

As is stated in documentation, you should place translation messages file messages.en.yml in folder app/Resources/FOSUserBundle/translations/.

Upvotes: 0

Matteo
Matteo

Reputation: 39430

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

Upvotes: 4

Related Questions