angular-gettext-tools icon indicating copy to clipboard operation
angular-gettext-tools copied to clipboard

Noise in diffs due to path separators

Open doublemarked opened this issue 9 years ago • 2 comments

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?

doublemarked avatar Aug 19 '15 12:08 doublemarked

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.

gabegorelick avatar Aug 19 '15 16:08 gabegorelick

Thank you, @gabegorelick !

doublemarked avatar Aug 19 '15 16:08 doublemarked