forked from syncfusion/ej2-aspnetcore-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobalization.cshtml
151 lines (133 loc) · 4.91 KB
/
Globalization.cshtml
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
145
146
147
148
149
150
@using Syncfusion.EJ2
@section ControlsSection{
<div class="col-lg-8 control-section">
<div class="calender-section">
<div id="calender-control">
<ejs-calendar id="calendar" change="startDate"></ejs-calendar>
<br>
<span id="date_label"> Selected Value: </span>
</div>
</div>
</div>
<div class="col-lg-4 property-section">
<div class="radio-control" id="property" title="Select a Locale">
<div class="row">
<ejs-radiobutton id="en" name="locale" label="English" value="en" change="onLocaleChange"></ejs-radiobutton>
</div>
<div class="row">
<ejs-radiobutton id="de" name="locale" label="German" value="de" change="onLocaleChange" checked="true"></ejs-radiobutton>
</div>
<div class="row">
<ejs-radiobutton id="ar" name="locale" label="Arabic" value="ar" change="onLocaleChange"></ejs-radiobutton>
</div>
</div>
</div>
}
<script>
function startDate(args) {
/*Displays selected date in the label*/
(document.getElementById('date_label')).textContent = 'Selected Value: ' + args.value.toLocaleDateString();
}
function onLocaleChange(args) {
/*Apply selected format to the component*/
var culture = args.value;
calendarObject.locale = culture;
calendarObject.enableRtl = (calendarObject.locale === 'ar');
if (culture !== 'en') {
loadCultureFiles(culture);
}
globalize = new ej.base.Internationalization(calendarObject.locale);
if (calendarObject.value) {
var dateString = globalize.formatDate(calendarObject.value);
(document.getElementById('date_label')).textContent = 'Selected Value: ' + dateString;
}
}
document.addEventListener('DOMContentLoaded', function () {
calendarObject = document.getElementById('calendar').ej2_instances[0];
var L10n = ej.base.L10n;
L10n.load({
"de": {
"calendar": {
today: 'heute'
}
},
"en": {
"calendar": {
today: 'Today'
}
},
"ar": {
"calendar": {
today: 'اليوم'
}
},
});
loadCultureFiles('de');
calendarObject.locale = 'de';
});
function loadCultureFiles(name) {
var files = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json'];
if (name === 'ar') {
files.push('numberingSystems.json');
}
var loader = ej.base.loadCldr;
var loadCulture = function (prop) {
var val, ajax;
if (name === 'ar' && prop === files.length - 1) {
ajax = new ej.base.Ajax(location.origin + location.pathname + '/../../scripts/cldr-data/supplemental/' + files[prop], 'GET', false);
} else {
ajax = new ej.base.Ajax(location.origin + location.pathname + '/../../scripts/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(prop);
}
}
</script>
@*custom code start*@
<style>
#date_label {
display: block;
width: 248px;
color: rgba(0, 0, 0, 0.58);
margin-left: 5px;
}
#calender-control {
max-width: 300px;
margin: 0 auto;
}
body.highcontrast #date_label {
color: white;
}
.property-section {
width: 200px;
}
</style>
@*custom code end*@
@section ActionDescription{
<div id="action-description">
<p>
In this sample, the calendar has been configured with
<code>German</code> culture. To change this current culture, go to the properties panel at the right side and select a culture from
the available options.For mobile mode touch the icon at the right side and select a culture from the available options.
</p>
</div>
}
@section Description{
<div id="description">
<p>
The calendar component was rendered with
<code>German</code> culture. Here the date separator, week header and month text content are updated based on current culture. You
can also change the component culture by selecting it from the culture options in the properties panel.
</p>
<p>
More information on the internationalization configuration can be found in this
<a href="https://ej2.syncfusion.com/aspnetcore/documentation/calendar/globalization/" target="_blank"> documentation section</a>.
</p>
</div>
}