UNPKG

4.17 kBJavaScriptView Raw
1//! moment.js locale configuration
2//! locale : Polish [pl]
3//! author : Rafal Hirsz : https://github.com/evoL
4
5import moment from '../moment';
6
7var monthsNominative =
8 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split(
9 '_'
10 ),
11 monthsSubjective =
12 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split(
13 '_'
14 ),
15 monthsParse = [
16 /^sty/i,
17 /^lut/i,
18 /^mar/i,
19 /^kwi/i,
20 /^maj/i,
21 /^cze/i,
22 /^lip/i,
23 /^sie/i,
24 /^wrz/i,
25 /^paź/i,
26 /^lis/i,
27 /^gru/i,
28 ];
29function plural(n) {
30 return n % 10 < 5 && n % 10 > 1 && ~~(n / 10) % 10 !== 1;
31}
32function translate(number, withoutSuffix, key) {
33 var result = number + ' ';
34 switch (key) {
35 case 'ss':
36 return result + (plural(number) ? 'sekundy' : 'sekund');
37 case 'm':
38 return withoutSuffix ? 'minuta' : 'minutę';
39 case 'mm':
40 return result + (plural(number) ? 'minuty' : 'minut');
41 case 'h':
42 return withoutSuffix ? 'godzina' : 'godzinę';
43 case 'hh':
44 return result + (plural(number) ? 'godziny' : 'godzin');
45 case 'ww':
46 return result + (plural(number) ? 'tygodnie' : 'tygodni');
47 case 'MM':
48 return result + (plural(number) ? 'miesiące' : 'miesięcy');
49 case 'yy':
50 return result + (plural(number) ? 'lata' : 'lat');
51 }
52}
53
54export default moment.defineLocale('pl', {
55 months: function (momentToFormat, format) {
56 if (!momentToFormat) {
57 return monthsNominative;
58 } else if (/D MMMM/.test(format)) {
59 return monthsSubjective[momentToFormat.month()];
60 } else {
61 return monthsNominative[momentToFormat.month()];
62 }
63 },
64 monthsShort: 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
65 monthsParse: monthsParse,
66 longMonthsParse: monthsParse,
67 shortMonthsParse: monthsParse,
68 weekdays:
69 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
70 weekdaysShort: 'ndz_pon_wt_śr_czw_pt_sob'.split('_'),
71 weekdaysMin: 'Nd_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
72 longDateFormat: {
73 LT: 'HH:mm',
74 LTS: 'HH:mm:ss',
75 L: 'DD.MM.YYYY',
76 LL: 'D MMMM YYYY',
77 LLL: 'D MMMM YYYY HH:mm',
78 LLLL: 'dddd, D MMMM YYYY HH:mm',
79 },
80 calendar: {
81 sameDay: '[Dziś o] LT',
82 nextDay: '[Jutro o] LT',
83 nextWeek: function () {
84 switch (this.day()) {
85 case 0:
86 return '[W niedzielę o] LT';
87
88 case 2:
89 return '[We wtorek o] LT';
90
91 case 3:
92 return '[W środę o] LT';
93
94 case 6:
95 return '[W sobotę o] LT';
96
97 default:
98 return '[W] dddd [o] LT';
99 }
100 },
101 lastDay: '[Wczoraj o] LT',
102 lastWeek: function () {
103 switch (this.day()) {
104 case 0:
105 return '[W zeszłą niedzielę o] LT';
106 case 3:
107 return '[W zeszłą środę o] LT';
108 case 6:
109 return '[W zeszłą sobotę o] LT';
110 default:
111 return '[W zeszły] dddd [o] LT';
112 }
113 },
114 sameElse: 'L',
115 },
116 relativeTime: {
117 future: 'za %s',
118 past: '%s temu',
119 s: 'kilka sekund',
120 ss: translate,
121 m: translate,
122 mm: translate,
123 h: translate,
124 hh: translate,
125 d: '1 dzień',
126 dd: '%d dni',
127 w: 'tydzień',
128 ww: translate,
129 M: 'miesiąc',
130 MM: translate,
131 y: 'rok',
132 yy: translate,
133 },
134 dayOfMonthOrdinalParse: /\d{1,2}\./,
135 ordinal: '%d.',
136 week: {
137 dow: 1, // Monday is the first day of the week.
138 doy: 4, // The week that contains Jan 4th is the first week of the year.
139 },
140});