diff --git a/lib/po.js b/lib/po.js index b140e12..4a7fe88 100644 --- a/lib/po.js +++ b/lib/po.js @@ -193,6 +193,11 @@ PO.Item.prototype.toString = function () { }); } + var flags = Object.keys(this.flags); + if (flags.length > 0) { + lines.push(util.format('#, %s', flags.join(","))); + } + ['msgid', 'msgid_plural', 'msgstr'].forEach(function (keyword) { var text = that[keyword]; if (text != null) { diff --git a/test/write.js b/test/write.js new file mode 100644 index 0000000..0c0f610 --- /dev/null +++ b/test/write.js @@ -0,0 +1,26 @@ +var assert = require('assert'); +var fs = require('fs'); +var PO = require('..'); + +function assertHasLine(str, line) { + var lines = str.split("\n"); + var found = false; + + for (var i = 0; i < lines.length; i++) { + if (lines[i].trim() === line) { + found = true; + break; + } + } + + assert(found, "Could not find line: " + line); +} + +describe('Write', function () { + it('write flags', function () { + var input = fs.readFileSync(__dirname + '/fixtures/fuzzy.po', 'utf8'); + var po = PO.parse(input); + var str = po.toString(); + assertHasLine(str, "#, fuzzy"); + }); +});