From c046b62873b5c932fe071b07374867a3255e0ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Tue, 21 Jan 2014 15:06:11 +0100 Subject: [PATCH] implement writing msgctxt field since the parser can extract this information, now, the writer should also be able to write it back to a po file --- lib/po.js | 2 +- test/write.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/po.js b/lib/po.js index 0068547..3825b65 100644 --- a/lib/po.js +++ b/lib/po.js @@ -203,7 +203,7 @@ PO.Item.prototype.toString = function () { lines.push('#, ' + flags.join(",")); } - ['msgid', 'msgid_plural', 'msgstr'].forEach(function (keyword) { + ['msgctxt', 'msgid', 'msgid_plural', 'msgstr'].forEach(function (keyword) { var text = that[keyword]; if (text != null) { if (isArray(text) && text.length > 1) { diff --git a/test/write.js b/test/write.js index 9aece24..3a04376 100644 --- a/test/write.js +++ b/test/write.js @@ -37,4 +37,11 @@ describe('Write', function () { var str = po.toString(); assertHasLine(str, "msgstr \"Source\""); }); + + it('write msgctxt', function () { + var input = fs.readFileSync(__dirname + '/fixtures/big.po', 'utf8'); + var po = PO.parse(input); + var str = po.toString(); + assertHasLine(str, 'msgctxt "folder action"'); + }); });