Skip to content

Commit ca589aa

Browse files
zaSecruspre-commit-ci[bot]
authored
Added JA translation (#610)
* Initiate JA translation * Initiate JA test code * Update custom.py * Update assert in the test code * Reformat locale.py using black * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Bartosz Sokorski <b.sokorski@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 262c1e0 commit ca589aa

File tree

4 files changed

+284
-0
lines changed

4 files changed

+284
-0
lines changed

pendulum/locales/ja/__init__.py

Whitespace-only changes.

pendulum/locales/ja/custom.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
ja custom locale file.
3+
"""
4+
5+
translations = {
6+
"units": {"few_second": "数秒"},
7+
# Relative time
8+
"ago": "{} 前に",
9+
"from_now": "今から {}",
10+
"after": "{0} 後",
11+
"before": "{0} 前",
12+
# Date formats
13+
"date_formats": {
14+
"LTS": "h:mm:ss A",
15+
"LT": "h:mm A",
16+
"L": "MM/DD/YYYY",
17+
"LL": "MMMM D, YYYY",
18+
"LLL": "MMMM D, YYYY h:mm A",
19+
"LLLL": "dddd, MMMM D, YYYY h:mm A",
20+
},
21+
}

pendulum/locales/ja/locale.py

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
from .custom import translations as custom_translations
2+
3+
4+
"""
5+
ja locale file.
6+
7+
It has been generated automatically and must not be modified directly.
8+
"""
9+
10+
11+
locale = {
12+
"plural": lambda n: "other",
13+
"ordinal": lambda n: "other",
14+
"translations": {
15+
"days": {
16+
"abbreviated": {
17+
0: "日",
18+
1: "月",
19+
2: "火",
20+
3: "水",
21+
4: "木",
22+
5: "金",
23+
6: "土",
24+
},
25+
"narrow": {
26+
0: "日",
27+
1: "月",
28+
2: "火",
29+
3: "水",
30+
4: "木",
31+
5: "金",
32+
6: "土",
33+
},
34+
"short": {
35+
0: "日",
36+
1: "月",
37+
2: "火",
38+
3: "水",
39+
4: "木",
40+
5: "金",
41+
6: "土",
42+
},
43+
"wide": {
44+
0: "日曜日",
45+
1: "月曜日",
46+
2: "火曜日",
47+
3: "水曜日",
48+
4: "木曜日",
49+
5: "金曜日",
50+
6: "土曜日",
51+
},
52+
},
53+
"months": {
54+
"abbreviated": {
55+
1: "1月",
56+
2: "2月",
57+
3: "3月",
58+
4: "4月",
59+
5: "5月",
60+
6: "6月",
61+
7: "7月",
62+
8: "8月",
63+
9: "9月",
64+
10: "10月",
65+
11: "11月",
66+
12: "12月",
67+
},
68+
"narrow": {
69+
1: "1",
70+
2: "2",
71+
3: "3",
72+
4: "4",
73+
5: "5",
74+
6: "6",
75+
7: "7",
76+
8: "8",
77+
9: "9",
78+
10: "10",
79+
11: "11",
80+
12: "12",
81+
},
82+
"wide": {
83+
1: "1月",
84+
2: "2月",
85+
3: "3月",
86+
4: "4月",
87+
5: "5月",
88+
6: "6月",
89+
7: "7月",
90+
8: "8月",
91+
9: "9月",
92+
10: "10月",
93+
11: "11月",
94+
12: "12月",
95+
},
96+
},
97+
"units": {
98+
"year": {
99+
"other": "{0} 年",
100+
},
101+
"month": {
102+
"other": "{0} か月",
103+
},
104+
"week": {
105+
"other": "{0} 週間",
106+
},
107+
"day": {
108+
"other": "{0} 日",
109+
},
110+
"hour": {
111+
"other": "{0} 時間",
112+
},
113+
"minute": {
114+
"other": "{0} 分",
115+
},
116+
"second": {
117+
"other": "{0} 秒",
118+
},
119+
"microsecond": {
120+
"other": "{0} マイクロ秒",
121+
},
122+
},
123+
"relative": {
124+
"year": {
125+
"future": {
126+
"other": "{0} 年後",
127+
},
128+
"past": {
129+
"other": "{0} 年前",
130+
},
131+
},
132+
"month": {
133+
"future": {
134+
"other": "{0} か月後",
135+
},
136+
"past": {
137+
"other": "{0} か月前",
138+
},
139+
},
140+
"week": {
141+
"future": {
142+
"other": "{0} 週間後",
143+
},
144+
"past": {
145+
"other": "{0} 週間前",
146+
},
147+
},
148+
"day": {
149+
"future": {
150+
"other": "{0} 日後",
151+
},
152+
"past": {
153+
"other": "{0} 日前",
154+
},
155+
},
156+
"hour": {
157+
"future": {
158+
"other": "{0} 時間後",
159+
},
160+
"past": {
161+
"other": "{0} 時間前",
162+
},
163+
},
164+
"minute": {
165+
"future": {
166+
"other": "{0} 分後",
167+
},
168+
"past": {
169+
"other": "{0} 分前",
170+
},
171+
},
172+
"second": {
173+
"future": {
174+
"other": "{0} 秒後",
175+
},
176+
"past": {
177+
"other": "{0} 秒前",
178+
},
179+
},
180+
},
181+
"day_periods": {
182+
"midnight": "真夜中",
183+
"am": "午前",
184+
"noon": "正午",
185+
"pm": "午後",
186+
"morning1": "朝",
187+
"afternoon1": "昼",
188+
"evening1": "夕方",
189+
"night1": "夜",
190+
"night2": "夜中",
191+
},
192+
},
193+
"custom": custom_translations,
194+
}

tests/localization/test_ja.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from __future__ import annotations
2+
3+
import pendulum
4+
5+
6+
locale = "ja"
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(seconds=21)
22+
assert d.diff_for_humans(locale=locale) == "21 秒前"
23+
24+
d = pendulum.now().subtract(minutes=1)
25+
assert d.diff_for_humans(locale=locale) == "1 分前"
26+
27+
d = pendulum.now().subtract(minutes=2)
28+
assert d.diff_for_humans(locale=locale) == "2 分前"
29+
30+
d = pendulum.now().subtract(hours=1)
31+
assert d.diff_for_humans(locale=locale) == "1 時間前"
32+
33+
d = pendulum.now().subtract(hours=2)
34+
assert d.diff_for_humans(locale=locale) == "2 時間前"
35+
36+
d = pendulum.now().subtract(days=1)
37+
assert d.diff_for_humans(locale=locale) == "1 日前"
38+
39+
d = pendulum.now().subtract(days=2)
40+
assert d.diff_for_humans(locale=locale) == "2 日前"
41+
42+
d = pendulum.now().subtract(weeks=1)
43+
assert d.diff_for_humans(locale=locale) == "1 週間前"
44+
45+
d = pendulum.now().subtract(weeks=2)
46+
assert d.diff_for_humans(locale=locale) == "2 週間前"
47+
48+
d = pendulum.now().subtract(months=1)
49+
assert d.diff_for_humans(locale=locale) == "1 か月前"
50+
51+
d = pendulum.now().subtract(months=2)
52+
assert d.diff_for_humans(locale=locale) == "2 か月前"
53+
54+
d = pendulum.now().subtract(years=1)
55+
assert d.diff_for_humans(locale=locale) == "1 年前"
56+
57+
d = pendulum.now().subtract(years=2)
58+
assert d.diff_for_humans(locale=locale) == "2 年前"
59+
60+
d = pendulum.now().add(seconds=1)
61+
assert d.diff_for_humans(locale=locale) == "今から 数秒"
62+
63+
d = pendulum.now().add(seconds=1)
64+
d2 = pendulum.now()
65+
assert d.diff_for_humans(d2, locale=locale) == "数秒 後"
66+
assert d2.diff_for_humans(d, locale=locale) == "数秒 前"
67+
68+
assert d.diff_for_humans(d2, True, locale=locale) == "数秒"
69+
assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "数秒"

0 commit comments

Comments
 (0)