-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<Trans> outputs (some?) basic HTML nodes as plain-text #1468
Comments
Just to make sure I understand correctly...the issue I can follow is that for some tags the saveMissing feature creates and logs wrong strings into the console when <Trans i18nKey="welcome">
Hello <br /> <small>World</small>
</Trans> generates The result would be correct if also setting: react: {
transSupportBasicHtmlNodes: false,
transKeepBasicHtmlNodesFor: []
} which leads me to this line of code causing the issue: https://github.com/i18next/react-i18next/blob/master/src/Trans.js#L41 should be: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
bumping this: Anyone knows a fix or work around? |
Found this workaround: <Trans
i18nKey="my_key"
transKeepBasicHtmlNodesFor={['br', 'strong', 'i']}
components={{ s: <s />, b: <b /> }}
/> |
I'm not sure if this is still a problem, but I guess the previous fixes by @jamuhl weren't enough since @mateusvahl is still complaining about the same thing. Sadly, I just found a workaround and moved along - I've spent a lot of time fiddling with the lib's problems when we should actually be focused on implementing i18n and translating stuff, rather than fixing the biggest lib on the topic for JS. What we've been doing (rather than config guesswork, trying to care for imprevisible scenarios) is to add |
🐛 Bug Report
Weird interaction between
transSupportBasicHtmlNodes
andtransKeepBasicHtmlNodesFor
, as a side-effect of the workaround for i18next/i18next-parser#264.It causes some tags to be outputted as plain-text, others to be correctly converted, but I can't isolate the exact causes?
To Reproduce
I made a slight fork of a sandbox sample, just changing the two settings mentioned:
https://codesandbox.io/s/react-i18next-forked-p7hcsc.
You can see some tags (
<code>
) were correctly displayed, whilebr
andstrong
weren't.code
andbr
aren't part oftransKeepBasicHtmlNodesFor
, whilestrong
is.One workaround I found is that placing an
<em>
tag inside<p>
solves the issue, or adding a prop - this was noticed by accident when I originally stumbled on this.Expected behavior
i18next-parser
should correctly output<p>
when that's whatreact-i18next
understands from<Trans>
(i18next-parser's 264). WithtransSupportBasicHtmlNodes
either true or false,missingKeyHandler()
reports the key to include<p>
, but the parser still stores<0>
.transSupportBasicHtmlNodes
seems to have mitigated this issue for some scenarios (not so sure anymore), but in others it causes this weird side-effect described above.Your Environment
Possibly related to #1240?
The text was updated successfully, but these errors were encountered: