How to handle Translation in twig file using variables?

荒凉一梦 提交于 2019-12-02 17:53:43
user1037069

You were going on right track, what you missed is just to pass someVariable as a parameter to trans() in your Twig file as:

<h2>{{ "follow.us.in.twitter"|trans({'%someVariable%': someVariable}, "workend") }}</h2>

Now your message in Yml file should be as:

follow.us.in.twitter: Hola, Follow %someVariable% en Twitter

This should work. For more details and clarity you can refer the following: Symfony Book

Good Luck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!