From e8dc265fbab3cc18485869e7bf4ff262d4537df5 Mon Sep 17 00:00:00 2001 From: Sarel van der Walt Date: Thu, 29 Oct 2015 07:10:50 +0200 Subject: [PATCH 1/5] Addition of Afrikaans (af) language translation (with spec tests) --- spec/Coduo/PHPHumanizer/DateTimeSpec.php | 48 +++++++++++++++++++ .../Resources/translations/difference.af.yml | 35 ++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/Coduo/PHPHumanizer/Resources/translations/difference.af.yml diff --git a/spec/Coduo/PHPHumanizer/DateTimeSpec.php b/spec/Coduo/PHPHumanizer/DateTimeSpec.php index ead80e9..aba5e42 100644 --- a/spec/Coduo/PHPHumanizer/DateTimeSpec.php +++ b/spec/Coduo/PHPHumanizer/DateTimeSpec.php @@ -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( @@ -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( diff --git a/src/Coduo/PHPHumanizer/Resources/translations/difference.af.yml b/src/Coduo/PHPHumanizer/Resources/translations/difference.af.yml new file mode 100644 index 0000000..77c6ed7 --- /dev/null +++ b/src/Coduo/PHPHumanizer/Resources/translations/difference.af.yml @@ -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" From e441c4031592e8a185d32229001b73440cbc282a Mon Sep 17 00:00:00 2001 From: Sarel van der Walt Date: Thu, 29 Oct 2015 07:31:57 +0200 Subject: [PATCH 2/5] Addition of contribution markdown file --- CONTRIBUTING.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..23aca62 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,21 @@ +#A quick guide to contribute to the project: + +##Installing the dev environment + +1. For 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 :: PSR-1](http://www.php-fig.org/psr/psr-1/) +[PSR-2: Coding Style Guide :: PSR-1](http://www.php-fig.org/psr/psr-2/) From db117e862c64468477750f5ae47b8dab46879f60 Mon Sep 17 00:00:00 2001 From: Sarel van der Walt Date: Thu, 29 Oct 2015 07:32:53 +0200 Subject: [PATCH 3/5] Update CONTRIBUTING.md New-lines after PSR links --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 23aca62..ae9c200 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,5 +17,7 @@ ##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 :: PSR-1](http://www.php-fig.org/psr/psr-1/) + [PSR-2: Coding Style Guide :: PSR-1](http://www.php-fig.org/psr/psr-2/) From 7e1071edc3f5ad67c9d5c38e6d11fc77dbaf293b Mon Sep 17 00:00:00 2001 From: Sarel van der Walt Date: Thu, 29 Oct 2015 07:33:29 +0200 Subject: [PATCH 4/5] Update CONTRIBUTING.md Fixed typo --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ae9c200..ab2b41d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,6 +18,6 @@ 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 :: PSR-1](http://www.php-fig.org/psr/psr-1/) +[PSR-1: Basic Coding Standard](http://www.php-fig.org/psr/psr-1/) -[PSR-2: Coding Style Guide :: PSR-1](http://www.php-fig.org/psr/psr-2/) +[PSR-2: Coding Style Guide](http://www.php-fig.org/psr/psr-2/) From b0759cb7acdee07a2b625d88dd1a54969a847873 Mon Sep 17 00:00:00 2001 From: Sarel van der Walt Date: Thu, 29 Oct 2015 11:17:30 +0200 Subject: [PATCH 5/5] Update CONTRIBUTING.md Fixed typo :) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ab2b41d..ee409ba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ##Installing the dev environment -1. For the repo +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: