Skip to content

Commit c3f7696

Browse files
author
Sébastien Eustace
committed
Merge branch 'master' of https://github.com/michele-comitini/pendulum into michele-comitini-master
2 parents cc1ed64 + 090ff7a commit c3f7696

File tree

4 files changed

+261
-0
lines changed

4 files changed

+261
-0
lines changed

pendulum/locales/it/__init__.py

Whitespace-only changes.

pendulum/locales/it/custom.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
it custom locale file.
4+
"""
5+
6+
from __future__ import unicode_literals
7+
8+
9+
translations = {
10+
"units": {"few_second": "alcuni secondi"},
11+
# Relative Time
12+
"ago": "{0} fa",
13+
"from_now": "in {0}",
14+
"after": "{0} dopo",
15+
"before": "{0} prima",
16+
# Ordinals
17+
"ordinal": {"other": "°"},
18+
# Date formats
19+
"date_formats": {
20+
"LTS": "H:mm:ss",
21+
"LT": "H:mm",
22+
"L": "DD/MM/YYYY",
23+
"LL": "D MMMM YYYY",
24+
"LLL": "D MMMM YYYY [alle] H:mm",
25+
"LLLL": "dddd, D MMMM YYYY [alle] H:mm",
26+
},
27+
}

pendulum/locales/it/locale.py

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
"""
5+
it 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: "one"
15+
if ((n == n and ((n == 1))) and (0 == 0 and ((0 == 0))))
16+
else "other",
17+
"ordinal": lambda n: "many"
18+
if (n == n and ((n == 11) or (n == 8) or (n == 80) or (n == 800)))
19+
else "other",
20+
"translations": {
21+
"days": {
22+
"abbreviated": {
23+
0: "dom",
24+
1: "lun",
25+
2: "mar",
26+
3: "mer",
27+
4: "gio",
28+
5: "ven",
29+
6: "sab",
30+
},
31+
"narrow": {0: "D", 1: "L", 2: "M", 3: "M", 4: "G", 5: "V", 6: "S"},
32+
"short": {
33+
0: "dom",
34+
1: "lun",
35+
2: "mar",
36+
3: "mer",
37+
4: "gio",
38+
5: "ven",
39+
6: "sab",
40+
},
41+
"wide": {
42+
0: "domenica",
43+
1: "lunedì",
44+
2: "martedì",
45+
3: "mercoledì",
46+
4: "giovedì",
47+
5: "venerdì",
48+
6: "sabato",
49+
},
50+
},
51+
"months": {
52+
"abbreviated": {
53+
1: "gen",
54+
2: "feb",
55+
3: "mar",
56+
4: "apr",
57+
5: "mag",
58+
6: "giu",
59+
7: "lug",
60+
8: "ago",
61+
9: "set",
62+
10: "ott",
63+
11: "nov",
64+
12: "dic",
65+
},
66+
"narrow": {
67+
1: "G",
68+
2: "F",
69+
3: "M",
70+
4: "A",
71+
5: "M",
72+
6: "G",
73+
7: "L",
74+
8: "A",
75+
9: "S",
76+
10: "O",
77+
11: "N",
78+
12: "D",
79+
},
80+
"wide": {
81+
1: "gennaio",
82+
2: "febbraio",
83+
3: "marzo",
84+
4: "aprile",
85+
5: "maggio",
86+
6: "giugno",
87+
7: "luglio",
88+
8: "agosto",
89+
9: "settembre",
90+
10: "ottobre",
91+
11: "novembre",
92+
12: "dicembre",
93+
},
94+
},
95+
"units": {
96+
"year": {"one": "{0} anno", "other": "{0} anni"},
97+
"month": {"one": "{0} mese", "other": "{0} mesi"},
98+
"week": {"one": "{0} settimana", "other": "{0} settimane"},
99+
"day": {"one": "{0} giorno", "other": "{0} giorni"},
100+
"hour": {"one": "{0} ora", "other": "{0} ore"},
101+
"minute": {"one": "{0} minuto", "other": "{0} minuti"},
102+
"second": {"one": "{0} secondo", "other": "{0} secondi"},
103+
"microsecond": {"one": "{0} microsecondo", "other": "{0} microsecondi"},
104+
},
105+
"relative": {
106+
"year": {
107+
"future": {"other": "tra {0} anni", "one": "tra {0} anno"},
108+
"past": {"other": "{0} anni fa", "one": "{0} anno fa"},
109+
},
110+
"month": {
111+
"future": {"other": "tra {0} mesi", "one": "tra {0} mese"},
112+
"past": {"other": "{0} mesi fa", "one": "{0} mese fa"},
113+
},
114+
"week": {
115+
"future": {"other": "tra {0} settimane", "one": "tra {0} settimana"},
116+
"past": {"other": "{0} settimane fa", "one": "{0} settimana fa"},
117+
},
118+
"day": {
119+
"future": {"other": "tra {0} giorni", "one": "tra {0} giorno"},
120+
"past": {"other": "{0} giorni fa", "one": "{0} giorno fa"},
121+
},
122+
"hour": {
123+
"future": {"other": "tra {0} ore", "one": "tra {0} ora"},
124+
"past": {"other": "{0} ore fa", "one": "{0} ora fa"},
125+
},
126+
"minute": {
127+
"future": {"other": "tra {0} minuti", "one": "tra {0} minuto"},
128+
"past": {"other": "{0} minuti fa", "one": "{0} minuto fa"},
129+
},
130+
"second": {
131+
"future": {"other": "tra {0} secondi", "one": "tra {0} secondo"},
132+
"past": {"other": "{0} secondi fa", "one": "{0} secondo fa"},
133+
},
134+
},
135+
"day_periods": {
136+
"midnight": "mezzanotte",
137+
"am": "AM",
138+
"noon": "mezzogiorno",
139+
"pm": "PM",
140+
"morning1": "di mattina",
141+
"afternoon1": "del pomeriggio",
142+
"evening1": "di sera",
143+
"night1": "di notte",
144+
},
145+
},
146+
"custom": custom_translations,
147+
}

tests/localization/test_it.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
import pendulum
5+
6+
7+
locale = "it"
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) == "alcuni secondi fa"
18+
19+
d = pendulum.now().subtract(seconds=2)
20+
assert d.diff_for_humans(locale=locale) == "alcuni secondi fa"
21+
22+
d = pendulum.now().subtract(minutes=1)
23+
assert d.diff_for_humans(locale=locale) == "1 minuto fa"
24+
25+
d = pendulum.now().subtract(minutes=2)
26+
assert d.diff_for_humans(locale=locale) == "2 minuti fa"
27+
28+
d = pendulum.now().subtract(hours=1)
29+
assert d.diff_for_humans(locale=locale) == "1 ora fa"
30+
31+
d = pendulum.now().subtract(hours=2)
32+
assert d.diff_for_humans(locale=locale) == "2 ore fa"
33+
34+
d = pendulum.now().subtract(days=1)
35+
assert d.diff_for_humans(locale=locale) == "1 giorno fa"
36+
37+
d = pendulum.now().subtract(days=2)
38+
assert d.diff_for_humans(locale=locale) == "2 giorni fa"
39+
40+
d = pendulum.now().subtract(weeks=1)
41+
assert d.diff_for_humans(locale=locale) == "1 settimana fa"
42+
43+
d = pendulum.now().subtract(weeks=2)
44+
assert d.diff_for_humans(locale=locale) == "2 settimane fa"
45+
46+
d = pendulum.now().subtract(months=1)
47+
assert d.diff_for_humans(locale=locale) == "1 mese fa"
48+
49+
d = pendulum.now().subtract(months=2)
50+
assert d.diff_for_humans(locale=locale) == "2 mesi fa"
51+
52+
d = pendulum.now().subtract(years=1)
53+
assert d.diff_for_humans(locale=locale) == "1 anno fa"
54+
55+
d = pendulum.now().subtract(years=2)
56+
assert d.diff_for_humans(locale=locale) == "2 anni fa"
57+
58+
d = pendulum.now().add(seconds=1)
59+
assert d.diff_for_humans(locale=locale) == "in alcuni secondi"
60+
61+
d = pendulum.now().add(seconds=1)
62+
d2 = pendulum.now()
63+
assert d.diff_for_humans(d2, locale=locale) == "alcuni secondi dopo"
64+
assert d2.diff_for_humans(d, locale=locale) == "alcuni secondi prima"
65+
66+
assert d.diff_for_humans(d2, True, locale=locale) == "alcuni secondi"
67+
assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "alcuni secondi"
68+
69+
70+
def test_format():
71+
d = pendulum.datetime(2016, 8, 28, 7, 3, 6, 123456)
72+
assert d.format("dddd", locale=locale) == "domenica"
73+
assert d.format("ddd", locale=locale) == "dom"
74+
assert d.format("MMMM", locale=locale) == "agosto"
75+
assert d.format("MMM", locale=locale) == "ago"
76+
assert d.format("A", locale=locale) == "AM"
77+
78+
assert d.format("LT", locale=locale) == "7:03"
79+
assert d.format("LTS", locale=locale) == "7:03:06"
80+
assert d.format("L", locale=locale) == "28/08/2016"
81+
assert d.format("LL", locale=locale) == "28 agosto 2016"
82+
assert d.format("LLL", locale=locale) == "28 agosto 2016 alle 7:03"
83+
assert d.format("LLLL", locale=locale) == "domenica, 28 agosto 2016 alle 7:03"
84+
85+
assert d.format("Do", locale=locale) == "28°"
86+
d = pendulum.datetime(2019, 1, 1, 7, 3, 6, 123456)
87+
assert d.format("Do", locale=locale) == "1°"

0 commit comments

Comments
 (0)