diff --git a/i18n/babel-plugin.js b/i18n/babel-plugin.js index df9607c9c57c7a..f3f1a536bec9b6 100644 --- a/i18n/babel-plugin.js +++ b/i18n/babel-plugin.js @@ -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' ); /** @@ -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