Merge pull request #10 from Open-Xchange-Frontend/handle_empty_comments
handle empty comments correctly
This commit is contained in:
commit
1b5668b5c7
@ -146,9 +146,9 @@ PO.parse = function (data) {
|
|||||||
for (var i = 0; i < flags.length; i++) {
|
for (var i = 0; i < flags.length; i++) {
|
||||||
item.flags[flags[i]] = true;
|
item.flags[flags[i]] = true;
|
||||||
}
|
}
|
||||||
} else if (line.match(/^#\s+/)) { // Translator comment
|
} else if (line.match(/^#($|\s+)/)) { // Translator comment
|
||||||
finish();
|
finish();
|
||||||
item.comments.push(trim(line.replace(/^#\s+/, '')));
|
item.comments.push(trim(line.replace(/^#($|\s+)/, '')));
|
||||||
} else if (line.match(/^#\./)) { // Extracted comment
|
} else if (line.match(/^#\./)) { // Extracted comment
|
||||||
finish();
|
finish();
|
||||||
item.extractedComments.push(trim(line.replace(/^#\./, '')));
|
item.extractedComments.push(trim(line.replace(/^#\./, '')));
|
||||||
|
8
test/fixtures/comment.po
vendored
8
test/fixtures/comment.po
vendored
@ -19,3 +19,11 @@ msgstr ""
|
|||||||
#. Extracted comment
|
#. Extracted comment
|
||||||
msgid "Title, as plain text"
|
msgid "Title, as plain text"
|
||||||
msgstr "Attribut title, en tant que texte brut"
|
msgstr "Attribut title, en tant que texte brut"
|
||||||
|
|
||||||
|
#
|
||||||
|
#.
|
||||||
|
#:
|
||||||
|
#, fuzzy
|
||||||
|
msgid "Empty comment"
|
||||||
|
msgstr "Empty"
|
||||||
|
|
||||||
|
@ -31,10 +31,24 @@ describe('Parse', function () {
|
|||||||
assert.equal(po.headers['Plural-Forms'], 'nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;');
|
assert.equal(po.headers['Plural-Forms'], 'nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Handle empty comments', function (done) {
|
||||||
|
PO.load(__dirname + '/fixtures/comment.po', function (err, po) {
|
||||||
|
assert.equal(err, null);
|
||||||
|
|
||||||
|
var item = po.items[1];
|
||||||
|
assert.equal(item.msgid, 'Empty comment');
|
||||||
|
assert.equal(item.msgstr, 'Empty');
|
||||||
|
assert.deepEqual(item.comments, ['']);
|
||||||
|
assert.deepEqual(item.extractedComments, ['']);
|
||||||
|
assert.deepEqual(item.references, ['']);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Handles translator comments', function () {
|
it('Handles translator comments', function () {
|
||||||
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/comment.po', 'utf8'));
|
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/comment.po', 'utf8'));
|
||||||
assert.notEqual(po, null);
|
assert.notEqual(po, null);
|
||||||
assert.equal(po.items.length, 1);
|
assert.equal(po.items.length, 2);
|
||||||
|
|
||||||
var item = po.items[0];
|
var item = po.items[0];
|
||||||
assert.equal(item.msgid, 'Title, as plain text');
|
assert.equal(item.msgid, 'Title, as plain text');
|
||||||
@ -45,7 +59,7 @@ describe('Parse', function () {
|
|||||||
it('Handles extracted comments', function () {
|
it('Handles extracted comments', function () {
|
||||||
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/comment.po', 'utf8'));
|
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/comment.po', 'utf8'));
|
||||||
assert.notEqual(po, null);
|
assert.notEqual(po, null);
|
||||||
assert.equal(po.items.length, 1);
|
assert.equal(po.items.length, 2);
|
||||||
|
|
||||||
var item = po.items[0];
|
var item = po.items[0];
|
||||||
assert.equal(item.msgid, 'Title, as plain text');
|
assert.equal(item.msgid, 'Title, as plain text');
|
||||||
|
Loading…
Reference in New Issue
Block a user