Support multiple spaces after msgid
This commit is contained in:
parent
ff1b888af1
commit
685be92923
2
dist/pofile.js
vendored
2
dist/pofile.js
vendored
@ -83,7 +83,7 @@ PO.parse = function (data) {
|
|||||||
var headers = [];
|
var headers = [];
|
||||||
//everything until the first 'msgid ""' is considered header
|
//everything until the first 'msgid ""' is considered header
|
||||||
while (sections[0] && (headers.length === 0 || headers[headers.length - 1].indexOf('msgid ""') < 0)) {
|
while (sections[0] && (headers.length === 0 || headers[headers.length - 1].indexOf('msgid ""') < 0)) {
|
||||||
if (sections[0].match(/msgid "[^"]/)) {
|
if (sections[0].match(/msgid\s+"[^"]/)) {
|
||||||
//found first real string, adding a dummy header item
|
//found first real string, adding a dummy header item
|
||||||
headers.push('msgid ""');
|
headers.push('msgid ""');
|
||||||
} else {
|
} else {
|
||||||
|
2
dist/pofile.min.js
vendored
2
dist/pofile.min.js
vendored
File diff suppressed because one or more lines are too long
@ -80,7 +80,7 @@ PO.parse = function (data) {
|
|||||||
var headers = [];
|
var headers = [];
|
||||||
//everything until the first 'msgid ""' is considered header
|
//everything until the first 'msgid ""' is considered header
|
||||||
while (sections[0] && (headers.length === 0 || headers[headers.length - 1].indexOf('msgid ""') < 0)) {
|
while (sections[0] && (headers.length === 0 || headers[headers.length - 1].indexOf('msgid ""') < 0)) {
|
||||||
if (sections[0].match(/msgid "[^"]/)) {
|
if (sections[0].match(/msgid\s+"[^"]/)) {
|
||||||
//found first real string, adding a dummy header item
|
//found first real string, adding a dummy header item
|
||||||
headers.push('msgid ""');
|
headers.push('msgid ""');
|
||||||
} else {
|
} else {
|
||||||
|
8
test/fixtures/no_header_extra_spaces.po
vendored
Normal file
8
test/fixtures/no_header_extra_spaces.po
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# some comment
|
||||||
|
|
||||||
|
msgid "First id, no header"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "A second string"
|
||||||
|
msgstr ""
|
||||||
|
|
@ -70,4 +70,24 @@ describe('PO files with no headers', function () {
|
|||||||
assert.equal(po.items.length, 2);
|
assert.equal(po.items.length, 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('advanced example with extra spaces', function () {
|
||||||
|
var po;
|
||||||
|
|
||||||
|
before(function (done) {
|
||||||
|
PO.load(__dirname + '/fixtures/no_header_extra_spaces.po', function (err, result) {
|
||||||
|
assert.equal(err, null);
|
||||||
|
po = result;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Parses the po file', function () {
|
||||||
|
assert.notEqual(po, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Finds all items', function () {
|
||||||
|
assert.equal(po.items.length, 2);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user