Skip to content

Commit 9f4011b

Browse files
authored
Add tr locale (#638)
1 parent 8b7a33f commit 9f4011b

File tree

4 files changed

+305
-0
lines changed

4 files changed

+305
-0
lines changed

pendulum/locales/tr/__init__.py

Whitespace-only changes.

pendulum/locales/tr/custom.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
tr custom locale file.
3+
"""
4+
5+
translations = {
6+
# Relative time
7+
"ago": "{} önce",
8+
"from_now": "{} içinde",
9+
"after": "{0} sonra",
10+
"before": "{0} önce",
11+
# Ordinals
12+
"ordinal": {"one": ".", "two": ".", "few": ".", "other": "."},
13+
# Date formats
14+
"date_formats": {
15+
"LTS": "h:mm:ss A",
16+
"LT": "h:mm A",
17+
"L": "MM/DD/YYYY",
18+
"LL": "MMMM D, YYYY",
19+
"LLL": "MMMM D, YYYY h:mm A",
20+
"LLLL": "dddd, MMMM D, YYYY h:mm A",
21+
},
22+
}

pendulum/locales/tr/locale.py

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
from .custom import translations as custom_translations
2+
3+
4+
"""
5+
tr locale file.
6+
7+
It has been generated automatically and must not be modified directly.
8+
"""
9+
10+
11+
locale = {
12+
"plural": lambda n: "one" if (n == n and (n == 1)) else "other",
13+
"ordinal": lambda n: "other",
14+
"translations": {
15+
"days": {
16+
"abbreviated": {
17+
0: "Paz",
18+
1: "Pzt",
19+
2: "Sal",
20+
3: "Çar",
21+
4: "Per",
22+
5: "Cum",
23+
6: "Cmt",
24+
},
25+
"narrow": {
26+
0: "P",
27+
1: "P",
28+
2: "S",
29+
3: "Ç",
30+
4: "P",
31+
5: "C",
32+
6: "C",
33+
},
34+
"short": {
35+
0: "Pa",
36+
1: "Pt",
37+
2: "Sa",
38+
3: "Ça",
39+
4: "Pe",
40+
5: "Cu",
41+
6: "Ct",
42+
},
43+
"wide": {
44+
0: "Pazar",
45+
1: "Pazartesi",
46+
2: "Salı",
47+
3: "Çarşamba",
48+
4: "Perşembe",
49+
5: "Cuma",
50+
6: "Cumartesi",
51+
},
52+
},
53+
"months": {
54+
"abbreviated": {
55+
1: "Oca",
56+
2: "Şub",
57+
3: "Mar",
58+
4: "Nis",
59+
5: "May",
60+
6: "Haz",
61+
7: "Tem",
62+
8: "Ağu",
63+
9: "Eyl",
64+
10: "Eki",
65+
11: "Kas",
66+
12: "Ara",
67+
},
68+
"narrow": {
69+
1: "O",
70+
2: "Ş",
71+
3: "M",
72+
4: "N",
73+
5: "M",
74+
6: "H",
75+
7: "T",
76+
8: "A",
77+
9: "E",
78+
10: "E",
79+
11: "K",
80+
12: "A",
81+
},
82+
"wide": {
83+
1: "Ocak",
84+
2: "Şubat",
85+
3: "Mart",
86+
4: "Nisan",
87+
5: "Mayıs",
88+
6: "Haziran",
89+
7: "Temmuz",
90+
8: "Ağustos",
91+
9: "Eylül",
92+
10: "Ekim",
93+
11: "Kasım",
94+
12: "Aralık",
95+
},
96+
},
97+
"units": {
98+
"year": {
99+
"one": "{0} yıl",
100+
"other": "{0} yıl",
101+
},
102+
"month": {
103+
"one": "{0} ay",
104+
"other": "{0} ay",
105+
},
106+
"week": {
107+
"one": "{0} hafta",
108+
"other": "{0} hafta",
109+
},
110+
"day": {
111+
"one": "{0} gün",
112+
"other": "{0} gün",
113+
},
114+
"hour": {
115+
"one": "{0} saat",
116+
"other": "{0} saat",
117+
},
118+
"minute": {
119+
"one": "{0} dakika",
120+
"other": "{0} dakika",
121+
},
122+
"second": {
123+
"one": "{0} saniye",
124+
"other": "{0} saniye",
125+
},
126+
"microsecond": {
127+
"one": "{0} mikrosaniye",
128+
"other": "{0} mikrosaniye",
129+
},
130+
},
131+
"relative": {
132+
"year": {
133+
"future": {
134+
"other": "{0} yıl sonra",
135+
"one": "{0} yıl sonra",
136+
},
137+
"past": {
138+
"other": "{0} yıl önce",
139+
"one": "{0} yıl önce",
140+
},
141+
},
142+
"month": {
143+
"future": {
144+
"other": "{0} ay sonra",
145+
"one": "{0} ay sonra",
146+
},
147+
"past": {
148+
"other": "{0} ay önce",
149+
"one": "{0} ay önce",
150+
},
151+
},
152+
"week": {
153+
"future": {
154+
"other": "{0} hafta sonra",
155+
"one": "{0} hafta sonra",
156+
},
157+
"past": {
158+
"other": "{0} hafta önce",
159+
"one": "{0} hafta önce",
160+
},
161+
},
162+
"day": {
163+
"future": {
164+
"other": "{0} gün sonra",
165+
"one": "{0} gün sonra",
166+
},
167+
"past": {
168+
"other": "{0} gün önce",
169+
"one": "{0} gün önce",
170+
},
171+
},
172+
"hour": {
173+
"future": {
174+
"other": "{0} saat sonra",
175+
"one": "{0} saat sonra",
176+
},
177+
"past": {
178+
"other": "{0} saat önce",
179+
"one": "{0} saat önce",
180+
},
181+
},
182+
"minute": {
183+
"future": {
184+
"other": "{0} dakika sonra",
185+
"one": "{0} dakika sonra",
186+
},
187+
"past": {
188+
"other": "{0} dakika önce",
189+
"one": "{0} dakika önce",
190+
},
191+
},
192+
"second": {
193+
"future": {
194+
"other": "{0} saniye sonra",
195+
"one": "{0} saniye sonra",
196+
},
197+
"past": {
198+
"other": "{0} saniye önce",
199+
"one": "{0} saniye önce",
200+
},
201+
},
202+
},
203+
"day_periods": {
204+
"midnight": "gece yarısı",
205+
"am": "ÖÖ",
206+
"noon": "öğle",
207+
"pm": "ÖS",
208+
"morning1": "sabah",
209+
"morning2": "öğleden önce",
210+
"afternoon1": "öğleden sonra",
211+
"afternoon2": "akşamüstü",
212+
"evening1": "akşam",
213+
"night1": "gece",
214+
},
215+
},
216+
"custom": custom_translations,
217+
}

tests/localization/test_tr.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from __future__ import annotations
2+
3+
import pendulum
4+
5+
6+
locale = "tr"
7+
8+
9+
def test_diff_for_humans():
10+
with pendulum.test(pendulum.datetime(2016, 8, 29)):
11+
diff_for_humans()
12+
13+
14+
def diff_for_humans():
15+
d = pendulum.now().subtract(seconds=1)
16+
assert d.diff_for_humans(locale=locale) == "1 saniye önce"
17+
18+
d = pendulum.now().subtract(seconds=2)
19+
assert d.diff_for_humans(locale=locale) == "2 saniye önce"
20+
21+
d = pendulum.now().subtract(minutes=1)
22+
assert d.diff_for_humans(locale=locale) == "1 dakika önce"
23+
24+
d = pendulum.now().subtract(minutes=2)
25+
assert d.diff_for_humans(locale=locale) == "2 dakika önce"
26+
27+
d = pendulum.now().subtract(hours=1)
28+
assert d.diff_for_humans(locale=locale) == "1 saat önce"
29+
30+
d = pendulum.now().subtract(hours=2)
31+
assert d.diff_for_humans(locale=locale) == "2 saat önce"
32+
33+
d = pendulum.now().subtract(days=1)
34+
assert d.diff_for_humans(locale=locale) == "1 gün önce"
35+
36+
d = pendulum.now().subtract(days=2)
37+
assert d.diff_for_humans(locale=locale) == "2 gün önce"
38+
39+
d = pendulum.now().subtract(weeks=1)
40+
assert d.diff_for_humans(locale=locale) == "1 hafta önce"
41+
42+
d = pendulum.now().subtract(weeks=2)
43+
assert d.diff_for_humans(locale=locale) == "2 hafta önce"
44+
45+
d = pendulum.now().subtract(months=1)
46+
assert d.diff_for_humans(locale=locale) == "1 ay önce"
47+
48+
d = pendulum.now().subtract(months=2)
49+
assert d.diff_for_humans(locale=locale) == "2 ay önce"
50+
51+
d = pendulum.now().subtract(years=1)
52+
assert d.diff_for_humans(locale=locale) == "1 yıl önce"
53+
54+
d = pendulum.now().subtract(years=2)
55+
assert d.diff_for_humans(locale=locale) == "2 yıl önce"
56+
57+
d = pendulum.now().add(seconds=1)
58+
assert d.diff_for_humans(locale=locale) == "1 saniye sonra"
59+
60+
d = pendulum.now().add(seconds=1)
61+
d2 = pendulum.now()
62+
assert d.diff_for_humans(d2, locale=locale) == "1 saniye sonra"
63+
assert d2.diff_for_humans(d, locale=locale) == "1 saniye önce"
64+
65+
assert d.diff_for_humans(d2, True, locale=locale) == "1 saniye"
66+
assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "2 saniye"

0 commit comments

Comments
 (0)