Write flags out when serializing.
This commit is contained in:
parent
fff8349e25
commit
0d4f80e7f6
@ -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
26
test/write.js
Normal 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");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user