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

Addition of Afrikaans (af) language translation (with spec tests) #28

Merged
merged 5 commits into from
Oct 29, 2015
Merged
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
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#A quick guide to contribute to the project:

##Installing the dev environment

1. Fork the repo
2. Clone the repo to local
3. Install dependencies: `composer install` (this assumes you have 'composer' aliased to whereever your composer.phar lives)
4. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate:
`./bin/phpspec run --format=pretty`

##The actual contribution

1. Make the changes/additions to the code, committing often and making clear what you've done
2. Make sure you write tests for your code, located in the folder structure `spec/Coduo/PHPHumanizer/...`
3. Run your tests (often and while coding): `./bin/phpspec run --format=pretty`

##Coding Standards

Try use similar coding standards to what you see in the project to keep things clear to the contributors. If you're unsure, it's always a safe bet to fall-back to the PSR standards.

[PSR-1: Basic Coding Standard](http://www.php-fig.org/psr/psr-1/)

[PSR-2: Coding Style Guide](http://www.php-fig.org/psr/psr-2/)
48 changes: 48 additions & 0 deletions spec/Coduo/PHPHumanizer/DateTimeSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,36 @@ function it_humanize_difference_between_dates_for_pl_locale()
}
}

function it_humanize_difference_between_dates_for_af_locale()
{
$examples = array(
array("2014-04-26 13:00:00", "2014-04-26 13:00:00", 'nou nou'),
array("2014-04-26 13:00:00", "2014-04-26 13:00:05", '5 sekondes van nou af'),
array("2014-04-26 13:00:00", "2014-04-26 12:59:00", '1 minuut gelede'),
array("2014-04-26 13:00:00", "2014-04-26 12:45:00", '15 minute gelede'),
array("2014-04-26 13:00:00", "2014-04-26 13:15:00", '15 minute van nou af'),
array("2014-04-26 13:00:00", "2014-04-26 14:00:00", '1 uur van nou af'),
array("2014-04-26 13:00:00", "2014-04-26 15:00:00", '2 ure van nou af'),
array("2014-04-26 13:00:00", "2014-04-26 12:00:00", '1 uur gelede'),
array("2014-04-26 13:00:00", "2014-04-26 11:00:00", '2 ure gelede'),
array("2014-04-26 13:00:00", "2014-04-26 12:00:00", '1 uur gelede'),
array("2014-04-26", "2014-04-25", '1 dag gelede'),
array("2014-04-26", "2014-04-24", '2 dae gelede'),
array("2014-04-26", "2014-04-28", '2 dae van nou af'),
array("2014-04-01", "2014-04-15", '2 weke van nou af'),
array("2014-04-15", "2014-04-07", '1 week gelede'),
array("2014-01-01", "2014-04-01", '3 maande van nou af'),
array("2014-05-01", "2014-04-01", '1 maand gelede'),
array("2015-05-01", "2014-04-01", '1 jaar gelede'),
array("2014-05-01", "2016-04-01", '2 jaar van nou af'),
array("2014-05-01", "2009-04-01", '5 jaar gelede'),
);

foreach ($examples as $example) {
$this->difference(new \DateTime($example[0]), new \DateTime($example[1]), 'af')->shouldReturn($example[2]);
}
}

function it_humanizes_precise_difference_between_dates()
{
$examples = array(
Expand Down Expand Up @@ -100,6 +130,24 @@ function it_humanizes_precise_difference_between_dates_for_pl_locale()
}
}

function it_humanizes_precise_difference_between_dates_for_af_locale()
{
$examples = array(
array("2014-04-26 13:00:00", "2014-04-26 12:58:15", '1 minuut, 45 sekondes gelede'),
array("2014-04-26 13:00:00", "2014-04-26 11:20:00", '1 uur, 40 minute gelede'),
array("2014-04-26 13:00:00", "2014-04-27 13:15:00", '1 dag, 15 minute van nou af'),
array("2014-04-26 13:00:00", "2014-05-03 15:00:00", '7 dae, 2 ure van nou af'),
array("2014-04-26 13:00:00", "2015-04-28 17:00:00", '1 jaar, 2 dae, 4 ure van nou af'),
array("2014-04-26 13:00:00", "2014-04-28 23:00:00", '2 dae, 10 ure van nou af'),
array("2014-04-26 13:00:00", "2014-04-25 11:20:00", '1 dag, 1 uur, 40 minute gelede'),
array("2014-04-26 13:00:00", "2016-04-27 13:00:00", '2 jaar, 1 dag van nou af'),
);

foreach ($examples as $example) {
$this->preciseDifference(new \DateTime($example[0]), new \DateTime($example[1]), 'af')->shouldReturn($example[2]);
}
}

function it_humanizes_precise_difference_between_dates_for_de_locale()
{
$examples = array(
Expand Down
35 changes: 35 additions & 0 deletions src/Coduo/PHPHumanizer/Resources/translations/difference.af.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
just_now:
past: "[0,Inf] nou nou"
future: "[0,Inf] netnou"
second:
past: "{1} %count% sekonde gelede|[2,Inf] %count% sekondes gelede"
future: "{1} %count% sekonde van nou af|[2,Inf] %count% sekondes van nou af"
minute:
past: "{1} %count% minuut gelede|[2,Inf] %count% minute gelede"
future: "{1} %count% minuut van nou af|[2,Inf] %count% minute van nou af"
hour:
past: "{1} %count% uur gelede|[2,Inf] %count% ure gelede"
future: "{1} %count% uur van nou af|[2,Inf] %count% ure van nou af"
day:
past: "{1} %count% dag gelede|[2,Inf] %count% dae gelede"
future: "{1} %count% dag van nou af|[2,Inf] %count% dae van nou af"
week:
past: "{1} %count% week gelede|[2,Inf] %count% weke gelede"
future: "{1} %count% week van nou af|[2,Inf] %count% weke van nou af"
month:
past: "{1} %count% maand gelede|[2,Inf] %count% maande gelede"
future: "{1} %count% maand van nou af|[2,Inf] %count% maande van nou af"
year:
past: "{1} %count% jaar gelede|[2,Inf] %count% jaar gelede"
future: "{1} %count% jaar van nou af|[2,Inf] %count% jaar van nou af"

compound:
second: "{1} %count% sekonde|[2,Inf] %count% sekondes"
minute: "{1} %count% minuut|[2,Inf] %count% minute"
hour: "{1} %count% uur|[2,Inf] %count% ure"
day: "{1} %count% dag|[2,Inf] %count% dae"
week: "{1} %count% week|[2,Inf] %count% weke"
month: "{1} %count% maand|[2,Inf] %count% maande"
year: "{1} %count% jaar|[2,Inf] %count% jaar"
ago: "gelede"
from_now: "van nou af"