gilbsgilbs / babel-plugin-i18next-extract

Babel plugin that statically extracts i18next and react-i18next translation keys.
https://i18next-extract.netlify.com
MIT License
161 stars 37 forks source link

Fix bad extracted keys with Trans and basic HTML nodes. #111

Closed gilbsgilbs closed 4 years ago

gilbsgilbs commented 4 years ago

This commit adds a better heuristic to detect which Trans component will be converted to indices by react-i18next (when using transKeepBasicHtmlNodes which is enabled by default). In particular, if the node has many children or interpolation, react-i18next ignores the transKeepBasicHtmlNodes option and converts the node to indices.

Fixes #108


@pcorpet could you have a look? Does this indeed fix #108? It was quite complex to align with every edge-case statically, but this is the best heuristic I could make. I have not been able to fool it so far.