-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
undefined Error when string has no closing tag #451
Comments
would you mind providing a PR or at least a failing testcase for this? |
@jamuhl Yes, if I have time on the weekend I will take a crack at it. |
i guess the error is caused here: https://github.com/i18next/react-i18next/blob/master/src/Trans.js#L56 evtl. doing a try catch around the parse and log an error on catch + fallback to unparsed value might be sufficient fix... |
@jamuhl Is this fixed, or would you like a PR for it? |
not yet fixed...was to low on my personal prio list...feel free to create a PR so this gets finally closed. |
@dguillamot It's been several months since your offer, do you want to contribute to this library, or shall we take it from here? |
looks like this got solved by other changes already - at least that code part was removed (changed heavily) and newly added tests do not show any issue for those invalid html tags from translations. |
An error is thrown from Trans.js line 78 (react-i18next.js line 1064) when the inputted string is just a single opening XML element.
Our string was 'This is a test string'.. However, translators accidentally surrounded this with angle brackets. making the string
<This is a test string>
.The result was a crash in Trans.js at line 78 in renderNodes(). 'Cannot read property 'content' of undefined' at this line:
const interpolated = i18n.services.interpolator.interpolate(node.children[0].content, child, i18n.language);
So, if the inputted string does not have a valid closing xml tag (in our case the entire string was one single opening xml tag), node.children[0] is, naturally, undefined as there are no children to that node.
Should Trans.js check for null node.children here, or higher up in the pipeline?
The text was updated successfully, but these errors were encountered: