gettext-extractor icon indicating copy to clipboard operation
gettext-extractor copied to clipboard

Disable line numbers

Open pronebird opened this issue 5 years ago • 6 comments

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.

pronebird avatar Apr 09 '19 11:04 pronebird

Currently this is not possible, but I will consider implementing it in the next feature release.

lukasgeiter avatar Apr 09 '19 11:04 lukasgeiter

@lukasgeiter a little input on this: we could also implement a feature to disable file references at once, not just line numbers 👍

pronebird avatar Apr 25 '19 09:04 pronebird

Sure thing, that should be easy to implement 🙂

lukasgeiter avatar Apr 25 '19 09:04 lukasgeiter

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);

pronebird avatar Apr 25 '19 09:04 pronebird

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(/:([^:]+)$/, '');
  });
});

fatihacet avatar Feb 17 '20 00:02 fatihacet

And you'd probably want to remove duplicated file names after that.

kreba avatar May 16 '24 11:05 kreba