Symfony2: HTML inside translation message

后端 未结 9 1798
醉话见心
醉话见心 2020-12-09 02:12

In messages.en.yml, I have

confirmed: Congrats %username%, your account is now activated.

But I want to \'bold\' username to

9条回答
  •  悲哀的现实
    2020-12-09 02:17

    Update 2

    In such cases, I started to use like this:

    confirmed: Congrats %start_link%%username%%end_link%, your account is now activated
    

    Since separation of concerns is maintained, this way is strongly recommended.


    Update

    In YAML, I have used translations like this without any problem:

    trans.key: click here to continue
    

    Although translations and design should be kept separated there are always some situations that you must use html tags inside translation files as it is also seen in huge projects like Facebook and Twitter.

    In such situations, you can use XLIFF format which is being recommended by Symfony. Inside translation file:

    
       confirmed
       Congrats %username%]]> , your account is now activated.
    
    

提交回复
热议问题