From d1be0f51b00e53dd273937bed0665f9521dbc6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Mon, 21 Sep 2015 09:13:43 +0200 Subject: [PATCH] fix issue #16 add a blank line in the comments of the headers of the big.po file. This breaks parsing the headers. msgcat of gettext tools just ignores empty lines until a header is found and treats everything above as header comment. The change to the library itself fixes the tests again, after the blank linke broke 3. --- lib/po.js | 7 ++++++- test/fixtures/big.po | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/po.js b/lib/po.js index b79de83..6e1e2cd 100644 --- a/lib/po.js +++ b/lib/po.js @@ -64,7 +64,12 @@ PO.parse = function (data) { data = data.replace(/\r\n/g, '\n'); var po = new PO(); var sections = data.split(/\n\n/); - var headers = sections.shift(); + var headers = [sections.shift()]; + //everything until the first 'msgid ""' is considered header + while (headers[headers.length - 1].indexOf('msgid ""') < 0) { + headers.push(sections.shift()); + } + headers = headers.join('\n'); var lines = sections.join('\n').split(/\n/); po.headers = { diff --git a/test/fixtures/big.po b/test/fixtures/big.po index 4638b40..c5236df 100644 --- a/test/fixtures/big.po +++ b/test/fixtures/big.po @@ -1,4 +1,5 @@ # French translation of Link (6.x-2.9) + # Copyright (c) 2011 by the French translation team # msgid ""