Fix self-closing tag to match with react-i18next #663
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why am I submitting this PR
This PR corrects the behavior of
<br />
to match with react-i18next's nodeToString routine.When
transSupportBasicHtmlNodes
is true, inside<Trans>
, react-i18next converts<br />
into<br/>
. But i18next-parser converts<br />
into<br />
, causing a difference between the defaultValue generated with each other.If
i18nKey
is specified, this wouldn't cause any problem because onlydefaultValue
would differ, and both<br/>
and<br />
can be parsed well by react-i18next.However, if only
defaultValue
is specified, the defaultValue will be used as the i18nKey. Therefore it makes generated key and the actual key to mismatch, making react-i18next unable to find the translation entry.Does it fix an existing ticket?
No
Checklist
yarn test
(see details here)FYI) I've encountered a failing test while running tests. I investigated the problem, and it turned out that
Intl.PluralRules
defaults to the system language if an unknown locale is specified - so the test will fail if the system language is set to other languages that have more/less than 2 plural types.(
Intl.PluralRules
is used by i18next.PluralResolver.)The test can be successfully run by changing the system language to en-US: