Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Apr 7, 2016
2 parents 52699be + e3ad3be commit fe2e030
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 7 deletions.
38 changes: 31 additions & 7 deletions src/Lang/hu.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,41 @@
|
*/

'year' => ':count év',
'month' => ':count hónap',
'week' => ':count hét',
'day' => ':count nap',
'hour' => ':count óra',
'minute' => ':count perc',
'second' => ':count másodperc',
'ago' => ':time ezelőtt',
'from_now' => ':time ezután',
'after' => ':time később',
'before' => ':time korábban',
'year' => '1 évvel|:count évvel',
'month' => '1 hónappal|:count hónappal',
'week' => '1 héttel|:count héttel',
'day' => '1 nappal|:count nappal',
'hour' => '1 órával|:count órával',
'minute' => '1 perccel|:count perccel',
'second' => '1 másodperccel|:count másodperccel',

'year_ago' => ':count éve',
'month_ago' => ':count hónapja',
'week_ago' => ':count hete',
'day_ago' => ':count napja',
'hour_ago' => ':count órája',
'minute_ago' => ':count perce',
'second_ago' => ':count másodperce',

'year_after' => ':count évvel',
'month_after' => ':count hónappal',
'week_after' => ':count héttel',
'day_after' => ':count nappal',
'hour_after' => ':count órával',
'minute_after' => ':count perccel',
'second_after' => ':count másodperccel',

'year_before' => ':count évvel',
'month_before' => ':count hónappal',
'week_before' => ':count héttel',
'day_before' => ':count nappal',
'hour_before' => ':count órával',
'minute_before' => ':count perccel',
'second_before' => ':count másodperccel',

'january' => 'január',
'february' => 'február',
Expand Down
122 changes: 122 additions & 0 deletions tests/TranslationHuTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

use Jenssegers\Date\Date;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\Translator;

class TranslationHuTest extends PHPUnit_Framework_TestCase
{

public function setUp()
{
date_default_timezone_set('UTC');
Date::setLocale('hu');
}

public function testGetsAndSetsTranslator()
{
$translator = new Translator('hu');
$translator->addLoader('array', new ArrayLoader());
$this->assertNotEquals($translator, Date::getTranslator());

Date::setTranslator($translator);
$this->assertEquals($translator, Date::getTranslator());
}

public function testTimespanTranslated()
{
$date = new Date(1403619368);
$date = $date->sub('-100 days -3 hours -20 minutes');

$this->assertSame('3 hónap, 1 hét, 1 nap, 3 óra, 20 perc', $date->timespan(1403619368));
}

public function testAgoTranslated()
{

$date = Date::parse('-1 minute');
$this->assertSame('1 perce', $date->diffForHumans());

$date = Date::parse('-21 hours');
$this->assertSame('21 órája', $date->ago());

$date = Date::parse('-5 days');
$this->assertSame('5 napja', $date->ago());

$date = Date::parse('-3 weeks');
$this->assertSame('3 hete', $date->ago());

$date = Date::parse('-6 months');
$this->assertSame('6 hónapja', $date->ago());

$date = Date::parse('-10 years');
$this->assertSame('10 éve', $date->ago());
}

public function testFromNowTranslated()
{

$date = Date::parse('+1 minute');
$this->assertSame('1 perc múlva', $date->ago());

$date = Date::parse('+21 hours');
$this->assertSame('21 óra múlva', $date->ago());

$date = Date::parse('+5 days');
$this->assertSame('5 nap múlva', $date->ago());

$date = Date::parse('+3 weeks');
$this->assertSame('3 hét múlva', $date->ago());

$date = Date::parse('+6 months');
$this->assertSame('6 hónap múlva', $date->ago());

$date = Date::parse('+10 years');
$this->assertSame('10 év múlva', $date->ago());
}

public function testAfterTranslated()
{
$date = Date::parse('+21 hours');
$this->assertSame('21 órával később', $date->ago(Date::now()));

$date = Date::parse('+5 days');
$this->assertSame('5 nappal később', $date->ago(Date::now()));

$date = Date::parse('+3 weeks');
$this->assertSame('3 héttel később', $date->ago(Date::now()));

$date = Date::parse('+6 months');
$this->assertSame('6 hónappal később', $date->ago(Date::now()));

$date = Date::parse('+10 years');
$this->assertSame('10 évvel később', $date->ago(Date::now()));
}

public function testBeforeTranslated()
{
$date = Date::parse('-21 hours');
$this->assertSame('21 órával korábban', $date->ago(Date::now()));

$date = Date::parse('-5 days');
$this->assertSame('5 nappal korábban', $date->ago(Date::now()));

$date = Date::parse('-3 weeks');
$this->assertSame('3 héttel korábban', $date->ago(Date::now()));

$date = Date::parse('-6 months');
$this->assertSame('6 hónappal korábban', $date->ago(Date::now()));

$date = Date::parse('-10 years');
$this->assertSame('10 évvel korábban', $date->ago(Date::now()));
}

public function testCreateFromFormat()
{
$date = Date::createFromFormat('Y. F d.', '2015. január 1.');
$this->assertSame('2015-01-01', $date->format('Y-m-d'));

$date = Date::createFromFormat('Y. F d., D', '2015. március 21., szombat');
$this->assertSame('2015-03-21', $date->format('Y-m-d'));
}
}

0 comments on commit fe2e030

Please sign in to comment.