-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8140258
commit 58b02c1
Showing
3 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
// locale: bulgarian (bg) | ||
// author: JamesAxl https://github.com/jamesaxl | ||
|
||
return array( | ||
"months" => explode('_', 'януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември'), | ||
"monthsShort" => explode('_', 'яну_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек'), | ||
"weekdays" => explode('_', 'понеделник_вторник_сряда_четвъртък_петък_събота_неделя'), | ||
"weekdaysShort" => explode('_', 'пон_вто_сря_чет_пет_съб_нед'), | ||
"calendar" => array( | ||
"sameDay" => '[Днес]', | ||
"nextDay" => '[Утре]', | ||
"lastDay" => '[Вчера]', | ||
"lastWeek" => 'l', | ||
"sameElse" => 'l', | ||
"withTime" => '[в] H:i', | ||
"default" => 'd/m/Y', | ||
), | ||
|
||
"relativeTime" => array( | ||
"future" => 'след %s', | ||
"past" => 'преди %s', | ||
"s" => 'няколко секунди', | ||
"ss" => '%d секунди', | ||
"m" => 'минута', | ||
"mm" => '%d минути', | ||
"h" => 'час', | ||
"hh" => '%d часа', | ||
"d" => 'ден', | ||
"dd" => '%d дена', | ||
"M" => 'месец', | ||
"MM" => '%d месеца', | ||
"y" => 'година', | ||
"yy" => '%d години', | ||
), | ||
|
||
"ordinal" => function ($number) | ||
{ | ||
$lastDigit = $number % 10; | ||
$lastTwoDigits = $number % 100; | ||
|
||
if ($number === 0) { | ||
return $number . '-ев'; | ||
} else if ($lastTwoDigits === 0) { | ||
return $number . '-ен'; | ||
} else if ($lastTwoDigits > 10 && $lastTwoDigits < 20) { | ||
return $number . '-ти'; | ||
} else if ($lastDigit === 1) { | ||
return $number . '-ви'; | ||
} else if ($lastDigit === 2) { | ||
return $number . '-ри'; | ||
} else if ($lastDigit === 7 || $lastDigit === 8) { | ||
return $number . '-ми'; | ||
} else { | ||
return $number . '-ти'; | ||
} | ||
}, | ||
"week" => array( | ||
"dow" => 1, // Monday is the first day of the week. | ||
"doy" => 7 // The week that contains Jan 7th is the first week of the year | ||
), | ||
"customFormats" => array( | ||
"LTS" => "G:i:s", | ||
"LT" => "G:i", // 20:30 | ||
"L" => "d/m/Y", // 04/09/1986 | ||
"l" => "j/n/Y", // 4/9/1986 | ||
"LL" => "jS F Y", // 4 Septembre 1986 | ||
"ll" => "j M Y", // 4 Sep 1986 | ||
"LLL" => "jS F Y G:i", // 4 Septembre 1986 20:30 | ||
"lll" => "j M Y G:i", // 4 Sep 1986 20:30 | ||
"LLLL" => "l, jS F Y G:i", // Jeudi, 4 Septembre 1986 20:30 | ||
"llll" => "D, j M Y G:i", // Jeu, 4 Sep 1986 20:30 | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace Moment\Test\Unit; | ||
|
||
use Moment\Moment; | ||
use PHPUnit\Framework; | ||
|
||
final class MomentBulgarianLocaleTest extends Framework\TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
Moment::setLocale('bg_BG'); | ||
} | ||
|
||
public function testWeekdayNames() | ||
{ | ||
$startingDate = '2015-01-04T00:00:00+0000'; | ||
|
||
$moment = new Moment($startingDate); | ||
|
||
$weekdayNames = array( | ||
1 => array('пон', 'понеделник'), | ||
2 => array('вто', 'вторник'), | ||
3 => array('сря', 'сряда'), | ||
4 => array('чет', 'четвъртък'), | ||
5 => array('пет', 'петък'), | ||
6 => array('съб', 'събота'), | ||
7 => array('нед', 'неделя'), | ||
); | ||
|
||
for ($d = 1; $d < 7; $d++) | ||
{ | ||
self::assertEquals($weekdayNames[$moment->getWeekday()][0], $moment->getWeekdayNameShort(), 'weekday short name failed'); | ||
self::assertEquals($weekdayNames[$moment->getWeekday()][1], $moment->getWeekdayNameLong(), 'weekday long name failed'); | ||
|
||
$moment->addDays(1); | ||
} | ||
} | ||
|
||
public function testMonthNames() | ||
{ | ||
$startingDate = '2015-01-04T00:00:00+0000'; | ||
|
||
$moment = new Moment($startingDate); | ||
|
||
$monthNames = array( | ||
1 => array('яну', 'януари'), | ||
2 => array('фев', 'февруари'), | ||
3 => array('мар', 'март'), | ||
4 => array('апр', 'април'), | ||
5 => array('май', 'май'), | ||
6 => array('юни', 'юни'), | ||
7 => array('юли', 'юли'), | ||
8 => array('авг', 'август'), | ||
9 => array('сеп', 'септември'), | ||
10 => array('окт', 'октомври'), | ||
11 => array('ное', 'ноември'), | ||
12 => array('дек', 'декември'), | ||
); | ||
|
||
for ($d = 1; $d < 12; $d++) | ||
{ | ||
self::assertEquals($monthNames[$moment->format('n')][0], $moment->getMonthNameShort(), 'month short name failed'); | ||
self::assertEquals($monthNames[$moment->format('n')][1], $moment->getMonthNameLong(), 'month long name failed'); | ||
|
||
$moment->addMonths(1); | ||
} | ||
} | ||
|
||
public function testFormat() | ||
{ | ||
$values = array( | ||
array('l, F d Y, g:i:s a', 'неделя, февруари 14 2010, 3:25:50 pm'), | ||
array('D, gA', 'нед, 3PM'), | ||
array('n m F M', '2 02 февруари фев'), | ||
array('Y y', '2010 10'), | ||
array('j d', '14 14'), | ||
array('[the] z [day of the year]', 'the 44 day of the year') | ||
); | ||
|
||
$moment = new Moment('2010-02-14 15:25:50'); | ||
|
||
for ($i = 0; $i < count($values); $i++) { | ||
self::assertEquals($values[$i][1], $moment->format($values[$i][0])); | ||
} | ||
} | ||
|
||
public function testRelative() | ||
{ | ||
$begin = new Moment('2015-06-14 20:46:22', 'Europe/Berlin'); | ||
|
||
$end = new Moment('2015-06-14 20:48:32', 'Europe/Berlin'); | ||
|
||
self::assertEquals('след 2 минути', $end->from($begin)->getRelative()); | ||
self::assertEquals('преди 2 минути', $begin->from($end)->getRelative()); | ||
} | ||
} |