Description
Docs say:
So if you follow the Best practices and finish your translation keys with .html when you want to allow HTML, the editor comes with full power.
Docs reference: https://php-translation.readthedocs.io/en/latest/symfony/edit-in-place.html#the-editor-toolbox-for-html
But if I just suffix translations with .html
- I see the HTML editor mode but it breaks translation:
Code in Twig template:
<div class="text-center">{{ 'test.html'|trans|raw }}</div>
Translation:
<unit id="80p.thq" name="test.html">
<notes>
<note category="file-source" priority="1">templates/index.html.twig:8</note>
</notes>
<segment>
<source>test.html</source>
<target><![CDATA[Hello <b>Bold Text</b> World.]]></target>
</segment>
</unit>
P.S. Probably because it requires an HTML tag wrapper for the whole translation, so:
<target><![CDATA[<p>Hello <b>Bold Text</b> World.</p>]]></target>
fixes the problem. But it does not work with every tag as a wrapper, e.g. it does not work with div
tag. I suppose that's because the HTML editor supports only p
, h1
, and h2
tags, see the 2nd screenshot. So I should wrap my translations with either p
, h1
, or h2
tag to get it working.