Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic Russian support #23

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions spec/Coduo/PHPHumanizer/DateTimeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,22 @@ function it_humanizes_precise_difference_between_dates_for_it_locale()
$this->preciseDifference(new \DateTime($example[0]), new \DateTime($example[1]), 'it')->shouldReturn($example[2]);
}
}

function it_humanizes_precise_difference_between_dates_for_ru_locale()
{
$examples = array(
array("2015-02-01 12:00:00", "2015-02-01 10:57:55", '1 час, 2 минуты, 5 секунд назад'),
array("2015-02-01 12:00:00", "2015-02-01 09:54:59", '2 часа, 5 минут, 1 секунда назад'),
array("2015-02-01 12:00:00", "2015-02-01 06:58:58", '5 часов, 1 минута, 2 секунды назад'),
array("2015-02-01 12:00:00", "2015-02-01 14:01:05", 'через 2 часа, 1 минуту, 5 секунд'),
array("2015-02-01 12:00:00", "2014-01-30 07:00:00", '1 год, 2 дня, 5 часов назад'),
array("2015-02-01 12:00:00", "2013-01-27 11:00:00", '2 года, 5 дней, 1 час назад'),
array("2015-02-01 12:00:00", "2010-01-31 10:00:00", '5 лет, 1 день, 2 часа назад'),
array("2015-02-01 12:00:00", "2017-02-06 13:00:00", 'через 2 года, 5 дней, 1 час'),
);

foreach ($examples as $example) {
$this->preciseDifference(new \DateTime($example[0]), new \DateTime($example[1]), 'ru')->shouldReturn($example[2]);
}
}
}
35 changes: 35 additions & 0 deletions src/Coduo/PHPHumanizer/Resources/translations/difference.ru.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
just_now:
past: "только что"
future: "только что"
second:
past: "%count% секунда назад|%count% секунды назад|%count% секунд назад"
future: "через %count% секунду|через %count% секунды|через %count% секунд"
minute:
past: "%count% минута назад|%count% минуты назад|%count% минут назад"
future: "через %count% минуту|через %count% минуты|через %count% минут"
hour:
past: "%count% час назад|%count% часа назад|%count% часов назад"
future: "через %count% час|через %count% часа"
day:
past: "%count% день назад|%count% дня назад|%count% дней назад"
future: "через %count% день|через %count% дня|через %count% дней"
week:
past: "%count% неделя назад|%count% недели назад|%count% недель назад"
future: "через %count% неделю|через %count% недели|через %count% недель"
month:
past: "%count% месяц назад|%count% месяца назад|%count% месяцев назад"
future: "через %count% месяц|через %count% месяца|через %count% месяцев"
year:
past: "%count% год назад|%count% года назад|%count% лет назад"
future: "через %count% год|через %count% года|через %count% лет"

compound:
second: "%count% секунда|%count% секунды|%count% секунд"
minute: "%count% минута|%count% минуты|%count% минут"
hour: "%count% час|%count% часа|%count% часов"
day: "%count% день|%count% дня|%count% дней"
week: "%count% неделя|%count% недели|%count недель"
month: "%count% месяц|%count% месяца|%count% месяцев"
year: "%count% год|%count% года|%count% лет"
ago: "назад"
from_now: "через"