Skip to content

Commit 150a794

Browse files
serimanorberttech
authored andcommitted
Support Japanese language (coduo#85)
* Add difference.ja.yml * Add oxford.ja.yml * Add Japanese language test cases * Update README.md * Delete trailing space
1 parent 4f83a62 commit 150a794

File tree

5 files changed

+76
-1
lines changed

5 files changed

+76
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ Currently we support following languages:
240240
* [Ukrainian] (src/Coduo/PHPHumanizer/Resources/translations/difference.uk.yml)
241241
* [Danish] (src/Coduo/PHPHumanizer/Resources/translations/difference.da.yml)
242242
* [Thai] (src/Coduo/PHPHumanizer/Resources/translations/difference.th.yml)
243+
* [Japanese] (src/Coduo/PHPHumanizer/Resources/translations/difference.ja.yml)
243244

244245
# Credits
245246

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
just_now:
2+
past: "[0,Inf] たった今"
3+
future: "[0,Inf] たった今"
4+
second:
5+
past: "{1} %count% 秒前|[2,Inf] %count% 秒前"
6+
future: "{1} %count% 秒後|[2,Inf] %count% 秒後"
7+
minute:
8+
past: "{1} %count% 分前|[2,Inf] %count% 分前"
9+
future: "{1} %count% 分後|[2,Inf] %count% 分後"
10+
hour:
11+
past: "{1} %count% 時間前|[2,Inf] %count% 時間前"
12+
future: "{1} %count% 時間後|[2,Inf] %count% 時間後"
13+
day:
14+
past: "{1} %count% 日前|[2,Inf] %count% 日前"
15+
future: "{1} %count% 日後|[2,Inf] %count% 日後"
16+
week:
17+
past: "{1} %count% 週間前|[2,Inf] %count% 週間前"
18+
future: "{1} %count% 週間後|[2,Inf] %count% 週間後"
19+
month:
20+
past: "{1} %count% ヶ月前|[2,Inf] %count% ヶ月前"
21+
future: "{1} %count% ヶ月後|[2,Inf] %count% ヶ月後"
22+
year:
23+
past: "{1} %count% 年前|[2,Inf] %count% 年前"
24+
future: "{1} %count% 年後|[2,Inf] %count% 年後"
25+
26+
compound:
27+
second: "{1} %count% 秒|[2,Inf] %count% 秒"
28+
minute: "{1} %count% 分|[2,Inf] %count% 分"
29+
hour: "{1} %count% 時間|[2,Inf] %count% 時間"
30+
day: "{1} %count% 日|[2,Inf] %count% 日"
31+
week: "{1} %count% 週間|[2,Inf] %count% 週間"
32+
month: "{1} %count% 月|[2,Inf] %count% 月"
33+
year: "{1} %count% 年|[2,Inf] %count% 年"
34+
past: "%value%前"
35+
future: "%value%後"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
only_two: "%first% と %second%"
2+
comma_separated: "%list% と %last%"
3+
comma_separated_with_limit: "{1} %list% ともうひとり|[2,Inf] %list% ともう %count% 人"

tests/Coduo/PHPHumanizer/Tests/CollectionHumanizerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public function oxfordCollectionProvider()
7171
array(array("Michal", "Norbert", "Lukasz"), 2, 'th', 'Michal, Norbert และอีก 1'),
7272
array(array("Michal", "Norbert", "Lukasz", "Pawel"), 2, 'th', 'Michal, Norbert และอีก 2'),
7373
array(array("Michal", "Norbert", "Lukasz", "Pawel"), null, 'th', 'Michal, Norbert, Lukasz และ Pawel'),
74+
75+
// Japanese
76+
array(array("Michal"), null, 'ja', 'Michal'),
77+
array(array("Michal", "Norbert"), null, 'ja', 'Michal と Norbert'),
78+
array(array("Michal", "Norbert", "Lukasz"), 2, 'ja', 'Michal, Norbert ともうひとり'),
79+
array(array("Michal", "Norbert", "Lukasz", "Pawel"), 2, 'ja', 'Michal, Norbert ともう 2 人'),
80+
array(array("Michal", "Norbert", "Lukasz", "Pawel"), null, 'ja', 'Michal, Norbert, Lukasz と Pawel'),
7481
);
7582
}
7683
}

tests/Coduo/PHPHumanizer/Tests/DateTimeHumanizerTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function humanizeDataProvider()
156156
array("2014-05-01", "2014-04-01", '1 bulan yang lalu', 'id'),
157157
array("2015-05-01", "2014-04-01", '1 tahun yang lalu', 'id'),
158158
array("2014-05-01", "2016-04-01", '2 tahun dari sekarang', 'id'),
159-
159+
160160
// Spanish
161161
array("2014-04-26 13:00:00", "2014-04-26 13:00:00", 'ahora mismo', 'es'),
162162
array("2014-04-26 13:00:00", "2014-04-26 13:00:05", 'dentro de 5 segundos', 'es'),
@@ -232,6 +232,25 @@ public function humanizeDataProvider()
232232
array("2014-05-01", "2014-04-01", '1 เดือนที่แล้ว', 'th'),
233233
array("2015-05-01", "2014-04-01", '1 ปีที่แล้ว', 'th'),
234234
array("2014-05-01", "2016-04-01", 'อีก 2 ปี', 'th'),
235+
236+
// Japanese
237+
array("2014-04-26 13:00:00", "2014-04-26 13:00:00", 'たった今', 'ja'),
238+
array("2014-04-26 13:00:00", "2014-04-26 13:00:05", '5 秒後', 'ja'),
239+
array("2014-04-26 13:00:00", "2014-04-26 12:59:00", '1 分前', 'ja'),
240+
array("2014-04-26 13:00:00", "2014-04-26 12:45:00", '15 分前', 'ja'),
241+
array("2014-04-26 13:00:00", "2014-04-26 13:15:00", '15 分後', 'ja'),
242+
array("2014-04-26 13:00:00", "2014-04-26 14:00:00", '1 時間後', 'ja'),
243+
array("2014-04-26 13:00:00", "2014-04-26 15:00:00", '2 時間後', 'ja'),
244+
array("2014-04-26 13:00:00", "2014-04-26 12:00:00", '1 時間前', 'ja'),
245+
array("2014-04-26", "2014-04-25", '1 日前', 'ja'),
246+
array("2014-04-26", "2014-04-24", '2 日前', 'ja'),
247+
array("2014-04-26", "2014-04-28", '2 日後', 'ja'),
248+
array("2014-04-01", "2014-04-15", '2 週間後', 'ja'),
249+
array("2014-04-15", "2014-04-07", '1 週間前', 'ja'),
250+
array("2014-01-01", "2014-04-01", '3 ヶ月後', 'ja'),
251+
array("2014-05-01", "2014-04-01", '1 ヶ月前', 'ja'),
252+
array("2015-05-01", "2014-04-01", '1 年前', 'ja'),
253+
array("2014-05-01", "2016-04-01", '2 年後', 'ja'),
235254
);
236255
}
237256

@@ -410,6 +429,16 @@ public function preciseDifferenceDataProvider()
410429
array("2014-04-26 13:00:00", "2014-04-28 23:00:00", 'อีก 2 วัน, 10 ชั่วโมง', 'th'),
411430
array("2014-04-26 13:00:00", "2014-04-25 11:20:00", '1 วัน, 1 ชั่วโมง, 40 นาทีที่แล้ว', 'th'),
412431
array("2014-04-26 13:00:00", "2016-04-27 13:00:00", 'อีก 2 ปี, 1 วัน', 'th'),
432+
433+
// Japanese
434+
array("2014-04-26 13:00:00", "2014-04-26 12:58:15", '1 分, 45 秒前', 'ja'),
435+
array("2014-04-26 13:00:00", "2014-04-26 11:20:00", '1 時間, 40 分前', 'ja'),
436+
array("2014-04-26 13:00:00", "2014-04-27 13:15:00", '1 日, 15 分後', 'ja'),
437+
array("2014-04-26 13:00:00", "2014-05-03 15:00:00", '7 日, 2 時間後', 'ja'),
438+
array("2014-04-26 13:00:00", "2015-04-28 17:00:00", '1 年, 2 日, 4 時間後', 'ja'),
439+
array("2014-04-26 13:00:00", "2014-04-28 23:00:00", '2 日, 10 時間後', 'ja'),
440+
array("2014-04-26 13:00:00", "2014-04-25 11:20:00", '1 日, 1 時間, 40 分前', 'ja'),
441+
array("2014-04-26 13:00:00", "2016-04-27 13:00:00", '2 年, 1 日後', 'ja'),
413442
);
414443
}
415444
}

0 commit comments

Comments
 (0)