From 2a2423260990baf8e41ccd05adf228ee7268b1a2 Mon Sep 17 00:00:00 2001 From: nasser Date: Sun, 6 Jun 2021 17:51:30 +0430 Subject: [PATCH] fix translation --- src/Lang/ar.php | 2 +- src/Lang/en.php | 2 +- src/Lang/fa.php | 2 +- src/Lang/ps.php | 2 +- src/Traits/Comparison.php | 2 +- src/Traits/Formatting.php | 10 ++++++---- tests/FormatTest.php | 3 ++- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Lang/ar.php b/src/Lang/ar.php index 858dae0..9bf7438 100644 --- a/src/Lang/ar.php +++ b/src/Lang/ar.php @@ -47,7 +47,7 @@ return [ 'decade' => 'عشر سنوات', 'century' => 'مئة عام' ], - 'pharse' => [ + 'phrase' => [ 'am' => 'ق ظ', 'pm' => 'ب ظ', 'ante_meridiem' => 'صباحي', diff --git a/src/Lang/en.php b/src/Lang/en.php index 4bd47c0..1220dbe 100644 --- a/src/Lang/en.php +++ b/src/Lang/en.php @@ -47,7 +47,7 @@ return [ 'decade' => 'decade', 'century' => 'century' ], - 'pharse' => [ + 'phrase' => [ 'am' => 'am', 'pm' => 'pm', 'ante_meridiem' => 'ante meridiem', diff --git a/src/Lang/fa.php b/src/Lang/fa.php index 1fa182a..9ad6e9d 100644 --- a/src/Lang/fa.php +++ b/src/Lang/fa.php @@ -47,7 +47,7 @@ return [ 'decade' => 'دهه', 'century' => 'قرن' ], - 'pharse' => [ + 'phrase' => [ 'am' => 'ق ظ', 'pm' => 'ب ظ', 'ante_meridiem' => 'قبل از ظهر', diff --git a/src/Lang/ps.php b/src/Lang/ps.php index 175c47e..0da0653 100644 --- a/src/Lang/ps.php +++ b/src/Lang/ps.php @@ -46,7 +46,7 @@ return [ 'yaer' => 'سال', 'century' => 'قرن' ], - 'pharse' => [ + 'phrase' => [ 'am' => 'ق ظ', 'pm' => 'ب ظ', 'ante_meridiem' => 'قبل از ظهر', diff --git a/src/Traits/Comparison.php b/src/Traits/Comparison.php index 5c34577..7c82912 100644 --- a/src/Traits/Comparison.php +++ b/src/Traits/Comparison.php @@ -334,7 +334,7 @@ trait Comparison */ public function isWeekend() { - return in_array($this->dayOfWeek, static::$weekEndsAt); + return in_array($this->dayOfWeek, static::$weekendDays); } /** diff --git a/src/Traits/Formatting.php b/src/Traits/Formatting.php index 10a2687..9fb6548 100644 --- a/src/Traits/Formatting.php +++ b/src/Traits/Formatting.php @@ -175,7 +175,7 @@ trait Formatting return ( $pYear . '-' . $pMonth . '-' . $pDay . ' ' . parent::format( 'H:i:s P' ) ); case 'r': - return ( substr(self::$messages['weekdays'][$gWeek], 0, 2 ) . '، ' . $pDay . ' ' . substr(self::$messages['year_months'][$pMonth], 0, 6 ) . ' ' . $pYear . ' ' . parent::format( 'H:i:s P' ) ); + return ( substr(self::$messages['weekdays'][$pWeek], 0, 2 ) . '، ' . $pDay . ' ' . substr(self::$messages['year_months'][$pMonth], 0, 6 ) . ' ' . $pYear . ' ' . parent::format( 'H:i:s P' ) ); case 'U': return $timestamp; @@ -216,7 +216,10 @@ trait Formatting continue; } $output = $this->characterFormat($char, $timestamp, $pYear, $pMonth, $pDay, $pWeek); - $result .= (string) new Notowo($output, static::getLocale() == 'en' ? 'en' : 'fa' ); + if(is_numeric($output)) { + $output = (string) new Notowo($output, static::getLocale() == 'en' ? 'en' : 'fa' ); + } + $result .= $output; $index++; } @@ -312,7 +315,6 @@ trait Formatting public function formatGregorian($format) { return $this->datetime()->format($format); - return $this->datetime()->format($format); } /** @@ -385,7 +387,7 @@ trait Formatting static::DECADE_PER_CENTURY, ]; $difference = $this->diffSeconds($v); - $result .= static::$messages['phrase'][$difference < 0 ? 'later' : 'ago']; + $absolute = static::$messages['phrase'][$difference < 0 ? 'later' : 'ago']; $difference = abs($difference); diff --git a/tests/FormatTest.php b/tests/FormatTest.php index 15912b3..2d8e9e2 100644 --- a/tests/FormatTest.php +++ b/tests/FormatTest.php @@ -74,6 +74,7 @@ class FormatTest extends TestCase public function testFormatDifference() { + Verta::setLocale('fa'); $target = Verta::parse('1398-10-10 21:30:50'); $datetime = Verta::parse('1398-10-10 21:30:50'); @@ -115,7 +116,7 @@ class FormatTest extends TestCase public function testFormatWord() { - $datetime = Verta::parse('1398-10-11 21:32:35')->formatWord('l dS F'); + $datetime = Verta::parse('1398-10-11 21:32:35')->formatWord('l d S F'); $this->assertEquals('چهارشنبه یازده ام دی', $datetime); }