Merge pull request #11 from Open-Xchange-Frontend/fix_newline_in_msgid

restore previous behaviour with \n in strings
This commit is contained in:
Ruben Vermeersch 2014-06-23 14:11:52 +02:00
commit f5056bc57f
2 changed files with 11 additions and 1 deletions

View File

@ -261,7 +261,8 @@ PO.Item.prototype.toString = function () {
}); });
} else { } else {
text = isArray(text) ? text.join() : text; text = isArray(text) ? text.join() : text;
lines = lines.concat(mkObsolete + _process(keyword, text)); var processed = _process(keyword, text);
lines = lines.concat(mkObsolete + processed.join('\n' + mkObsolete));
} }
} }
}); });

View File

@ -92,6 +92,15 @@ describe('Write', function () {
assertHasLine(item.toString(), 'msgid "\\\\ should be written escaped"'); assertHasLine(item.toString(), 'msgid "\\\\ should be written escaped"');
}); });
it('should escape \\n', function () {
var item = new PO.Item();
item.msgid = '\n should be written escaped';
assertHasLine(item.toString(), 'msgid ""');
assertHasLine(item.toString(), '""');
assertHasLine(item.toString(), '" should be written escaped"');
});
it('should write identical file after parsing a file', function () { it('should write identical file after parsing a file', function () {
var input = fs.readFileSync(__dirname + '/fixtures/c-strings.po', 'utf8'); var input = fs.readFileSync(__dirname + '/fixtures/c-strings.po', 'utf8');
var po = PO.parse(input); var po = PO.parse(input);