Repository navigation
Expand file tree
/
Copy pathinternationalization.js
More file actions
97 lines (97 loc) · 3.45 KB
/
Copy pathinternationalization.js
File metadata and controls
97 lines (97 loc) · 3.45 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
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
this.default = function () {
// Loading English, German and Chinese cultures
ej.base.L10n.load({
'en': {
'numerictextbox': { incrementTitle: 'Increment value', decrementTitle: 'Decrement value' }
},
'de': {
'numerictextbox': { incrementTitle: 'Wert erhöhen', decrementTitle: 'Dekrementwert' }
},
'zh': {
'numerictextbox': { incrementTitle: '增值', decrementTitle: '遞減值' }
}
});
function loadCultureFiles(name) {
var files = ['currencies.json', 'numbers.json'];
if (name === 'zh') {
files.push('currencyData.json');
}
var loader = ej.base.loadCldr;
var loadCulture = function () {
var val,ajax;
if (name === 'zh' && prop === files.length-1) {
ajax = new ej.base.Ajax(location.origin + location.pathname + 'src/common/cldr-data/supplemental/' + files[prop], 'GET', false);
} else {
ajax = new ej.base.Ajax(location.origin + location.pathname + 'src/common/cldr-data/main/' + name + '/' + files[prop], 'GET', false);
}
ajax.onSuccess = function (value) {
val = value;
};
ajax.send();
loader(JSON.parse(val));
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture();
}
}
loadCultureFiles('de');
// Render the Numeric Textbox
var numeric = new ej.inputs.NumericTextBox({
locale: 'de',
value: 10,
placeholder: 'Geben Sie den Wert ein',
floatLabelType: 'Always'
});
numeric.appendTo('#numeric');
// Render the Percentage Textbox
var percent = new ej.inputs.NumericTextBox({
format: 'p2',
locale: 'de',
value: 0.5,
min: 0,
max: 1,
step: 0.01,
placeholder: 'Geben Sie den Prozentsatz ein',
floatLabelType: 'Always'
});
percent.appendTo('#percent');
// Render the Currency Textbox
var currency = new ej.inputs.NumericTextBox({
format: 'c2',
locale: 'de',
value: 100,
currency: 'EUR',
placeholder: 'Geben Sie die Währung ein',
floatLabelType: 'Always'
});
currency.appendTo('#currency');
document.getElementById('cultures').addEventListener('change', changeLocale);
// While changing culture 'locale', 'currency' and 'placeholder' values will be modified.
function changeLocale() {
var culture = document.getElementById('cultures').value;
numeric.locale = culture;
percent.locale = culture;
currency.locale = culture;
if (culture != 'en') {
loadCultureFiles(culture);
}
if (culture === 'zh') {
currency.currency = 'CNY';
numeric.placeholder = '输入值';
currency.placeholder = '输入货币';
percent.placeholder = '输入百分比';
}
else if (culture === 'de') {
currency.currency = 'EUR';
numeric.placeholder = 'Geben Sie den Wert ein';
currency.placeholder = 'Geben Sie die Währung ein';
percent.placeholder = 'Geben Sie den Prozentsatz ein';
}
else {
currency.currency = 'USD';
numeric.placeholder = 'Enter the value';
currency.placeholder = 'Enter the currency';
percent.placeholder = 'Enter the percentage';
}
}
};