From d8fc514359fdd4469c7e3dd735e9ac984fbda529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Mon, 23 Jun 2014 12:52:10 +0200 Subject: [PATCH] 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. --- lib/po.js | 3 +++ test/write.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/po.js b/lib/po.js index e22db97..2bfc3e6 100644 --- a/lib/po.js +++ b/lib/po.js @@ -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)); } } diff --git a/test/write.js b/test/write.js index dd319ad..06edb97 100644 --- a/test/write.js +++ b/test/write.js @@ -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"'); });