如何在Symfony2翻译文件中强制换行 [英] How to force line break in Symfony2 translation file
问题描述
在我的messages.en.yml
中,我有一个条目用于纯文本的电子邮件正文,因此我不能使用任何HTML标记.现在,当我需要换行符并在其后添加一个空白行时,该换行符将出现在我的电子邮件正文中.
In my messages.en.yml
I have an entry that is used for an email body which is in plaintext, so I cannot use any HTML tags. Now when I need a line break and I add a blank line after, the line break appears in my email body.
但是,当我尝试使用以下非空行进行换行时,它不会中断换行.
But when I try to do a line break with a non empty line following, it does not break the lines.
email:
subject: My Subject
message: >
Hello %name%,
This is my second line
Best regards,
John Smith
Customer Care
这样到达我的邮箱
汤姆你好,
Hello Tom,
这是我的第二行
最诚挚的问候,约翰·史密斯客户服务中心
Best regards, John Smith Customer Care
我尝试使用HTML标记或我从PHP知道的\n
.但是,如果我在翻译文件中使用<br>
或<br />
并在树枝文件中应用了|raw
过滤器,则HTML标记仍会出现在我的电子邮件正文中.另外,如果我使用\n
强制换行,则不会给出换行符,而\n
也会出现在我的电子邮件中.
I've tried to play around with HTML tags or with the \n
which I know from PHP. But if I use <br>
or <br />
in the translation file and apply the |raw
filter in my twig file, the HTML tags still appear in my email body. And also if I use \n
to force a line break, no line break is given and instead, the \n
appear in my email as well.
现在如果后面有非空行,我该如何强制换行?
Now how can I force the line break if a non empty line is following?
推荐答案
使用|
email:
subject: My Subject
message: |
Hello %name%,
This is my second line
Best regards,
John Smith
Customer Care
这篇关于如何在Symfony2翻译文件中强制换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!