Skip to content

Commit c85022e

Browse files
authored
Add Hebrew (he) locale to pendulum (#585)
* Add Hebrew(he) locale * Hebrew (he) localization tests and customization
1 parent 3b52e43 commit c85022e

File tree

4 files changed

+358
-0
lines changed

4 files changed

+358
-0
lines changed

pendulum/locales/he/__init__.py

Whitespace-only changes.

pendulum/locales/he/custom.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
he custom locale file.
3+
"""
4+
5+
translations = {
6+
"units": {"few_second": "כמה שניות"},
7+
# Relative time
8+
"ago": "לפני {0}",
9+
"from_now": "תוך {0}",
10+
"after": "בעוד {0}",
11+
"before": "{0} קודם",
12+
# Ordinals
13+
"ordinal": {"other": "º"},
14+
# Date formats
15+
"date_formats": {
16+
"LTS": "H:mm:ss",
17+
"LT": "H:mm",
18+
"LLLL": "dddd, D [ב] MMMM [ב] YYYY H:mm",
19+
"LLL": "D [ב] MMMM [ב] YYYY H:mm",
20+
"LL": "D [ב] MMMM [ב] YYYY",
21+
"L": "DD/MM/YYYY",
22+
},
23+
}

pendulum/locales/he/locale.py

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
from .custom import translations as custom_translations
2+
3+
4+
"""
5+
he locale file.
6+
7+
It has been generated automatically and must not be modified directly.
8+
"""
9+
10+
11+
locale = {
12+
"plural": lambda n: "many"
13+
if (
14+
((0 == 0 and (0 == 0)) and (not (n == n and (n >= 0 and n <= 10))))
15+
and ((n % 10) == (n % 10) and ((n % 10) == 0))
16+
)
17+
else "one"
18+
if ((n == n and (n == 1)) and (0 == 0 and (0 == 0)))
19+
else "two"
20+
if ((n == n and (n == 2)) and (0 == 0 and (0 == 0)))
21+
else "other",
22+
"ordinal": lambda n: "other",
23+
"translations": {
24+
"days": {
25+
"abbreviated": {
26+
0: "יום א׳",
27+
1: "יום ב׳",
28+
2: "יום ג׳",
29+
3: "יום ד׳",
30+
4: "יום ה׳",
31+
5: "יום ו׳",
32+
6: "שבת",
33+
},
34+
"narrow": {
35+
0: "א׳",
36+
1: "ב׳",
37+
2: "ג׳",
38+
3: "ד׳",
39+
4: "ה׳",
40+
5: "ו׳",
41+
6: "ש׳",
42+
},
43+
"short": {
44+
0: "א׳",
45+
1: "ב׳",
46+
2: "ג׳",
47+
3: "ד׳",
48+
4: "ה׳",
49+
5: "ו׳",
50+
6: "ש׳",
51+
},
52+
"wide": {
53+
0: "יום ראשון",
54+
1: "יום שני",
55+
2: "יום שלישי",
56+
3: "יום רביעי",
57+
4: "יום חמישי",
58+
5: "יום שישי",
59+
6: "יום שבת",
60+
},
61+
},
62+
"months": {
63+
"abbreviated": {
64+
1: "ינו׳",
65+
2: "פבר׳",
66+
3: "מרץ",
67+
4: "אפר׳",
68+
5: "מאי",
69+
6: "יוני",
70+
7: "יולי",
71+
8: "אוג׳",
72+
9: "ספט׳",
73+
10: "אוק׳",
74+
11: "נוב׳",
75+
12: "דצמ׳",
76+
},
77+
"narrow": {
78+
1: "1",
79+
2: "2",
80+
3: "3",
81+
4: "4",
82+
5: "5",
83+
6: "6",
84+
7: "7",
85+
8: "8",
86+
9: "9",
87+
10: "10",
88+
11: "11",
89+
12: "12",
90+
},
91+
"wide": {
92+
1: "ינואר",
93+
2: "פברואר",
94+
3: "מרץ",
95+
4: "אפריל",
96+
5: "מאי",
97+
6: "יוני",
98+
7: "יולי",
99+
8: "אוגוסט",
100+
9: "ספטמבר",
101+
10: "אוקטובר",
102+
11: "נובמבר",
103+
12: "דצמבר",
104+
},
105+
},
106+
"units": {
107+
"year": {
108+
"one": "שנה",
109+
"two": "שנתיים",
110+
"many": "{0} שנים",
111+
"other": "{0} שנים",
112+
},
113+
"month": {
114+
"one": "חודש",
115+
"two": "חודשיים",
116+
"many": "{0} חודשים",
117+
"other": "{0} חודשים",
118+
},
119+
"week": {
120+
"one": "שבוע",
121+
"two": "שבועיים",
122+
"many": "{0} שבועות",
123+
"other": "{0} שבועות",
124+
},
125+
"day": {
126+
"one": "יום {0}",
127+
"two": "יומיים",
128+
"many": "{0} יום",
129+
"other": "{0} ימים",
130+
},
131+
"hour": {
132+
"one": "שעה",
133+
"two": "שעתיים",
134+
"many": "{0} שעות",
135+
"other": "{0} שעות",
136+
},
137+
"minute": {
138+
"one": "דקה",
139+
"two": "שתי דקות",
140+
"many": "{0} דקות",
141+
"other": "{0} דקות",
142+
},
143+
"second": {
144+
"one": "שניה",
145+
"two": "שתי שניות",
146+
"many": "\u200f{0} שניות",
147+
"other": "{0} שניות",
148+
},
149+
"microsecond": {
150+
"one": "{0} מיליונית שנייה",
151+
"two": "{0} מיליוניות שנייה",
152+
"many": "{0} מיליוניות שנייה",
153+
"other": "{0} מיליוניות שנייה",
154+
},
155+
},
156+
"relative": {
157+
"year": {
158+
"future": {
159+
"other": "בעוד {0} שנים",
160+
"one": "בעוד שנה",
161+
"two": "בעוד שנתיים",
162+
"many": "בעוד {0} שנה",
163+
},
164+
"past": {
165+
"other": "לפני {0} שנים",
166+
"one": "לפני שנה",
167+
"two": "לפני שנתיים",
168+
"many": "לפני {0} שנה",
169+
},
170+
},
171+
"month": {
172+
"future": {
173+
"other": "בעוד {0} חודשים",
174+
"one": "בעוד חודש",
175+
"two": "בעוד חודשיים",
176+
"many": "בעוד {0} חודשים",
177+
},
178+
"past": {
179+
"other": "לפני {0} חודשים",
180+
"one": "לפני חודש",
181+
"two": "לפני חודשיים",
182+
"many": "לפני {0} חודשים",
183+
},
184+
},
185+
"week": {
186+
"future": {
187+
"other": "בעוד {0} שבועות",
188+
"one": "בעוד שבוע",
189+
"two": "בעוד שבועיים",
190+
"many": "בעוד {0} שבועות",
191+
},
192+
"past": {
193+
"other": "לפני {0} שבועות",
194+
"one": "לפני שבוע",
195+
"two": "לפני שבועיים",
196+
"many": "לפני {0} שבועות",
197+
},
198+
},
199+
"day": {
200+
"future": {
201+
"other": "בעוד {0} ימים",
202+
"one": "בעוד יום {0}",
203+
"two": "בעוד יומיים",
204+
"many": "בעוד {0} ימים",
205+
},
206+
"past": {
207+
"other": "לפני {0} ימים",
208+
"one": "לפני יום {0}",
209+
"two": "לפני יומיים",
210+
"many": "לפני {0} ימים",
211+
},
212+
},
213+
"hour": {
214+
"future": {
215+
"other": "בעוד {0} שעות",
216+
"one": "בעוד שעה",
217+
"two": "בעוד שעתיים",
218+
"many": "בעוד {0} שעות",
219+
},
220+
"past": {
221+
"other": "לפני {0} שעות",
222+
"one": "לפני שעה",
223+
"two": "לפני שעתיים",
224+
"many": "לפני {0} שעות",
225+
},
226+
},
227+
"minute": {
228+
"future": {
229+
"other": "בעוד {0} דקות",
230+
"one": "בעוד דקה",
231+
"two": "בעוד שתי דקות",
232+
"many": "בעוד {0} דקות",
233+
},
234+
"past": {
235+
"other": "לפני {0} דקות",
236+
"one": "לפני דקה",
237+
"two": "לפני שתי דקות",
238+
"many": "לפני {0} דקות",
239+
},
240+
},
241+
"second": {
242+
"future": {
243+
"other": "בעוד {0} שניות",
244+
"one": "בעוד שנייה",
245+
"two": "בעוד שתי שניות",
246+
"many": "בעוד {0} שניות",
247+
},
248+
"past": {
249+
"other": "לפני {0} שניות",
250+
"one": "לפני שנייה",
251+
"two": "לפני שתי שניות",
252+
"many": "לפני {0} שניות",
253+
},
254+
},
255+
},
256+
"day_periods": {
257+
"midnight": "חצות",
258+
"am": "לפנה״צ",
259+
"pm": "אחה״צ",
260+
"morning1": "בבוקר",
261+
"afternoon1": "בצהריים",
262+
"afternoon2": "אחר הצהריים",
263+
"evening1": "בערב",
264+
"night1": "בלילה",
265+
"night2": "לפנות בוקר",
266+
},
267+
},
268+
"custom": custom_translations,
269+
}

tests/localization/test_he.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 = "he"
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) == "לפני כמה שניות"
17+
18+
d = pendulum.now().subtract(seconds=2)
19+
assert d.diff_for_humans(locale=locale) == "לפני כמה שניות"
20+
21+
d = pendulum.now().subtract(minutes=1)
22+
assert d.diff_for_humans(locale=locale) == "לפני דקה"
23+
24+
d = pendulum.now().subtract(minutes=2)
25+
assert d.diff_for_humans(locale=locale) == "לפני שתי דקות"
26+
27+
d = pendulum.now().subtract(hours=1)
28+
assert d.diff_for_humans(locale=locale) == "לפני שעה"
29+
30+
d = pendulum.now().subtract(hours=2)
31+
assert d.diff_for_humans(locale=locale) == "לפני שעתיים"
32+
33+
d = pendulum.now().subtract(days=1)
34+
assert d.diff_for_humans(locale=locale) == "לפני יום 1"
35+
36+
d = pendulum.now().subtract(days=2)
37+
assert d.diff_for_humans(locale=locale) == "לפני יומיים"
38+
39+
d = pendulum.now().subtract(weeks=1)
40+
assert d.diff_for_humans(locale=locale) == "לפני שבוע"
41+
42+
d = pendulum.now().subtract(weeks=2)
43+
assert d.diff_for_humans(locale=locale) == "לפני שבועיים"
44+
45+
d = pendulum.now().subtract(months=1)
46+
assert d.diff_for_humans(locale=locale) == "לפני חודש"
47+
48+
d = pendulum.now().subtract(months=2)
49+
assert d.diff_for_humans(locale=locale) == "לפני חודשיים"
50+
51+
d = pendulum.now().subtract(years=1)
52+
assert d.diff_for_humans(locale=locale) == "לפני שנה"
53+
54+
d = pendulum.now().subtract(years=2)
55+
assert d.diff_for_humans(locale=locale) == "לפני שנתיים"
56+
57+
d = pendulum.now().add(seconds=1)
58+
assert d.diff_for_humans(locale=locale) == "תוך כמה שניות"
59+
60+
d = pendulum.now().add(seconds=1)
61+
d2 = pendulum.now()
62+
assert d.diff_for_humans(d2, locale=locale) == "בעוד כמה שניות"
63+
assert d2.diff_for_humans(d, locale=locale) == "כמה שניות קודם"
64+
65+
assert d.diff_for_humans(d2, True, locale=locale) == "כמה שניות"
66+
assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "כמה שניות"

0 commit comments

Comments
 (0)