1 |
|
2 | import dayjs from '../index';
|
3 |
|
4 | function dual(n) {
|
5 | return n % 100 == 2;
|
6 | }
|
7 |
|
8 | function threeFour(n) {
|
9 | return n % 100 == 3 || n % 100 == 4;
|
10 | }
|
11 |
|
12 |
|
13 |
|
14 | function translate(number, withoutSuffix, key, isFuture) {
|
15 | var result = number + " ";
|
16 |
|
17 | switch (key) {
|
18 | case 's':
|
19 |
|
20 | return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
|
21 |
|
22 | case 'm':
|
23 |
|
24 | return withoutSuffix ? 'ena minuta' : 'eno minuto';
|
25 |
|
26 | case 'mm':
|
27 |
|
28 | if (dual(number)) {
|
29 | return result + (withoutSuffix || isFuture ? 'minuti' : 'minutama');
|
30 | }
|
31 |
|
32 | if (threeFour(number)) {
|
33 | return result + (withoutSuffix || isFuture ? 'minute' : 'minutami');
|
34 | }
|
35 |
|
36 | return result + (withoutSuffix || isFuture ? 'minut' : 'minutami');
|
37 |
|
38 | case 'h':
|
39 |
|
40 | return withoutSuffix ? 'ena ura' : isFuture ? 'eno uro' : 'eno uro';
|
41 |
|
42 | case 'hh':
|
43 |
|
44 | if (dual(number)) {
|
45 | return result + (withoutSuffix || isFuture ? 'uri' : 'urama');
|
46 | }
|
47 |
|
48 | if (threeFour(number)) {
|
49 | return result + (withoutSuffix || isFuture ? 'ure' : 'urami');
|
50 | }
|
51 |
|
52 | return result + (withoutSuffix || isFuture ? 'ur' : 'urami');
|
53 |
|
54 | case 'd':
|
55 |
|
56 | return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
|
57 |
|
58 | case 'dd':
|
59 |
|
60 | if (dual(number)) {
|
61 | return result + (withoutSuffix || isFuture ? 'dneva' : 'dnevoma');
|
62 | }
|
63 |
|
64 | return result + (withoutSuffix || isFuture ? 'dni' : 'dnevi');
|
65 |
|
66 | case 'M':
|
67 |
|
68 | return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
|
69 |
|
70 | case 'MM':
|
71 |
|
72 | if (dual(number)) {
|
73 |
|
74 | return result + (withoutSuffix || isFuture ? 'meseca' : 'mesecema');
|
75 | }
|
76 |
|
77 | if (threeFour(number)) {
|
78 | return result + (withoutSuffix || isFuture ? 'mesece' : 'meseci');
|
79 | }
|
80 |
|
81 | return result + (withoutSuffix || isFuture ? 'mesecev' : 'meseci');
|
82 |
|
83 | case 'y':
|
84 |
|
85 | return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
|
86 |
|
87 | case 'yy':
|
88 |
|
89 | if (dual(number)) {
|
90 |
|
91 | return result + (withoutSuffix || isFuture ? 'leti' : 'letoma');
|
92 | }
|
93 |
|
94 | if (threeFour(number)) {
|
95 | return result + (withoutSuffix || isFuture ? 'leta' : 'leti');
|
96 | }
|
97 |
|
98 | return result + (withoutSuffix || isFuture ? 'let' : 'leti');
|
99 | }
|
100 | }
|
101 |
|
102 |
|
103 |
|
104 | var locale = {
|
105 | name: 'sl',
|
106 | weekdays: 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
|
107 | months: 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
|
108 | weekStart: 1,
|
109 | weekdaysShort: 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
|
110 | monthsShort: 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
|
111 | weekdaysMin: 'ne_po_to_sr_če_pe_so'.split('_'),
|
112 | ordinal: function ordinal(n) {
|
113 | return n + ".";
|
114 | },
|
115 | formats: {
|
116 | LT: 'H:mm',
|
117 | LTS: 'H:mm:ss',
|
118 | L: 'DD.MM.YYYY',
|
119 | LL: 'D. MMMM YYYY',
|
120 | LLL: 'D. MMMM YYYY H:mm',
|
121 | LLLL: 'dddd, D. MMMM YYYY H:mm',
|
122 | l: 'D. M. YYYY'
|
123 | },
|
124 | relativeTime: {
|
125 | future: 'čez %s',
|
126 | past: 'pred %s',
|
127 | s: translate,
|
128 | m: translate,
|
129 | mm: translate,
|
130 | h: translate,
|
131 | hh: translate,
|
132 | d: translate,
|
133 | dd: translate,
|
134 | M: translate,
|
135 | MM: translate,
|
136 | y: translate,
|
137 | yy: translate
|
138 | }
|
139 | };
|
140 | dayjs.locale(locale, null, true);
|
141 | export default locale; |
\ | No newline at end of file |