2 Commits

Author SHA1 Message Date
Ruben Vermeersch
88364bc5e1 Release v1.1.2 2021-12-01 10:06:48 +01:00
Remko Tronçon
685be92923 Support multiple spaces after msgid 2021-12-01 09:48:44 +01:00
9 changed files with 5557 additions and 6 deletions

View File

@@ -53,7 +53,7 @@ module.exports = (grunt) ->
bump: bump:
options: options:
files: ['package.json', 'bower.json'] files: ['package.json', 'package-lock.json', 'bower.json']
commitFiles: ['-a'] commitFiles: ['-a']
pushTo: 'origin' pushTo: 'origin'

View File

@@ -1,6 +1,6 @@
{ {
"name": "pofile", "name": "pofile",
"version": "1.1.1", "version": "1.1.2",
"authors": [ "authors": [
"Ruben Vermeersch <ruben@rocketeer.be>" "Ruben Vermeersch <ruben@rocketeer.be>"
], ],

2
dist/pofile.js vendored
View File

@@ -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

File diff suppressed because one or more lines are too long

View File

@@ -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 {

5523
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{ {
"name": "pofile", "name": "pofile",
"description": "Parse and serialize Gettext PO files.", "description": "Parse and serialize Gettext PO files.",
"version": "1.1.1", "version": "1.1.2",
"author": { "author": {
"name": "Ruben Vermeersch", "name": "Ruben Vermeersch",
"email": "ruben@savanne.be", "email": "ruben@savanne.be",

View File

@@ -0,0 +1,8 @@
# some comment
msgid "First id, no header"
msgstr ""
msgid "A second string"
msgstr ""

View File

@@ -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);
});
});
}); });