implement writing msgctxt field

since the parser can extract this information, now, the writer should
also be able to write it back to a po file
This commit is contained in:
Julian Bäume 2014-01-21 15:06:11 +01:00
parent 6790bfb466
commit c046b62873
2 changed files with 8 additions and 1 deletions

View File

@ -203,7 +203,7 @@ PO.Item.prototype.toString = function () {
lines.push('#, ' + flags.join(","));
}
['msgid', 'msgid_plural', 'msgstr'].forEach(function (keyword) {
['msgctxt', 'msgid', 'msgid_plural', 'msgstr'].forEach(function (keyword) {
var text = that[keyword];
if (text != null) {
if (isArray(text) && text.length > 1) {

View File

@ -37,4 +37,11 @@ describe('Write', function () {
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"');
});
});