在我使用的流体模板中
{f:translate(key:'LLL:path/to/file/locallang.xlf:Test', arguments: {0: 'Test'})}
locallang.xlf的内容:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2016-12-06T14:00:00Z" product-name="">
<header/>
<body>
<trans-unit id="Test" xml:space="preserve">
<source><![CDATA[mailto:info@example.org?Subject=%1$s&Body=Hello%0A]]></source>
</trans-unit>
</body>
</file>
</xliff>
输出:
mailto:info@example.org?Subject=Test&Body=Hello
locallang.xlf的内容:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2016-12-06T14:00:00Z" product-name="">
<header/>
<body>
<trans-unit id="Test" xml:space="preserve">
<source><![CDATA[mailto:info@example.org?Subject=%1$s&Body=Hello%0A%0A]]></source>
</trans-unit>
</body>
</file>
</xliff>
输出为空字符串
导致空输出的原因是什么,而不是预期的,编码的双重换行?
我刚刚发现了PHP错误消息:
#1: PHP Warning: vsprintf(): Too few arguments in LocalizationUtility.php line 115
答案 0 :(得分:1)
角色&#39;%&#39;应该被转义为&#39; %%&#39;如PHP documentation for sprintf
中所述这导致
<source><![CDATA[mailto:info@example.org?Subject=%1$s&Body=Hello%%0A%%0A]]></source>
而不是
<source><![CDATA[mailto:info@example.org?Subject=%1$s&Body=Hello%0A%0A]]></source>