Line Breaks <br> in symfony2 XLIFF
internationalization, php, symfony, xliff, xml
Solution
You must use a CDATA section make sure your html tags are not misinterpreted as xliff :
<!-- messages.fr.xliff -->
<?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>Je suis Joe Schmoe</source>
<target><![CDATA[I am<br />Joe Schmoe]]></target>
</trans-unit>
</body>
</file>
</xliff>
After that, in your template, make sure the html is not escaped, use the raw tag :
{{'Je suis Joe Schmoe' | trans | raw }}
By the way, what the hell is this supposed to be ? `<x id='1' ctype='lb'/>`
Problem
I'm looking for a working solution, to use line-breaks (`<br />`) in symfony's XLIFF i18n files. Unfortunately, the default tag `<x id='1' ctype='lb'/>` seems to get stripped by Twig and/or symfony's XLIFF implementation. The XLIFF format is the recommended format for symfony2, so I'm wondering that there is no single line about line-breaks in symfony's cookbooks ? ``` <!-- messages.fr.xliff --> <?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>Je suis Joe Schmoe</source> <target>I am<x id="1" ctype="lb"/>Joe Schmoe</target> </trans-unit> </body> </file> </xliff> ``` Generic placeholder `<x/>` (deprecated) The `<x/>` element is used to replace any code of the original document. The required id attribute is used to reference the replaced code in the skeleton file. The optional `ctype` attribute allows you to specify what kind of attribute the placeholder represents; Source: XLIFF 1.2 specification ``` Line 1<x id='1' ctype='lb'/>line 2 ``` Edit 2: The `<x/>` element is deprecated - you can find this information in the documentation now.