lukasgeiter / gettext-extractor

A flexible and powerful Gettext message extractor with support for JavaScript, TypeScript, JSX and HTML.
MIT License
98 stars 21 forks source link

Retrieve column number #70

Open MarcelloPerathoner opened 2 months ago

MarcelloPerathoner commented 2 months ago

Please make it possible to retrieve the column number along with the line number of a message.

Use case: to parse a Vue.js template the obvious way is to compile the Vue template into JS and then feed the compiled JS to the gettext-extractor. The Vue template compiler returns the compiled JS plus a sourceMap, so it would be easy to fix up the references using https://github.com/mozilla/source-map if you could get the column number. (Note that setting the column number to always 0 or always 9999 does not work reliably with mozilla/source-map.)

One way to fix this would be a callback before storing each message, with the message, filename, line, column as parameters, so I could replace the reference with the correct one.