Reputation: 3860
Help me go through this, I'm counting on you!
I have split my translation file into two files.
nav.fr.xlf & body.fr.xlf
Both have the same structure:
<?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>
The second one is the same, (same id for trans-unit) in one twig file I have this
{% trans_default_domain "body" %}
and in the second one :
{% trans_default_domain "nav" %}
With only one translation Catalogue, it works fine, but with both : I have this error
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)"}
Please help me go through it
Upvotes: 1
Views: 494
Reputation: 3860
My problem is solved, Shouldn't have used html tag inside a translation source/ target
Edit:
Well of course Xlf files are XML files and inserting html tags breaks the syntax.
What you can do is replacing < with <
and > with >
and use the raw filter in twig.
Something like:
'<strong>Hello</strong>'|trans|raw
Upvotes: 2