i18next-parser
i18next-parser copied to clipboard
jsx-lexer: Don't extract a variable identifier in i18nKey as key
Why am I submitting this PR
Hello,
Updated to latest i18next-parser in our largeish project. There are few instances where we have <Trans> component with a variable as i18nKey for whatever reason. The latest i18next-parser started extracting those variables like so:
<Trans
i18nKey={titleTextKey}
components={{
rating_type: productRating,
}}
/>
→ "titleTextKey": ""
Does not seem like the correct behavior for me hence the fix but please comment. Thanks!
Does it fix an existing ticket?
Not sure.
Checklist
- [x] only relevant code is changed (make a diff before you submit the PR)
- [x] tests are included and pass:
yarn test(see details here) - [ ] documentation is changed or added
Thanks for the PR. I believe a more consistent fix would be to throw a warning. You can see here and here.
Would you mind adding the warning and a test?
@karellm Thanks for the input. How does it look now? https://github.com/i18next/i18next-parser/pull/506/commits/94536c82ed80eaf05e1f4bd6a8bf54378d1be6cb