new implementation of items marked obsolete
the current implementation of items marked obsolete did not allow "plain" comments for these items. However, this is perfectly fine according to the original gettext tools. When writing a po file, comments for obsolete items don't contain the '#~ ' mark (tested using msgcat), so this is now also aligned with the behaviour of the original gettext tools. For all these cases I added examples in the po files, that failed with the current implementation and work fine after these changes.
This commit is contained in:
10
test/fixtures/commented.po
vendored
10
test/fixtures/commented.po
vendored
@@ -21,3 +21,13 @@ msgstr "{{dataLoader.data.length}} resultaten"
|
||||
|
||||
#~ msgid "Add order"
|
||||
#~ msgstr "Order toevoegen"
|
||||
|
||||
#~ # commented obsolete item
|
||||
#~ #, fuzzy
|
||||
#~ msgid "Commented item"
|
||||
#~ msgstr "not sure"
|
||||
|
||||
# commented obsolete item
|
||||
#, fuzzy
|
||||
#~ msgid "Second commented item"
|
||||
#~ msgstr "also not sure"
|
||||
|
||||
@@ -96,7 +96,7 @@ describe('Parse', function () {
|
||||
it('Handles obsolete items', function () {
|
||||
var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/commented.po', 'utf8'));
|
||||
|
||||
assert.equal(po.items.length, 2);
|
||||
assert.equal(po.items.length, 4);
|
||||
var item = po.items[0];
|
||||
assert.equal(item.obsolete, false);
|
||||
assert.equal(item.msgid, '{{dataLoader.data.length}} results');
|
||||
@@ -106,6 +106,16 @@ describe('Parse', function () {
|
||||
assert.equal(item.obsolete, true);
|
||||
assert.equal(item.msgid, 'Add order');
|
||||
assert.equal(item.msgstr, 'Order toevoegen');
|
||||
|
||||
item = po.items[2];
|
||||
assert.equal(item.obsolete, true);
|
||||
assert.equal(item.msgid, 'Commented item');
|
||||
assert.equal(item.msgstr, 'not sure');
|
||||
|
||||
item = po.items[3];
|
||||
assert.equal(item.obsolete, true);
|
||||
assert.equal(item.msgid, 'Second commented item');
|
||||
assert.equal(item.msgstr, 'also not sure');
|
||||
});
|
||||
|
||||
describe('C-Strings', function () {
|
||||
|
||||
@@ -61,6 +61,22 @@ describe('Write', function () {
|
||||
assertHasLine(str, '#~ msgstr "Order toevoegen"');
|
||||
});
|
||||
|
||||
it('write obsolete items with comment', function () {
|
||||
var input = fs.readFileSync(__dirname + '/fixtures/commented.po', 'utf8');
|
||||
var po = PO.parse(input);
|
||||
var str = po.toString();
|
||||
|
||||
//this is what msgcat tool of gettext does: don't print #~ for comments
|
||||
assertHasLine(str, '# commented obsolete item');
|
||||
assertHasLine(str, '#, fuzzy');
|
||||
|
||||
//items made obsolete by commenting every keyword with #~
|
||||
assertHasLine(str, '#~ msgid "Commented item"');
|
||||
assertHasLine(str, '#~ msgstr "not sure"');
|
||||
assertHasLine(str, '#~ msgid "Second commented item"');
|
||||
assertHasLine(str, '#~ msgstr "also not sure"');
|
||||
});
|
||||
|
||||
describe('C-Strings', function () {
|
||||
it('should escape "', function () {
|
||||
var item = new PO.Item();
|
||||
|
||||
Reference in New Issue
Block a user