如何在 Symfony2 翻译文件中强制换行 [英] How to force line break in Symfony2 translation file

查看:24
本文介绍了如何在 Symfony2 翻译文件中强制换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 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

这样到我的邮箱里

你好汤姆,

这是我的第二行

此致,John Smith 客户服务部

Best regards, John Smith Customer Care

我尝试过使用 HTML 标记或我从 PHP 中知道的 .但是如果我在翻译文件中使用 <br><br/> 并在我的 twig 文件中应用 |raw 过滤器,HTML 标签仍然出现在我的电子邮件正文中.此外,如果我使用 强制换行,则不会给出换行符,而是 也会出现在我的电子邮件中.

I've tried to play around with HTML tags or with the 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 to force a line break, no line break is given and instead, the 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆