/
i18n.html
66 lines (54 loc) · 1.44 KB
/
i18n.html
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
<!DOCTYPE HTML>
<html>
<head>
<title>i18n tests</title>
<script>
curl = {
baseUrl: '.',
paths: {
curl: '../src/curl'
},
//locale: true, //'en-gb',
preloads: [
'curl/tdd/undefine'
]
};
</script>
<script src="../src/curl.js" type="text/javascript"></script>
<script type="text/javascript">
test1();
function test1 () {
curl(['i18n!i18n/strings', 'curl/tdd/undefine']).then(
function (strings, undefine) {
var val1 = !!strings, val2 = strings.labels.beer == 'brew';
write((val1 ? 'SUCCESS' : 'FAILED') + ': i18n string bundle should be loaded.');
write((val2 ? 'SUCCESS' : 'FAILED') + ': i18n string should have correct value.');
undefine(['curl/plugin/i18n!i18n/strings', 'i18n/strings']);
},
function (ex) {
write('FAILED: to load i18n!i18n/strings ' + ex.message);
}
).then(test2);
}
function test2 () {
curl({ locale: 'en-gb' }, ['i18n!i18n/strings']).then(
function (strings) {
var val1 = !!strings, val2 = strings.labels.beer == 'pint';
write((val1 ? 'SUCCESS' : 'FAILED') + ': i18n string bundle (en-gb) should be loaded.');
write((val2 ? 'SUCCESS' : 'FAILED') + ': i18n string should have correct value (en-gb).');
},
function (ex) {
write('FAILED: to load i18n!i18n/strings (en-gb) ' + ex.message);
}
);
}
function write (msg) {
curl('domReady!', function () {
document.body.appendChild(document.createElement('div')).innerHTML = msg;
});
}
</script>
</head>
<body>
</body>
</html>