TYPO3流体转换视图助手:在xlf文件中使用“%0A%0A”时无输出

时间:2017-03-30 08:48:10

标签: typo3 fluid

在我使用的流体模板中

{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

1 个答案:

答案 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>