Skip to content

[localize] Extracting html within html in messages #2426

@augustjk

Description

@augustjk

Description

lit-localize extract does not properly handle html calls within html within msg.

Steps to Reproduce

Include the following code

msg(html`Hello <b>${html`<i>World</i>`}</b>!`, {id: "foo"});

And run lit-localize extract

Expected Results

<trans-unit id="foo">
  <source>Hello <x id="0" equiv-text="<b>${html`<i>World</i>`}</b>"/>!</source>
</trans-unit>

Actual Results

<trans-unit id="foo">
  <source>Hello <x id="0" equiv-text="&lt;b>"/>html `<x id="1" equiv-text="&lt;i>"/>World<x id="2" equiv-text="&lt;/i>${`}&lt;/b>"/>!</source>
</trans-unit>

Above results are for xliff format but similar results are seen for xlb format as well.

Workaround for now is probably not to use html within html to create a placeholder, something like

html`${msg('Hello')} <b><i>World</i></b>!`;

though that doesn't allow a translator to switch the order if that's necessary. Perhaps #1890 would allow this?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions