1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
var po2json = require(".."),
fs = require("fs"),
Jed = require("jed");
module.exports["parse"] = {
setUp: function(callback){
this.po = fs.readFileSync(__dirname + "/fixtures/pl.po");
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8"));
callback();
},
parse: function(test){
var parsed = po2json.parse(this.po);
test.deepEqual(parsed, this.json);
test.done();
}
}
module.exports["parse with Jed format"] = {
setUp: function(callback){
this.po = fs.readFileSync(__dirname + "/fixtures/pl.po");
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-jed.json", "utf-8"));
callback();
},
parse: function(test){
var parsed = po2json.parse(this.po, { format: 'jed' });
test.deepEqual(parsed, this.json);
test.doesNotThrow(function() { new Jed(parsed) }, Error)
test.done();
}
};
module.exports["parse with Jed1.x format"] = {
setUp: function(callback){
this.po = fs.readFileSync(__dirname + "/fixtures/pl.po");
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-jed1.x.json", "utf-8"));
callback();
},
parse: function(test){
var parsed = po2json.parse(this.po, { format: 'jed1.x' });
test.deepEqual(parsed, this.json);
test.doesNotThrow(function() { new Jed(parsed) }, Error)
test.done();
}
};
module.exports["parse with MessageFormatter format"] = {
setUp: function(callback){
this.po = fs.readFileSync(__dirname + "/fixtures/pl-mf.po");
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-mf.json", "utf-8"));
callback();
},
parse: function(test){
var parsed = po2json.parse(this.po, { format: 'mf' });
test.deepEqual(parsed, this.json);
test.done();
}
}
module.exports["parse with MessageFormatter format + fallback-to-msgid"] = {
setUp: function(callback){
this.po = fs.readFileSync(__dirname + "/fixtures/en-empty.po");
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-mf-fallback-to-msgid.json", "utf-8"));
callback();
},
parse: function(test){
var parsed = po2json.parse(this.po, { format: 'mf', 'fallback-to-msgid': true });
test.deepEqual(parsed, this.json);
test.done();
}
}
module.exports["parse with fallback-to-msgid"] = {
setUp: function(callback){
this.po = fs.readFileSync(__dirname + "/fixtures/en-empty.po");
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-empty.json", "utf-8"));
callback();
},
parse: function(test){
var parsed = po2json.parse(this.po, { 'fallback-to-msgid': true });
test.deepEqual(parsed, this.json);
test.done();
}
}
module.exports["parseFile"] = {
setUp: function(callback){
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8"));
callback();
},
parseFile: function(test){
var self = this;
po2json.parseFile(__dirname + "/fixtures/pl.po", null, function (err, parsed) {
test.deepEqual(parsed, self.json);
test.done();
});
}
}
module.exports["parseFileSync"] = {
setUp: function(callback){
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8"));
callback();
},
parseFileSync: function(test){
var parsed = po2json.parseFileSync(__dirname + "/fixtures/pl.po");
test.deepEqual(parsed, this.json);
test.done();
}
}
module.exports["parse with Plural-Forms == nplurals=1; plural=0;"] = {
setUp: function(callback){
this.po = fs.readFileSync(__dirname + "/fixtures/ja.po");
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/ja.json", "utf-8"));
callback();
},
parse: function(test){
var parsed = po2json.parse(this.po);
test.deepEqual(parsed, this.json);
test.done();
}
}
module.exports["parse with no headers"] ={
setUp: function(callback){
this.po = fs.readFileSync(__dirname + "/fixtures/en-no-header.po");
this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-no-header.json", "utf-8"));
callback();
},
parse: function(test){
var parsed = po2json.parse(this.po);
test.deepEqual(parsed, this.json);
test.done();
}
}
|