Include comments in PO.Item output

Fixes #5
This commit is contained in:
Gabe Gorelick 2014-03-01 17:21:18 -05:00
parent c5515d6128
commit ada76116b0
2 changed files with 13 additions and 0 deletions

View File

@ -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);

View File

@ -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');