How to handle Translation in twig file using variables?

后端 未结 1 1918
星月不相逢
星月不相逢 2021-02-01 01:40

I have a twig file and a yml, in which I define the variables for translation

e.g.:

YML File -
variable.for.translation: Disponible

相关标签:
1条回答
  • 2021-02-01 02:26

    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.

    0 讨论(0)
提交回复
热议问题