Can I add HTML to my localization strings?

Updated:

Related pages: loc, Localization, Translation & Localization

At the moment, intl-messageformat somewhat supports parsing HTML, but it's limited in its functionality and ease of use. We are discussing internally how we can best support it in the future.

In the meantime, what you can do is use the ignoreTag option, which will parse the HTML tags as part of the string. From there, you can dangerously set the innerHTML, in the element you need it applied to.

// Given the following string
// {
//  myString: "<li>My string</li>";
// }

const myStringResult = tecton.sources.loc(
  "myString", 
  undefined, 
  { ignoreTag: true }
);
// Returns "<li>My string</li>".

document.querySelector(".my-element").innerHTML = myStringResult;