Skip to content

[@lit/localize] A translation of "2 > 1" results in "2 > 1" when using msg("2 > 1") #5012

@BenjaminMaxdoro

Description

@BenjaminMaxdoro

Which package(s) are affected?

Localize (@lit/localize)

Description

When adding translations containing the > char (didn't test any others), the char is HTML escaped when rendering in that translation (not when rendering the source language).

Reproduction

When defining a translation like this:

return html`<span>${msg("2 > 1")}</span>`;

And add a translation:

<trans-unit id="s59704991b8b78e98">
  <source>2 &gt; 1</source>
  <target>2 &gt; 1</target>
</trans-unit>

The rendered text is 2 &gt; 1 instead of 2 > 1.

Workaround

Did not test any workaround but I would guess that using

msg(html`2 &gt; 1`)

would work.

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

Tested with @lit/localize 0.12.2 and @lit/localize-tools 0.8.0

Browser/OS/Node environment

Browser: Firefox 139.0.1
OS: Windows 11 (24H2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions