Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Replace path separators in i18n file reference
  • Loading branch information
aduth committed May 4, 2017
commit 4a76421dff4b536bca00ccfa4e10e27ca64461b1
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' ).posix;
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