-
Notifications
You must be signed in to change notification settings - Fork 21
/
test.js
58 lines (48 loc) · 2.69 KB
/
test.js
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
asyncTest("translation", function() {
var o = {
lang : 'testlang'
};
$.jsperanto.init(function(t){
equals(t('product.name'),"jsperanto");
equals(t('withreuse'),"jsperanto and Home");
equals(t('withreplacement',{year:2005}),"since 2005");
equals(t('4.level.of.nesting'),"4 level of nesting");
equals(t('not.existing.key',{defaultValue:"default"}),"default");
equals(t('product.name'),"jsperanto");
equals(t('pluralversionexist',{count:2}),"plural version of pluralversionexist");
equals(t('pluralversionexist',{count:1}),"singular version of pluralversionexist");
equals(t('pluralversionexist'),"singular version of pluralversionexist");
equals(t('pluralversiondoesnotexist',{count:2}),"plural version does not exist");
equals(t('withHTML'),"<b>this would be bold</b>");
equals(t('count and replacement',{count:1}),"you have 1 friend");
equals(t('count and replacement',{count:3}),"you have 3 friends");
equals($.t('can_speak_plural',{count:'any'}),"I can speak any languages","count can be a string");
equals($.t('project.size.source',{value:4,unit:"kb"}),"jsperanto is 4 kb","Interpolation variables can be a number");
equals($.t('project.size.min',{value:1010,unit:"bytes"}),"jsperanto is 1010 bytes when minified","options are also used for nested lookup ");
equals($.t('project.size.gzip',{value:505,unit:"bytes"}),"jsperanto is 505 bytes when minified and gzipped","options are also used for nested lookup");
equals(t('not.existing.key'),"not.existing.key");
t('infinite');
equals(true,true,"recursive nested lookup should not crash");
},o);
o.getSuffixMethod = function(count){
if ( count == 0 ) {
return "_zero";
}
if ( count != 1 ) {
return "_plural";
}
};
$.jsperanto.init(function(t){
equals(t('countCustomSuffix',{count:0}),"I have exactly zero. The count is 0");
equals(t('countCustomSuffix',{count:0.5}),"I have many. The count is 0.5");
equals(t('countCustomSuffix',{count:1}),"I have exactly one. The count is 1");
equals(t('countCustomSuffix',{count:3}),"I have many. The count is 3");
equals(t('countCustomSuffix',{count:-1}),"I have many. The count is -1");
equals(t('countCustomSuffix',{count:"0"}),"I have exactly zero. The count is 0");
equals(t('countCustomSuffix',{count:"string"}),"I have many. The count is string");
equals(t('countCustomSuffix',{count:"1"}),"I have exactly one. The count is 1");
equals(t('countCustomSuffix',{count:"01"}),"I have exactly one. The count is 01");
start();
},o);
});
//TODO test options