gettext-extractor
gettext-extractor copied to clipboard
Disable line numbers
Hi,
Is it possible to disable the output of line numbers in references field? The idea behind is to reduce the amount of noise in gettext catalogues because our codebase changes a lot but translations normally remain the same, so when running the gettext-extractor we get a dirty git because of the line numbers change.
Currently this is not possible, but I will consider implementing it in the next feature release.
@lukasgeiter a little input on this: we could also implement a feature to disable file references at once, not just line numbers 👍
Sure thing, that should be easy to implement 🙂
The workaround that I use for now (taking advantage of mutability and object references, which is not really cool but easier than parsing POT line-by-line)
// clean file references
extractor.getMessages().forEach((msg) => {
msg.references = [];
});
extractor.savePotFile(outputPotFile);
Nice workaround from @pronebird 👍
msg.references = [];
will completely delete the file reference comment. If you only want to delete the line number which is usually the reason for conflicts, you can do:
extractor.getMessages().forEach((msg) => {
msg.references = msg.references.map((ref) => {
return ref.replace(/:([^:]+)$/, '');
});
});
And you'd probably want to remove duplicated file names after that.