angular-gettext-tools
angular-gettext-tools copied to clipboard
Noise in diffs due to path separators
Hello!
We added a developer to our team that works on Windows. Unfortunately, each time he runs the extractor, the POT file has all its reference filenames changed to have backslashes instead of forward slashes. It produces hundreds of diffs like,
-#: site/home.html:93
+#: site\home.html:93
And of course, the next time one of our unix-based developers regenerates the file, the changes are all reversed.
Considering those are just references, can the format be normalized?
You can use the postProcess
callback to fix this. Here's what my builds look like:
gulp.src(['public/**/*.html', 'public/**/*.js'])
.pipe(gettext.extract('messages.pot', {
postProcess: function (po) {
po.items.forEach(function (item) {
item.references = item.references.map(function (ref) {
return path.relative(path.join(__dirname, '../po'), ref)
.replace(/\\/g, '/'); // replace any Windows-style paths
});
});
}
}))
.pipe(gulp.dest('po/'));
That being said, we should consider normalizing paths by default.
Thank you, @gabegorelick !