don't remove \n characters from written po file

in Item.toString, all \n characters are removed from the output.
The gettext tools however leave those characters intact. This
will now produce the same output as tools like msgcat.
This commit is contained in:
Julian Bäume 2014-06-23 12:52:10 +02:00
parent d202e39a60
commit d8fc514359
2 changed files with 4 additions and 1 deletions

View File

@ -262,6 +262,9 @@ PO.Item.prototype.toString = function () {
} else {
text = isArray(text) ? text.join() : text;
var processed = _process(keyword, text);
for (var i = 1; i < processed.length - 1; i++) {
processed[i] = processed[i].slice(0, -1) + '\\n"';
}
lines = lines.concat(mkObsolete + processed.join('\n' + mkObsolete));
}
}

View File

@ -97,7 +97,7 @@ describe('Write', function () {
item.msgid = '\n should be written escaped';
assertHasLine(item.toString(), 'msgid ""');
assertHasLine(item.toString(), '""');
assertHasLine(item.toString(), '"\\n"');
assertHasLine(item.toString(), '" should be written escaped"');
});