i18n.html
2.49 KB
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
<html>
<head>
<title>testing i18n extra locales</title>
<!-- gotta do this in a separate page since clearing all the caches in the loader and dojo/i18n is too error-prone -->
<script type="text/javascript">
var dohArgs= (window.parent.doh && window.parent.doh.dohArgs) || {async:0};
var dojoConfig = {
async:dohArgs.async,
extraLocale:['en-us-hawaii', 'en-us-new_york-brooklyn'],
has:{
"dojo-unit-tests":1
}
};
</script>
<script type="text/javascript" src="../dojo.js" data-dojo-config=""></script>
<script type="text/javascript">
// the following should load the current locale + 'en-us-hawaii' and 'en-us-new_york-brooklyn
require(["doh", "dojo/_base/array", "dojo/has", "dojo/i18n", "dojo/i18n!dojo/tests/nls/salutations", "dojo/domReady!"],
function(doh, array, has, i18n){
if(dohArgs.async){
doh.register(function extraLocalesAsync(t){
// the following should load synchronously...at least with the dojo loader
var hawaii, ny;
require(["dojo/i18n!dojo/tests/nls/en-us-hawaii/salutations"], function(bundle){ hawaii = bundle;});
require(["dojo/i18n!dojo/tests/nls/en-us-new_york-brooklyn/salutations"], function(bundle){ ny = bundle;});
t.is(hawaii.hello, "Aloha");
t.is(ny.hello, "Yo");
try{
var result = require("dojo/i18n!dojo/tests/nls/ar/salutations");
t.f(true, "should have thrown");
}catch(e){
t.t(true);
}
});
}else{
doh.register(function extraLocalesSync(t){
t.is(i18n.getLocalization("dojo/tests", "salutations", "en-us-hawaii").hello, "Aloha");
t.is(i18n.getLocalization("dojo/tests", "salutations", "en-us-new_york-brooklyn").hello, "Yo");
try{
t.is(i18n.getLocalization("dojo/tests", "salutations", "en-au").hello, "G'day");
}catch(e){
t.f("synchronous get should work if not xdomain");
}
});
}
if(has("dojo-unit-tests")){
array.forEach(i18n.unitTests, function(item){item(doh);});
}
doh.run();
});
if(!require.async){
dojo.requireLocalization("dojo.tests._base.loader", "syncBundle", "ab-cd-ef");
dojo.requireLocalization("dojo.tests._base.loader", "amdBundle", "ab-cd-ef");
doh.register(function oldAndNewBundleStyles(t){
t.is(dojo.i18n.getLocalization("dojo.tests._base.loader", "syncBundle", "ab-cd-ef").syncBundle, "syncBundle-ab-cd-ef");
t.is(dojo.i18n.getLocalization("dojo.tests._base.loader", "amdBundle", "ab-cd-ef").amdBundle, "amdBundle-ab-cd-ef");
});
}
</script>
</head>
<body>
</body>
</html>