Skip to content

Edit in place requires P, H1, or H2 tag wrapper for translations with HTML tags #294

Open
@bocharsky-bw

Description

@bocharsky-bw

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:

Screen Shot 2019-03-13 at 16 35 05

Screen Shot 2019-03-13 at 16 35 48

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions