c046b62873
since the parser can extract this information, now, the writer should also be able to write it back to a po file
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
var assert = require('assert');
|
|
var fs = require('fs');
|
|
var PO = require('..');
|
|
|
|
function assertHasLine(str, line) {
|
|
var lines = str.split("\n");
|
|
var found = false;
|
|
|
|
for (var i = 0; i < lines.length; i++) {
|
|
if (lines[i].trim() === line) {
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
assert(found, "Could not find line: " + line);
|
|
}
|
|
|
|
describe('Write', function () {
|
|
it('write flags', function () {
|
|
var input = fs.readFileSync(__dirname + '/fixtures/fuzzy.po', 'utf8');
|
|
var po = PO.parse(input);
|
|
var str = po.toString();
|
|
assertHasLine(str, "#, fuzzy");
|
|
});
|
|
|
|
it('write msgid', function () {
|
|
var input = fs.readFileSync(__dirname + '/fixtures/fuzzy.po', 'utf8');
|
|
var po = PO.parse(input);
|
|
var str = po.toString();
|
|
assertHasLine(str, "msgid \"Sources\"");
|
|
});
|
|
|
|
it('write msgstr', function () {
|
|
var input = fs.readFileSync(__dirname + '/fixtures/fuzzy.po', 'utf8');
|
|
var po = PO.parse(input);
|
|
var str = po.toString();
|
|
assertHasLine(str, "msgstr \"Source\"");
|
|
});
|
|
|
|
it('write msgctxt', function () {
|
|
var input = fs.readFileSync(__dirname + '/fixtures/big.po', 'utf8');
|
|
var po = PO.parse(input);
|
|
var str = po.toString();
|
|
assertHasLine(str, 'msgctxt "folder action"');
|
|
});
|
|
});
|