fluent.js icon indicating copy to clipboard operation
fluent.js copied to clipboard

<Localized> around a text node should process markup in the translation

Open stasm opened this issue 6 years ago • 1 comments

#230 made it possible to use <Localized> around text nodes rather than elements.

// BEFORE
<Localized id="...">
    <span>Hello</span>
</Localized>

// AFTER
<Localized id="...">
    Hello
</Localized>

Currently, if the wrapped node is a string, Localized always returns the translation as a simple string, too. As a consequence, the text-only form doesn't support any markup in translations.

stasm avatar Feb 15 '19 11:02 stasm

If we allowed markup in text-only forms of Localized, the following would become possible:

<Localized id="..." em={<em/>}>
    {"Hello, <em>world</em>!"}
</Localized>

In order to achieve it, we might want to modify the return value of Localized to be a React.Fragment.

stasm avatar Feb 15 '19 11:02 stasm