Skip to content

Commit df88b0e

Browse files
dimostenisSecrus
andauthored
Add Czech [cs] localization (#540)
* Add cs localization * Apply pre-commit hooks * Apply pre-commit --all-files Co-authored-by: Bartosz Sokorski <b.sokorski@gmail.com>
1 parent 0ba5cc1 commit df88b0e

File tree

4 files changed

+397
-0
lines changed

4 files changed

+397
-0
lines changed

pendulum/locales/cs/__init__.py

Whitespace-only changes.

pendulum/locales/cs/custom.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
cs custom locale file.
3+
"""
4+
5+
translations = {
6+
"units": {"few_second": "pár vteřin"},
7+
# Relative time
8+
"ago": "{} zpět",
9+
"from_now": "za {}",
10+
"after": "{0} po",
11+
"before": "{0} zpět",
12+
# Ordinals
13+
"ordinal": {"one": ".", "two": ".", "few": ".", "other": "."},
14+
# Date formats
15+
"date_formats": {
16+
"LTS": "h:mm:ss",
17+
"LT": "h:mm",
18+
"L": "DD. M. YYYY",
19+
"LL": "D. MMMM, YYYY",
20+
"LLL": "D. MMMM, YYYY h:mm",
21+
"LLLL": "dddd, D. MMMM, YYYY h:mm",
22+
},
23+
}

pendulum/locales/cs/locale.py

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
from .custom import translations as custom_translations
2+
3+
4+
"""
5+
cs locale file.
6+
7+
It has been generated automatically and must not be modified directly.
8+
"""
9+
10+
11+
locale = {
12+
"plural": lambda n: "few"
13+
if ((n == n and (n >= 2 and n <= 4)) and (0 == 0 and (0 == 0)))
14+
else "many"
15+
if (not (0 == 0 and (0 == 0)))
16+
else "one"
17+
if ((n == n and (n == 1)) and (0 == 0 and (0 == 0)))
18+
else "other",
19+
"ordinal": lambda n: "other",
20+
"translations": {
21+
"days": {
22+
"abbreviated": {
23+
0: "ne",
24+
1: "po",
25+
2: "út",
26+
3: "st",
27+
4: "čt",
28+
5: "pá",
29+
6: "so",
30+
},
31+
"narrow": {
32+
0: "N",
33+
1: "P",
34+
2: "Ú",
35+
3: "S",
36+
4: "Č",
37+
5: "P",
38+
6: "S",
39+
},
40+
"short": {
41+
0: "ne",
42+
1: "po",
43+
2: "út",
44+
3: "st",
45+
4: "čt",
46+
5: "pá",
47+
6: "so",
48+
},
49+
"wide": {
50+
0: "neděle",
51+
1: "pondělí",
52+
2: "úterý",
53+
3: "středa",
54+
4: "čtvrtek",
55+
5: "pátek",
56+
6: "sobota",
57+
},
58+
},
59+
"months": {
60+
"abbreviated": {
61+
1: "led",
62+
2: "úno",
63+
3: "bře",
64+
4: "dub",
65+
5: "kvě",
66+
6: "čvn",
67+
7: "čvc",
68+
8: "srp",
69+
9: "zář",
70+
10: "říj",
71+
11: "lis",
72+
12: "pro",
73+
},
74+
"narrow": {
75+
1: "1",
76+
2: "2",
77+
3: "3",
78+
4: "4",
79+
5: "5",
80+
6: "6",
81+
7: "7",
82+
8: "8",
83+
9: "9",
84+
10: "10",
85+
11: "11",
86+
12: "12",
87+
},
88+
"wide": {
89+
1: "ledna",
90+
2: "února",
91+
3: "března",
92+
4: "dubna",
93+
5: "května",
94+
6: "června",
95+
7: "července",
96+
8: "srpna",
97+
9: "září",
98+
10: "října",
99+
11: "listopadu",
100+
12: "prosince",
101+
},
102+
},
103+
"units": {
104+
"year": {
105+
"one": "{0} rok",
106+
"few": "{0} roky",
107+
"many": "{0} roku",
108+
"other": "{0} let",
109+
},
110+
"month": {
111+
"one": "{0} měsíc",
112+
"few": "{0} měsíce",
113+
"many": "{0} měsíce",
114+
"other": "{0} měsíců",
115+
},
116+
"week": {
117+
"one": "{0} týden",
118+
"few": "{0} týdny",
119+
"many": "{0} týdne",
120+
"other": "{0} týdnů",
121+
},
122+
"day": {
123+
"one": "{0} den",
124+
"few": "{0} dny",
125+
"many": "{0} dne",
126+
"other": "{0} dní",
127+
},
128+
"hour": {
129+
"one": "{0} hodina",
130+
"few": "{0} hodiny",
131+
"many": "{0} hodiny",
132+
"other": "{0} hodin",
133+
},
134+
"minute": {
135+
"one": "{0} minuta",
136+
"few": "{0} minuty",
137+
"many": "{0} minuty",
138+
"other": "{0} minut",
139+
},
140+
"second": {
141+
"one": "{0} sekunda",
142+
"few": "{0} sekundy",
143+
"many": "{0} sekundy",
144+
"other": "{0} sekund",
145+
},
146+
"microsecond": {
147+
"one": "{0} mikrosekunda",
148+
"few": "{0} mikrosekundy",
149+
"many": "{0} mikrosekundy",
150+
"other": "{0} mikrosekund",
151+
},
152+
},
153+
"relative": {
154+
"year": {
155+
"future": {
156+
"other": "za {0} let",
157+
"one": "za {0} rok",
158+
"few": "za {0} roky",
159+
"many": "za {0} roku",
160+
},
161+
"past": {
162+
"other": "před {0} lety",
163+
"one": "před {0} rokem",
164+
"few": "před {0} lety",
165+
"many": "před {0} roku",
166+
},
167+
},
168+
"month": {
169+
"future": {
170+
"other": "za {0} měsíců",
171+
"one": "za {0} měsíc",
172+
"few": "za {0} měsíce",
173+
"many": "za {0} měsíce",
174+
},
175+
"past": {
176+
"other": "před {0} měsíci",
177+
"one": "před {0} měsícem",
178+
"few": "před {0} měsíci",
179+
"many": "před {0} měsíce",
180+
},
181+
},
182+
"week": {
183+
"future": {
184+
"other": "za {0} týdnů",
185+
"one": "za {0} týden",
186+
"few": "za {0} týdny",
187+
"many": "za {0} týdne",
188+
},
189+
"past": {
190+
"other": "před {0} týdny",
191+
"one": "před {0} týdnem",
192+
"few": "před {0} týdny",
193+
"many": "před {0} týdne",
194+
},
195+
},
196+
"day": {
197+
"future": {
198+
"other": "za {0} dní",
199+
"one": "za {0} den",
200+
"few": "za {0} dny",
201+
"many": "za {0} dne",
202+
},
203+
"past": {
204+
"other": "před {0} dny",
205+
"one": "před {0} dnem",
206+
"few": "před {0} dny",
207+
"many": "před {0} dne",
208+
},
209+
},
210+
"hour": {
211+
"future": {
212+
"other": "za {0} hodin",
213+
"one": "za {0} hodinu",
214+
"few": "za {0} hodiny",
215+
"many": "za {0} hodiny",
216+
},
217+
"past": {
218+
"other": "před {0} hodinami",
219+
"one": "před {0} hodinou",
220+
"few": "před {0} hodinami",
221+
"many": "před {0} hodiny",
222+
},
223+
},
224+
"minute": {
225+
"future": {
226+
"other": "za {0} minut",
227+
"one": "za {0} minutu",
228+
"few": "za {0} minuty",
229+
"many": "za {0} minuty",
230+
},
231+
"past": {
232+
"other": "před {0} minutami",
233+
"one": "před {0} minutou",
234+
"few": "před {0} minutami",
235+
"many": "před {0} minuty",
236+
},
237+
},
238+
"second": {
239+
"future": {
240+
"other": "za {0} sekund",
241+
"one": "za {0} sekundu",
242+
"few": "za {0} sekundy",
243+
"many": "za {0} sekundy",
244+
},
245+
"past": {
246+
"other": "před {0} sekundami",
247+
"one": "před {0} sekundou",
248+
"few": "před {0} sekundami",
249+
"many": "před {0} sekundy",
250+
},
251+
},
252+
},
253+
"day_periods": {
254+
"midnight": "půlnoc",
255+
"am": "dop.",
256+
"noon": "poledne",
257+
"pm": "odp.",
258+
"morning1": "ráno",
259+
"morning2": "dopoledne",
260+
"afternoon1": "odpoledne",
261+
"evening1": "večer",
262+
"night1": "v noci",
263+
},
264+
},
265+
"custom": custom_translations,
266+
}

tests/localization/test_cs.py

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import pendulum
2+
3+
4+
locale = "cs"
5+
6+
7+
def test_diff_for_humans():
8+
with pendulum.test(pendulum.datetime(2016, 8, 29)):
9+
diff_for_humans()
10+
11+
12+
def diff_for_humans():
13+
d = pendulum.now().subtract(seconds=1)
14+
assert d.diff_for_humans(locale=locale) == "pár vteřin zpět"
15+
16+
d = pendulum.now().subtract(seconds=2)
17+
assert d.diff_for_humans(locale=locale) == "pár vteřin zpět"
18+
19+
d = pendulum.now().subtract(seconds=20)
20+
assert d.diff_for_humans(locale=locale) == "před 20 sekundami"
21+
22+
d = pendulum.now().subtract(minutes=1)
23+
assert d.diff_for_humans(locale=locale) == "před 1 minutou"
24+
25+
d = pendulum.now().subtract(minutes=2)
26+
assert d.diff_for_humans(locale=locale) == "před 2 minutami"
27+
28+
d = pendulum.now().subtract(minutes=5)
29+
assert d.diff_for_humans(locale=locale) == "před 5 minutami"
30+
31+
d = pendulum.now().subtract(hours=1)
32+
assert d.diff_for_humans(locale=locale) == "před 1 hodinou"
33+
34+
d = pendulum.now().subtract(hours=2)
35+
assert d.diff_for_humans(locale=locale) == "před 2 hodinami"
36+
37+
d = pendulum.now().subtract(hours=5)
38+
assert d.diff_for_humans(locale=locale) == "před 5 hodinami"
39+
40+
d = pendulum.now().subtract(days=1)
41+
assert d.diff_for_humans(locale=locale) == "před 1 dnem"
42+
43+
d = pendulum.now().subtract(days=2)
44+
assert d.diff_for_humans(locale=locale) == "před 2 dny"
45+
46+
d = pendulum.now().subtract(weeks=1)
47+
assert d.diff_for_humans(locale=locale) == "před 1 týdnem"
48+
49+
d = pendulum.now().subtract(weeks=2)
50+
assert d.diff_for_humans(locale=locale) == "před 2 týdny"
51+
52+
d = pendulum.now().subtract(months=1)
53+
assert d.diff_for_humans(locale=locale) == "před 1 měsícem"
54+
55+
d = pendulum.now().subtract(months=2)
56+
assert d.diff_for_humans(locale=locale) == "před 2 měsíci"
57+
58+
d = pendulum.now().subtract(months=5)
59+
assert d.diff_for_humans(locale=locale) == "před 5 měsíci"
60+
61+
d = pendulum.now().subtract(years=1)
62+
assert d.diff_for_humans(locale=locale) == "před 1 rokem"
63+
64+
d = pendulum.now().subtract(years=2)
65+
assert d.diff_for_humans(locale=locale) == "před 2 lety"
66+
67+
d = pendulum.now().subtract(years=5)
68+
assert d.diff_for_humans(locale=locale) == "před 5 lety"
69+
70+
d = pendulum.now().add(seconds=1)
71+
assert d.diff_for_humans(locale=locale) == "za pár vteřin"
72+
73+
d = pendulum.now().add(seconds=1)
74+
d2 = pendulum.now()
75+
assert d.diff_for_humans(d2, locale=locale) == "pár vteřin po"
76+
assert d2.diff_for_humans(d, locale=locale) == "pár vteřin zpět"
77+
78+
assert d.diff_for_humans(d2, True, locale=locale) == "pár vteřin"
79+
assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "pár vteřin"
80+
81+
d = pendulum.now().add(seconds=20)
82+
d2 = pendulum.now()
83+
assert d.diff_for_humans(d2, locale=locale) == "20 sekund po"
84+
assert d2.diff_for_humans(d, locale=locale) == "20 sekund zpět"
85+
86+
d = pendulum.now().add(seconds=10)
87+
d2 = pendulum.now()
88+
assert d.diff_for_humans(d2, True, locale=locale) == "pár vteřin"
89+
assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "11 sekund"
90+
91+
92+
def test_format():
93+
d = pendulum.datetime(2016, 8, 29, 7, 3, 6, 123456)
94+
assert d.format("dddd", locale=locale) == "pondělí"
95+
assert d.format("ddd", locale=locale) == "po"
96+
assert d.format("MMMM", locale=locale) == "srpna"
97+
assert d.format("MMM", locale=locale) == "srp"
98+
assert d.format("A", locale=locale) == "dop."
99+
assert d.format("Qo", locale=locale) == "3."
100+
assert d.format("Mo", locale=locale) == "8."
101+
assert d.format("Do", locale=locale) == "29."
102+
103+
assert d.format("LT", locale=locale) == "7:03"
104+
assert d.format("LTS", locale=locale) == "7:03:06"
105+
assert d.format("L", locale=locale) == "29. 8. 2016"
106+
assert d.format("LL", locale=locale) == "29. srpna, 2016"
107+
assert d.format("LLL", locale=locale) == "29. srpna, 2016 7:03"
108+
assert d.format("LLLL", locale=locale) == "pondělí, 29. srpna, 2016 7:03"

0 commit comments

Comments
 (0)