diff --git a/README.md b/README.md index f7ba58a..20d4d23 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ Currently we support following languages: * [Português - Brasil](src/Coduo/PHPHumanizer/Resources/translations/difference.pt_BR.yml) * [Italian](src/Coduo/PHPHumanizer/Resources/translations/difference.it.yml) * [Dutch](src/Coduo/PHPHumanizer/Resources/translations/difference.nl.yml) +* [Spanish(Castilian) - Spain](src/Coduo/PHPHumanizer/Resources/translations/difference.es_ES.yml) # Credits diff --git a/spec/Coduo/PHPHumanizer/CollectionSpec.php b/spec/Coduo/PHPHumanizer/CollectionSpec.php index 8e9a6fa..bef3753 100644 --- a/spec/Coduo/PHPHumanizer/CollectionSpec.php +++ b/spec/Coduo/PHPHumanizer/CollectionSpec.php @@ -50,4 +50,19 @@ function it_humanizes_collections_for_dutch_locale() $this->oxford($example[0], $example[1], 'nl')->shouldReturn($example[2]); } } + + function it_humanizes_collections_for_spanish_locale() + { + $examples = array( + array(array("Michal"), null, 'Michal'), + array(array("Michal", "Norbert"), null, 'Michal y Norbert'), + array(array("Michal", "Norbert", "Lukasz"), 2, 'Michal, Norbert, y 1 más'), + array(array("Michal", "Norbert", "Lukasz", "Pawel"), 2, 'Michal, Norbert, y 2 más'), + array(array("Michal", "Norbert", "Lukasz", "Pawel"), null, 'Michal, Norbert, Lukasz, y Pawel'), + ); + + foreach ($examples as $example) { + $this->oxford($example[0], $example[1], 'es_ES')->shouldReturn($example[2]); + } + } } diff --git a/spec/Coduo/PHPHumanizer/DateTimeSpec.php b/spec/Coduo/PHPHumanizer/DateTimeSpec.php index 529aff0..eb30690 100644 --- a/spec/Coduo/PHPHumanizer/DateTimeSpec.php +++ b/spec/Coduo/PHPHumanizer/DateTimeSpec.php @@ -282,7 +282,7 @@ 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_humanize_difference_between_dates_for_bg_locale() { $examples = array( @@ -309,7 +309,7 @@ function it_humanize_difference_between_dates_for_bg_locale() $this->difference(new \DateTime($example[0]), new \DateTime($example[1]), 'bg')->shouldReturn($example[2]); } } - + function it_humanizes_precise_difference_between_dates_for_bg_locale() { $examples = array( @@ -344,4 +344,21 @@ function it_humanizes_precise_difference_between_dates_for_no_locale() $this->preciseDifference(new \DateTime($example[0]), new \DateTime($example[1]), 'no')->shouldReturn($example[2]); } } + + function it_humanizes_precise_difference_between_dates_for_es_ES_locale() + { + $examples = array( + array("2014-04-26 13:00:00", "2014-04-26 12:58:15", '1 minuto, 45 segundos atrás'), + array("2014-04-26 13:00:00", "2014-04-26 11:20:00", '1 hora, 40 minutos atrás'), + array("2014-04-26 13:00:00", "2014-04-27 13:15:00", '1 día, 15 minutos desde ahora'), + array("2014-04-26 13:00:00", "2014-05-03 15:00:00", '7 días, 2 horas desde ahora'), + array("2014-04-26 13:00:00", "2015-04-28 17:00:00", '1 año, 2 días, 4 horas desde ahora'), + array("2014-04-26 13:00:00", "2014-04-28 23:00:00", '2 días, 10 horas desde ahora'), + array("2014-04-26 13:00:00", "2014-04-25 11:20:00", '1 día, 1 hora, 40 minutos atrás'), + array("2014-04-26 13:00:00", "2016-04-27 13:00:00", '2 años, 1 día desde ahora'), + ); + foreach ($examples as $example) { + $this->preciseDifference(new \DateTime($example[0]), new \DateTime($example[1]), 'es_ES')->shouldReturn($example[2]); + } + } } diff --git a/src/Coduo/PHPHumanizer/Resources/translations/difference.es_ES.yml b/src/Coduo/PHPHumanizer/Resources/translations/difference.es_ES.yml new file mode 100644 index 0000000..5f1676f --- /dev/null +++ b/src/Coduo/PHPHumanizer/Resources/translations/difference.es_ES.yml @@ -0,0 +1,35 @@ +just_now: + past: "[0,Inf] en este momento" + future: "[0,Inf] en este momento" +second: + past: "{1} %count% segundo atrás|[2,Inf] %count% atrás" + future: "{1} %count% segundo desde ahora|[2,Inf] %count% segundos desde ahora" +minute: + past: "{1} %count% minuto|[2,Inf] hace %count% minutos atrás" + future: "{1} %count% minuto|[2,Inf] en %count% minutos desde ahora" +hour: + past: "{1} %count% hora|[2,Inf] hace %count% horas atrás" + future: "{1} %count% horas|[2,Inf] en %count% horas desde ahora" +day: + past: "{1} %count% día|[2,Inf] hace %count% días atrás" + future: "{1} %count% día|[2,Inf] en %count% días desde ahora" +week: + past: "{1} %count% semana|[2,Inf] hace %count% semanas atrás" + future: "{1} %count% semana|[2,Inf] en %count% semanas desde ahora" +month: + past: "{1} %count% mes|[2,Inf] hace %count% meses atrás" + future: "{1} %count% mes|[2,Inf] en %count% meses desde ahora" +year: + past: "{1} %count% año|[2,Inf] hace %count% años atrás" + future: "{1} %count% año|[2,Inf] en %count% años desde ahora" + +compound: + second: "{1} %count% segundo|[2,Inf] %count% segundos" + minute: "{1} %count% minuto|[2,Inf] %count% minutos" + hour: "{1} %count% hora|[2,Inf] %count% horas" + day: "{1} %count% día|[2,Inf] %count% días" + week: "{1} %count% semana|[2,Inf] %count% semanas" + month: "{1} %count% mes|[2,Inf] %count% meses" + year: "{1} %count% año|[2,Inf] %count% años" + ago: "atrás" + from_now: "desde ahora" diff --git a/src/Coduo/PHPHumanizer/Resources/translations/oxford.es_ES.yml b/src/Coduo/PHPHumanizer/Resources/translations/oxford.es_ES.yml new file mode 100644 index 0000000..1335e9f --- /dev/null +++ b/src/Coduo/PHPHumanizer/Resources/translations/oxford.es_ES.yml @@ -0,0 +1,3 @@ +only_two: "%first% y %second%" +comma_separated: "%list%, y %last%" +comma_separated_with_limit: "{1} %list%, y 1 más|[2,Inf] %list%, y %count% más"