-
Notifications
You must be signed in to change notification settings - Fork 107
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 russian. Add prefix at format difference. #41
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5d328c5
Add russian. Add prefix at format difference.
sam002 9c6bf24
russian in readme
sam002 06b0735
Added spec for PreciseFormatter.
juanramirez 294457a
Merge pull request #1 from juanramirez/precise-formatter-spec
sam002 f789ab6
Merge branch 'master' of https://github.com/coduo/php-humanizer. Past…
sam002 9104ef0
Past/future compound formater for prefix precise. Rename: ago->past a…
sam002 212711d
Fix compound.future for pt_BR. Inline key in PreciseFormatter.
sam002 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace spec\Coduo\PHPHumanizer\DateTime; | ||
|
||
use Coduo\PHPHumanizer\DateTime\PreciseDifference; | ||
use Coduo\PHPHumanizer\DateTime\Difference\CompoundResult; | ||
use Coduo\PHPHumanizer\DateTime\Unit\Day; | ||
use Coduo\PHPHumanizer\DateTime\Unit\Hour; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Symfony\Component\Translation\Translator; | ||
|
||
class PreciseFormatterSpec extends ObjectBehavior | ||
{ | ||
function let(Translator $translator) | ||
{ | ||
$this->beConstructedWith($translator); | ||
$translator->transChoice( | ||
'compound.day', | ||
10, | ||
array('%count%' => 10), | ||
'difference', | ||
'en' | ||
)->willReturn('10 days'); | ||
|
||
$translator->transChoice( | ||
'compound.hour', | ||
5, | ||
array('%count%' => 5), | ||
'difference', | ||
'en' | ||
)->willReturn('5 hours'); | ||
|
||
$translator->trans( | ||
'compound.future', | ||
array('%value%' => '10 days, 5 hours'), | ||
'difference', | ||
'en' | ||
)->willReturn('10 days, 5 hours from now'); | ||
|
||
$translator->transChoice( | ||
'compound.day', | ||
10, | ||
array('%count%' => 10), | ||
'difference', | ||
'ru' | ||
)->willReturn('10 дней'); | ||
|
||
$translator->transChoice( | ||
'compound.hour', | ||
5, | ||
array('%count%' => 5), | ||
'difference', | ||
'ru' | ||
)->willReturn('5 часов'); | ||
|
||
$translator->trans( | ||
'compound.future', | ||
array('%value%' => '10 дней, 5 часов'), | ||
'difference', | ||
'ru' | ||
)->willReturn('через 10 дней, 5 часов'); | ||
} | ||
|
||
function it_format_compound_datetime_diff(PreciseDifference $diff, CompoundResult $dayResult, | ||
CompoundResult $hourResult) | ||
{ | ||
$dayResult->getUnit()->willReturn(new Day()); | ||
$dayResult->getQuantity()->willReturn(10); | ||
$hourResult->getUnit()->willReturn(new Hour()); | ||
$hourResult->getQuantity()->willReturn(5); | ||
|
||
$diff->getCompoundResults()->willReturn(array($dayResult, $hourResult)); | ||
$diff->isPast()->willReturn(false); | ||
$this->formatDifference($diff)->shouldReturn('10 days, 5 hours from now'); | ||
} | ||
|
||
function it_format_compound_datetime_diff_for_specific_locale(PreciseDifference $diff, | ||
CompoundResult $dayResult, CompoundResult $hourResult) | ||
{ | ||
$dayResult->getUnit()->willReturn(new Day()); | ||
$dayResult->getQuantity()->willReturn(10); | ||
$hourResult->getUnit()->willReturn(new Hour()); | ||
$hourResult->getQuantity()->willReturn(5); | ||
|
||
$diff->getCompoundResults()->willReturn(array($dayResult, $hourResult)); | ||
$diff->isPast()->willReturn(false); | ||
$this->formatDifference($diff, 'ru')->shouldReturn('через 10 дней, 5 часов'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,5 @@ compound: | |
week: "{1} %count% semana|[2,Inf] %count% semana" | ||
month: "{1} %count% mês|[2,Inf] %count% meses" | ||
year: "{1} %count% ano|[2,Inf] %count% anos" | ||
ago: "atrás" | ||
past: "%value% atrás" | ||
from_now: "a partir de agora" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. future is missing here. |
35 changes: 35 additions & 0 deletions
35
src/Coduo/PHPHumanizer/Resources/translations/difference.ru.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
just_now: | ||
past: "[0,Inf] сейчас" | ||
future: "[0,Inf] сейчас" | ||
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% часа|через %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% лет" | ||
past: "%value% назад" | ||
future: "через %value%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
only_two: "%first% и %second%" | ||
comma_separated: "%list% и %last%" | ||
comma_separated_with_limit: "{1} %list% и ещё 1|[2,Inf] %list% и ещё %count%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for
$translationKey
,'compound.' . $difference->isPast() ? 'past' : 'future'
its enoguh