Skip to content

Commit

Permalink
Merge pull request #622 from WordPress/fix/597-windows-slash
Browse files Browse the repository at this point in the history
Force POSIX implementation for strings relative path output
  • Loading branch information
aduth authored May 4, 2017
2 parents 4cf7bb1 + 4a76421 commit 17a7a88
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions i18n/babel-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

const { po } = require( 'gettext-parser' );
const { pick, reduce, uniq, forEach, sortBy, isEqual, merge, isEmpty } = require( 'lodash' );
const { relative } = require( 'path' );
const { relative, sep } = require( 'path' );
const { writeFileSync } = require( 'fs' );

/**
Expand Down Expand Up @@ -199,10 +199,12 @@ module.exports = function() {
translation.msgstr = '';
}

// Assign file reference comment
// Assign file reference comment, ensuring consistent pathname
// reference between Win32 and POSIX
const { filename } = this.file.opts;
const pathname = relative( '.', filename ).split( sep ).join( '/' );
translation.comments = {
reference: relative( process.cwd(), filename ) + ':' + path.node.loc.start.line
reference: pathname + ':' + path.node.loc.start.line
};

// If exists, also assign translator comment
Expand Down

0 comments on commit 17a7a88

Please sign in to comment.