Write flags out when serializing.

This commit is contained in:
Ruben Vermeersch 2013-12-17 16:35:40 +01:00
parent fff8349e25
commit 0d4f80e7f6
2 changed files with 31 additions and 0 deletions

View File

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

26
test/write.js Normal file
View File

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