You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, i18next-parser's JsxLexer doesn't unescape JsxText properly, making defaultValue to be "Hello & world!" in the example. Similiar to #663, if i18nKey is specified in other ways, it can be patched by specifying shouldUnescape to true.
But, if i18nKey is not specified (or shouldUnescape is not applied), react-i18next never sees the escaped string because it would only reside in the raw source code - the transpiler effectively removes the escape from the transpiled code, making the translation key to differ between the generated file and the actual code.
🐛 Bug Report
In JSX, you can specify HTML entities (
<
,"
,"
, etc) in JsxText.These HTML entities are unescaped while compile time - so it would end up like this in the compiled code:
However, i18next-parser's JsxLexer doesn't unescape JsxText properly, making
defaultValue
to be"Hello & world!"
in the example. Similiar to #663, ifi18nKey
is specified in other ways, it can be patched by specifyingshouldUnescape
to true.But, if
i18nKey
is not specified (orshouldUnescape
is not applied), react-i18next never sees the escaped string because it would only reside in the raw source code - the transpiler effectively removes the escape from the transpiled code, making the translation key to differ between the generated file and the actual code.This can be resolved by changing JsxLexer's
JsxText
rendering routine - https://github.com/i18next/i18next-parser/blob/master/src/lexers/jsx-lexer.js#L186-L191Simply unescaping the text would resolve the problem. However, I'm not sure if I should send PR with a new dependency (e.g. unescape), or bundle simple
unescape
function inside (https://github.com/i18next/react-i18next/blob/master/src/unescape.js). I'll be looking forward for your suggestions!To Reproduce
is parsed/generated as-is -
"Hello & world!"
is the defaultValue / i18nKey.Expected behavior
"Hello & world!"
should be the generated defaultValue / i18nKey.Your Environment
The text was updated successfully, but these errors were encountered: