add reverse method of extract(string)
during PO.parse, an extract(string) method is called on each string to unescape some characters (like " and \). This process should be reverted in the toString method. The PO spec says, that all strings should be C-Strings. Otherwise tools like msgmerge (from the gettext package) will fail parsing po files written by this library.
This commit is contained in:
@@ -52,6 +52,22 @@ describe('Write', function () {
|
||||
assertHasLine(str, '#. Extracted comment');
|
||||
});
|
||||
|
||||
describe('C-Strings', function () {
|
||||
it('should escape "', function () {
|
||||
var item = new PO.Item();
|
||||
|
||||
item.msgid = '" should be written escaped';
|
||||
assertHasLine(item.toString(), 'msgid "\\" should be written escaped"');
|
||||
});
|
||||
|
||||
it('shoudl escape \\', function () {
|
||||
var item = new PO.Item();
|
||||
|
||||
item.msgid = '\\ should be written escaped';
|
||||
assertHasLine(item.toString(), 'msgid "\\\\ should be written escaped"');
|
||||
});
|
||||
});
|
||||
|
||||
describe('msgctxt', function () {
|
||||
it('should write context field to file', function () {
|
||||
var input = fs.readFileSync(__dirname + '/fixtures/big.po', 'utf8');
|
||||
|
||||
Reference in New Issue
Block a user