两个翻译文件具有不同的域,在一个模板内

时间:2014-12-11 21:00:10

标签: symfony translation


帮助我解决这个问题,我依靠你! 我已将翻译文件拆分为两个文件。 nav.fr.xlf& body.fr.xlf
两者都具有相同的结构:

    <?xml version="1.0"?>
    <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
        <file source-language="en" datatype="plaintext" original="file.ext">
            <body>
                <trans-unit id="1">
                    <source>Hello</source>
                    <target>Salut</target>
                </trans-unit>
</body>
    </file>
</xliff>

第二个是相同的,(反式单位的id相同) 在一个twig文件中我有这个

{% trans_default_domain "body" %}

在第二个:

{% trans_default_domain "nav" %}

只有一个翻译目录,它工作正常,但两者都有:我有这个错误

CRITICAL - Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("[ERROR 1871] Element '{urn:oasis:names:tc:xliff:document:1.2}b': This element is not expected. Expected is one of ( {urn:oasis:names:tc:xliff:document:1.2}g, {urn:oasis:names:tc:xliff:document:1.2}bpt, {urn:oasis:names:tc:xliff:document:1.2}ept, {urn:oasis:names:tc:xliff:document:1.2}ph, {urn:oasis:names:tc:xliff:document:1.2}it, {urn:oasis:names:tc:xliff:document:1.2}mrk, {urn:oasis:names:tc:xliff:document:1.2}x, {urn:oasis:names:tc:xliff:document:1.2}bx, {urn:oasis:names:tc:xliff:document:1.2}ex ). (in /usr/share/nginx/www/gitneargood/web/ - line 212, column 0) [ERROR 1871] Element '{urn:oasis:names:tc:xliff:document:1.2}b': This element is not expected. Expected is one of ( {urn:oasis:names:tc:xliff:document:1.2}g, {urn:oasis:names:tc:xliff:document:1.2}bpt, {urn:oasis:names:tc:xliff:document:1.2}ept, {urn:oasis:names:tc:xliff:document:1.2}ph, {urn:oasis:names:tc:xliff:document:1.2}it, {urn:oasis:names:tc:xliff:document:1.2}mrk, {urn:oasis:names:tc:xliff:document:1.2}x, {urn:oasis:names:tc:xliff:document:1.2}bx, {urn:oasis:names:tc:xliff:document:1.2}ex ). (in /usr/share/nginx/www/gitneargood/web/ - line 213, column 0)") in "ngNrBundle:Welcome:nav.html.twig" at line 40." at app/cache/prod/classes.php line 5131 
Context: {"exception":"Object(Twig_Error_Runtime)"}

请帮我解决一下

1 个答案:

答案 0 :(得分:2)

我的问题已经解决,我们不应该在翻译源/目标中使用html标签 编辑: 当然,Xlf文件是XML文件,插入html标签会破坏语法。 你可以做的是替换&lt;与&lt;和&gt;使用&gt;并在树枝中使用原始过滤器。
类似的东西:

'<strong>Hello</strong>'|trans|raw
相关问题