Skip to content

Commit fb6fc72

Browse files
kangfendsdispater
authored andcommitted
Add 'id' localization (#359)
1 parent 2781f24 commit fb6fc72

File tree

4 files changed

+235
-0
lines changed

4 files changed

+235
-0
lines changed

pendulum/locales/id/__init__.py

Whitespace-only changes.

pendulum/locales/id/custom.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
"""
5+
id custom locale file.
6+
"""
7+
8+
translations = {
9+
"units": {"few_second": "beberapa detik"},
10+
"ago": "{} yang lalu",
11+
"from_now": "dalam {}",
12+
"after": "{0} kemudian",
13+
"before": "{0} yang lalu",
14+
"date_formats": {
15+
"LTS": "HH:mm:ss",
16+
"LT": "HH:mm",
17+
"LLLL": "dddd [d.] D. MMMM YYYY HH:mm",
18+
"LLL": "D. MMMM YYYY HH:mm",
19+
"LL": "D. MMMM YYYY",
20+
"L": "DD/MM/YYYY",
21+
},
22+
}

pendulum/locales/id/locale.py

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
"""
5+
id locale file.
6+
7+
It has been generated automatically and must not be modified directly.
8+
"""
9+
10+
from .custom import translations as custom_translations
11+
12+
13+
locale = {
14+
"plural": lambda n: "other",
15+
"ordinal": lambda n: "other",
16+
"translations": {
17+
"days": {
18+
"abbreviated": {
19+
0: "Min",
20+
1: "Sen",
21+
2: "Sel",
22+
3: "Rab",
23+
4: "Kam",
24+
5: "Jum",
25+
6: "Sab",
26+
},
27+
"narrow": {0: "M", 1: "S", 2: "S", 3: "R", 4: "K", 5: "J", 6: "S"},
28+
"short": {
29+
0: "Min",
30+
1: "Sen",
31+
2: "Sel",
32+
3: "Rab",
33+
4: "Kam",
34+
5: "Jum",
35+
6: "Sab",
36+
},
37+
"wide": {
38+
0: "Minggu",
39+
1: "Senin",
40+
2: "Selasa",
41+
3: "Rabu",
42+
4: "Kamis",
43+
5: "Jumat",
44+
6: "Sabtu",
45+
},
46+
},
47+
"months": {
48+
"abbreviated": {
49+
1: "Jan",
50+
2: "Feb",
51+
3: "Mar",
52+
4: "Apr",
53+
5: "Mei",
54+
6: "Jun",
55+
7: "Jul",
56+
8: "Agt",
57+
9: "Sep",
58+
10: "Okt",
59+
11: "Nov",
60+
12: "Des",
61+
},
62+
"narrow": {
63+
1: "J",
64+
2: "F",
65+
3: "M",
66+
4: "A",
67+
5: "M",
68+
6: "J",
69+
7: "J",
70+
8: "A",
71+
9: "S",
72+
10: "O",
73+
11: "N",
74+
12: "D",
75+
},
76+
"wide": {
77+
1: "Januari",
78+
2: "Februari",
79+
3: "Maret",
80+
4: "April",
81+
5: "Mei",
82+
6: "Juni",
83+
7: "Juli",
84+
8: "Agustus",
85+
9: "September",
86+
10: "Oktober",
87+
11: "November",
88+
12: "Desember",
89+
},
90+
},
91+
"units": {
92+
"year": {"other": "{0} tahun"},
93+
"month": {"other": "{0} bulan"},
94+
"week": {"other": "{0} minggu"},
95+
"day": {"other": "{0} hari"},
96+
"hour": {"other": "{0} jam"},
97+
"minute": {"other": "{0} menit"},
98+
"second": {"other": "{0} detik"},
99+
"microsecond": {"other": "{0} mikrodetik"},
100+
},
101+
"relative": {
102+
"year": {
103+
"future": {"other": "dalam {0} tahun"},
104+
"past": {"other": "{0} tahun yang lalu"},
105+
},
106+
"month": {
107+
"future": {"other": "dalam {0} bulan"},
108+
"past": {"other": "{0} bulan yang lalu"},
109+
},
110+
"week": {
111+
"future": {"other": "dalam {0} minggu"},
112+
"past": {"other": "{0} minggu yang lalu"},
113+
},
114+
"day": {
115+
"future": {"other": "dalam {0} hari"},
116+
"past": {"other": "{0} hari yang lalu"},
117+
},
118+
"hour": {
119+
"future": {"other": "dalam {0} jam"},
120+
"past": {"other": "{0} jam yang lalu"},
121+
},
122+
"minute": {
123+
"future": {"other": "dalam {0} menit"},
124+
"past": {"other": "{0} menit yang lalu"},
125+
},
126+
"second": {
127+
"future": {"other": "dalam {0} detik"},
128+
"past": {"other": "{0} detik yang lalu"},
129+
},
130+
},
131+
"day_periods": {
132+
"midnight": "tengah malam",
133+
"am": "AM",
134+
"noon": "tengah hari",
135+
"pm": "PM",
136+
"morning1": "pagi",
137+
"afternoon1": "siang",
138+
"evening1": "sore",
139+
"night1": "malam",
140+
},
141+
},
142+
"custom": custom_translations,
143+
}

tests/localization/test_id.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
import pendulum
5+
6+
7+
locale = "id"
8+
9+
10+
def test_diff_for_humans():
11+
with pendulum.test(pendulum.datetime(2016, 8, 29)):
12+
diff_for_humans()
13+
14+
15+
def diff_for_humans():
16+
d = pendulum.now().subtract(seconds=1)
17+
assert d.diff_for_humans(locale=locale) == "beberapa detik yang lalu"
18+
19+
d = pendulum.now().subtract(seconds=2)
20+
assert d.diff_for_humans(locale=locale) == "beberapa detik yang lalu"
21+
22+
d = pendulum.now().subtract(seconds=21)
23+
assert d.diff_for_humans(locale=locale) == "21 detik yang lalu"
24+
25+
d = pendulum.now().subtract(minutes=1)
26+
assert d.diff_for_humans(locale=locale) == "1 menit yang lalu"
27+
28+
d = pendulum.now().subtract(minutes=2)
29+
assert d.diff_for_humans(locale=locale) == "2 menit yang lalu"
30+
31+
d = pendulum.now().subtract(hours=1)
32+
assert d.diff_for_humans(locale=locale) == "1 jam yang lalu"
33+
34+
d = pendulum.now().subtract(hours=2)
35+
assert d.diff_for_humans(locale=locale) == "2 jam yang lalu"
36+
37+
d = pendulum.now().subtract(days=1)
38+
assert d.diff_for_humans(locale=locale) == "1 hari yang lalu"
39+
40+
d = pendulum.now().subtract(days=2)
41+
assert d.diff_for_humans(locale=locale) == "2 hari yang lalu"
42+
43+
d = pendulum.now().subtract(weeks=1)
44+
assert d.diff_for_humans(locale=locale) == "1 minggu yang lalu"
45+
46+
d = pendulum.now().subtract(weeks=2)
47+
assert d.diff_for_humans(locale=locale) == "2 minggu yang lalu"
48+
49+
d = pendulum.now().subtract(months=1)
50+
assert d.diff_for_humans(locale=locale) == "1 bulan yang lalu"
51+
52+
d = pendulum.now().subtract(months=2)
53+
assert d.diff_for_humans(locale=locale) == "2 bulan yang lalu"
54+
55+
d = pendulum.now().subtract(years=1)
56+
assert d.diff_for_humans(locale=locale) == "1 tahun yang lalu"
57+
58+
d = pendulum.now().subtract(years=2)
59+
assert d.diff_for_humans(locale=locale) == "2 tahun yang lalu"
60+
61+
d = pendulum.now().add(seconds=1)
62+
assert d.diff_for_humans(locale=locale) == "dalam beberapa detik"
63+
64+
d = pendulum.now().add(seconds=1)
65+
d2 = pendulum.now()
66+
assert d.diff_for_humans(d2, locale=locale) == "beberapa detik kemudian"
67+
assert d2.diff_for_humans(d, locale=locale) == "beberapa detik yang lalu"
68+
69+
assert d.diff_for_humans(d2, True, locale=locale) == "beberapa detik"
70+
assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "beberapa detik"

0 commit comments

Comments
 (0)