-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Incorrect whitespace handling in JSX #73
Comments
Similar issue reported in #72 |
So slightly inspired by this issue and #72 I had a look at putting together a tool that uses the same babel tooling i use to compile my app to extract all my translation strings. This uses a single parser rather than i18next-scanner's current approach of using a JS parser plus a HTML parser for the JSX bits. One nice benefit of this is that the issue described here, plus some extra things that should be valid but maybe unusual (e.g. My stuff is here: https://github.com/SomeHats/i18next-extract and is working perfectly for my app (interesting bits for this discussion: https://github.com/SomeHats/i18next-extract/blob/master/lib/extract-component-visitor.js) |
@SomeHats if you add some readme we might add that to https://www.i18next.com/plugins-and-utils.html others might like your work... |
Since v2.6.0, the HTML parser is replaced by Acorn-JSX parser for parsing JSX code. Check out the latest release at https://github.com/i18next/i18next-scanner/releases/tag/v2.6.0 |
Version
Hey there! Thanks for your great work on this tool - it's super useful. I've noticed a few places where it doesn't work as expected around whitespace in JSX:
A few examples:
Expected key (generated by react-i18next):
hello<1>world</1>
Actual key (generated by i18next-scanner):
hello <1>world</1>
Expected key (generated by react-i18next):
<0>hello</0>world
Actual key (generated by i18next-scanner):
<0>hello</0> world
This is an area where JSX behaves a bit differently to HTML. To keep a space between the two words, it's quite common to add
{' '}
:Expected key (generated by react-i18next):
hello <2>world</2>
Actual key (generated by i18next-scanner):
hello<1>{' '}</1> <3>world</3>
The text was updated successfully, but these errors were encountered: