我正在编写一个纯文本邮件版本,我需要\ n用于新行。
几乎一切正常但我的transchoice过滤器有问题,正如我在断行被打印为文本而不是断行之前所说的那样
foo.twig.txt
{{ 'Foo.plain.intro'|transchoice(nr, {'%nr%': nr, '%name%': entity.name}) }}
messages.en
首先尝试:
Foo.hello.test: '{1} Hello %name% \n there is one test found. \n See you later. | ]1,Inf[ Hello %name%, \n there are %nr% tests found. \n See you later.'
第一次尝试后,一个元素的输出是:
Hello tester \n there is one test found. \n See you later.
第二次尝试:
Foo.hello.test: "{1} Hello %name% \n there is one test found. \n See you later. | ]1,Inf[ Hello %name%, \n there are %nr% tests found. \n See you later."
第二次输出:
{1} Hello tester
there is one test found.
See you later.
第三次尝试:
Foo.hello.test: '{1} "Hello %name% \n there is one test found. \n See you later." | ]1,Inf[ "Hello %name%, \n there are %nr% tests found. \n See you later."'
第三输出:
"Hello tester \n there is one test found \n See you later."
我还尝试更改包括原始过滤器的树枝部分:
{{ 'Foo.plain.intro'|transchoice(nr, {'%nr%': nr, '%name%': entity.name})|raw }}
对于第三次尝试,包括原始过滤器,输出为:
"Hello tester \n there is one test found \n See you later."
是否存在类似的形式,对于普通翻译字符串,翻译必须使用双引号来识别\ n:
messages.en
Foo.hello: "Hello %name%, \n see you later"