forked from BrightspaceUI/date-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
localize-behavior.html
91 lines (90 loc) · 1.99 KB
/
localize-behavior.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
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
<link rel="import" href="../app-localize-behavior/app-localize-behavior.html">
<script>
(function() {
'use strict';
/** @polymerBehavior D2L.PolymerBehaviors.DatePicker.LocalizeBehavior */
var LocalizeBehavior = {
properties: {
language: {
type: String,
default: 'en',
computed: '_computeLanguage(resources, language)'
},
resources: {
value: function() {
return {
'ar': {
today: 'اليوم',
cancel: 'إلغاء'
},
'en': {
today: 'today',
cancel: 'cancel'
},
'es': {
today: 'hoy',
cancel: 'cancelar'
},
'fr': {
today: 'aujourd\'hui',
cancel: 'Annuler'
},
'ja': {
today: '今日',
cancel: 'キャンセル'
},
'ko': {
today: '오늘',
cancel: '취소'
},
'nl': {
today: 'vandaag',
cancel: 'Annuleer'
},
'pt': {
today: 'hoje',
cancel: 'cancelar'
},
'sv': {
today: 'i dag',
cancel: 'annullera'
},
'tr': {
today: 'bugün',
cancel: 'iptal etmek'
},
'zh': {
today: '今天',
cancel: '取消'
},
'zh-tw': {
today: '今天',
cancel: '取消'
}
};
}
}
},
_computeLanguage: function(resources) {
var locale = this.language;
locale = locale.toLowerCase();
if (resources[locale]) {
return locale;
}
var langAndRegion = locale.split('-');
if (resources[langAndRegion[0]]) {
return langAndRegion[0];
}
return 'en';
}
};
window.D2L = window.D2L || {};
window.D2L.PolymerBehaviors = window.D2L.PolymerBehaviors || {};
window.D2L.PolymerBehaviors.DatePicker = window.D2L.PolymerBehaviors.DatePicker || {};
/** @polymerBehavior */
window.D2L.PolymerBehaviors.DatePicker.LocalizeBehavior = [
Polymer.AppLocalizeBehavior,
LocalizeBehavior
];
})();
</script>