tolgee / tolgee-js

Tolgee JavaScript libraries monorepo
https://tolgee.io
MIT License
234 stars 28 forks source link

Self closing tags are not supported (<br />) #3101

Open Goye opened 2 years ago

Goye commented 2 years ago

Hey everyone hope all is going well,

I am trying to use the line break element without success, even if I try using the function form does not work. I guess this is happening will all these kinds of tags

Do you know what the problem might be? Or which file can I modify to fix it?

Thank you so much,

Screenshots

Screen Shot 2022-10-03 at 7 17 33 PM

Code snippet

{t({
    key: 'about.whoWeAre.lowFees.description',
    parameters: {
        s: <s />,
        strong: <strong />,
        br: <br />,
    },
})}

Enviorement

"@tolgee/react": "^4.9.2", "react": "^17.0.2", "next": "12.1.0",

stepan662 commented 2 years ago

Hey, we are now using format.js for parsing tags and it doesn't support this, so now we don't have an easy way how to enable it. https://formatjs.io/docs/intl-messageformat#rich-text-support. We might change this by implementing our custom tag parser. Another thing is that we are preparing a new core library now, so after we release that, we might look at this again.

Goye commented 2 years ago

Thanks for letting me know! @stepan662

bpetermann commented 1 year ago

Hi,

just wanted to ask if there are any updates on this?

Thanks in advance!

stepan662 commented 1 year ago

Hey, sorry not yet. Will try to get to this, as I had multiple requests. In mean time, you can use <br></br>, it's a bit ugly, but it works.

moussaab-moulim commented 2 months ago

for self closing tags you can use icu placeholder as mentioned here https://github.com/formatjs/formatjs/releases/tag/v4.0.0

an example provided by fromatJs guys codesandbox