diff --git a/lib/po.js b/lib/po.js index e4a2d2c..c04c842 100644 --- a/lib/po.js +++ b/lib/po.js @@ -192,6 +192,12 @@ PO.Item.prototype.toString = function () { return lines; }; + if (this.comments.length > 0) { + this.comments.forEach(function (c) { + lines.push('# ' + c); + }); + } + if (this.references.length > 0) { this.references.forEach(function (ref) { lines.push('#: ' + ref); diff --git a/test/write.js b/test/write.js index 809b145..78708f3 100644 --- a/test/write.js +++ b/test/write.js @@ -38,6 +38,13 @@ describe('Write', function () { assertHasLine(str, "msgstr \"Source\""); }); + it('write translator comment', function () { + var input = fs.readFileSync(__dirname + '/fixtures/comment.po', 'utf8'); + var po = PO.parse(input); + var str = po.toString(); + assertHasLine(str, "# Comment"); + }); + describe('msgctxt', function () { it('should write context field to file', function () { var input = fs.readFileSync(__dirname + '/fixtures/big.po', 'utf8');