Fix tag converting behavior to match with react-i18next#665
Fix tag converting behavior to match with react-i18next#665yoo2001818 wants to merge 2 commits intoi18next:masterfrom
Conversation
572335b to
a8880f7
Compare
@yoo2001818 |
No, it is You have to match them, either by setting i18next's value to |
As far as i can see, i18next-parser does not have |
i18next-parser does have You may use it like this: // i18next-parser.config.js
export default {
lexers: {
jsx: [{
lexer: 'JsxLexer',
transSupportBasicHtmlNodes: true,
}],
},
};Furthermore, i18next-parser cannot read i18next's config, as i18next-parser statically analyzes the code without executing it. It doesn't actually care about i18next's configuration or its presence - it works by just reading However, i18next itself, does set |
d72e758 to
10f3d69
Compare
|
Bumped into this today and was so grateful to find not only is it reported, but there's a PR already. Could this be looked at by a maintainer? |
Why am I submitting this PR
This PR is continuation of #663. (You can disregard #663 if this PR gets merged first)
I've checked the difference between react-i18next and i18next-parser, and mainly there were 3 problems.
<br />is converted to<br />(should be<br/>)<strong></strong>should be converted to<strong/>in this case. This directly contradicts Outputting autoclosed tags when there's no child content #254, so I think I need your decision whether to strictly follow react-i18next's behavior, or to allow some differences.elementNamewhen only 1 string element is inside the node.For example,
<p>a{'b'}</p>is converted to<1>ab</1>because there are two string elements inside<p>.<p>{{ count }}</p>is also converted to<1>{{ count }}</1>because the children is an object.This resolves 1st and 3rd point to match with react-i18next's behavior.
I think #264 can be resolved if this PR gets merged, and
transSupportBasicHtmlNodesbecomestrueby default. However, since that would be a breaking change, a proper documentation abouttransSupportBasicHtmlNodescould be enough to resolve it. I'll try to update the documentation if you want to.Does it fix an existing ticket?
No
Checklist
yarn test(see details here)