diff --git a/README.md b/README.md index 63f7636..0e702b3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +# Maintainers needed +Sorry, I have not much time supporting this repo. Also I rarely work with Laravel now, so new maintainers are needed. + # Localized Carbon for **L4** use **1.4** branch @@ -58,6 +61,7 @@ Current version of Localized Carbon ships with these localizations: + Arabic (ar) (no genitive) + Japanese (ja) (full) + Bengali (bn) (full) ++ Persian (fa) (full) But it is extendable, so you may write and use your own localization without altering the contents of the package. See [extending Localized Carbon](#extending). @@ -76,8 +80,8 @@ Next, add package's Service Provider to `app/config/app.php` in `providers` sect After that you may want to add some Aliases (`aliases` section of the same config): ``` -'LocalizedCarbon' => 'Laravelrus\LocalizedCarbon\LocalizedCarbon', -'DiffFormatter' => 'Laravelrus\LocalizedCarbon\DiffFactoryFacade', +'LocalizedCarbon' => Laravelrus\LocalizedCarbon\LocalizedCarbon::class, +'DiffFormatter' => Laravelrus\LocalizedCarbon\DiffFactoryFacade::class, ``` Note that `DiffFormatter` will only be used for extending default localizations. See [extending Localized Carbon](#extending). diff --git a/composer.json b/composer.json index 570fbdc..55fe5e9 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ ], "require": { "php": ">=5.3.0", - "illuminate/support": ">=4.1.0" + "illuminate/support": ">=5.4.0", + "nesbot/carbon": "^1.24" }, "autoload": { "psr-0": { diff --git a/src/Laravelrus/LocalizedCarbon/DiffFormatters/AfDiffFormatter.php b/src/Laravelrus/LocalizedCarbon/DiffFormatters/AfDiffFormatter.php new file mode 100644 index 0000000..81aa3b6 --- /dev/null +++ b/src/Laravelrus/LocalizedCarbon/DiffFormatters/AfDiffFormatter.php @@ -0,0 +1,18 @@ + "Januarie", + "februarie" => "Februarie", + "maart" => "Maart", + "april" => "April", + "mei" => "Mei", + "junie" => "Junie", + "julie" => "Julie", + "augustus" => "Augustus", + "september" => "September", + "oktober" => "Oktober", + "november" => "November", + "december" => "December", +); diff --git a/src/lang/af/units.php b/src/lang/af/units.php new file mode 100644 index 0000000..39b8278 --- /dev/null +++ b/src/lang/af/units.php @@ -0,0 +1,10 @@ + "sekonde|sekondes", + "minute" => "minuut|minute", + "hour" => "uur|ure", + "day" => "dag|dae", + "week" => "week|weke", + "month" => "maand|maande", + "year" => "jaar|jare", +); diff --git a/src/lang/ar/months.php b/src/lang/ar/months.php new file mode 100644 index 0000000..b43e80f --- /dev/null +++ b/src/lang/ar/months.php @@ -0,0 +1,16 @@ + https://github.com/chadidi +return array( + "january" => "يناير", + "february" => "فبراير", + "march" => "مارس", + "april" => "أبريل", + "may" => "مايو", + "june" => "يونيو", + "july" => "يوليو", + "august" => "أغسطس", + "september" => "سبتمبر", + "october" => "أكتوبر", + "november" => "نوفمبر", + "december" => "ديسمبر", +); diff --git a/src/lang/ar/units.php b/src/lang/ar/units.php index 07febf6..9dc51be 100644 --- a/src/lang/ar/units.php +++ b/src/lang/ar/units.php @@ -1,11 +1,11 @@ https://github.com/chadidi return array( - "second" => "ثانية", - "minute" => "[0,10] دقائق|[11,Inf] دقيقة", - "hour" => "[0,10] ساعات|[11,Inf] ساعة", - "day" => "[0,10] أيام|[11,Inf] يوما", - "week" => "[0,10] أسابيع|[11,Inf] أسبوعا", - "month" => "[0,10] أشهر|[11,Inf] شهرا", - "year" => "[0,10] سنوات|[11,Inf] سنة", + "second" => "[0,1] ثَانِيَة|{2} ثَانِيَتَيْن|[3,10]:count ثَوَان|[11,Inf]:count ثَانِيَة", + "minute" => "[0,1] دَقِيقَة|{2} دَقِيقَتَيْن|[3,10]:count دَقَائِق|[11,Inf]:count دَقِيقَة", + "hour" => "[0,1] سَاعَة|{2} سَاعَتَيْن|[3,10]:count سَاعَات|[11,Inf]:count سَاعَة", + "day" => "[0,1] يَوْم|{2} يَوْمَيْن|[3,10]:count أَيَّام|[11,Inf] يَوْم", + "week" => "[0,1] أُسْبُوع|{2} أُسْبُوعَيْن|[3,10]:count أَسَابِيع|[11,Inf]:count أُسْبُوع", + "month" => "[0,1] شَهْرَ|{2} شَهْرَيْن|[3,10]:count أَشْهُر|[11,Inf]:count شَهْرَ", + "year" => "[0,1] سَنَة|{2} سَنَتَيْن|[3,10]:count سَنَوَات|[11,Inf]:count سَنَة", ); diff --git a/src/lang/bg/months.php b/src/lang/bg/months.php new file mode 100644 index 0000000..2463a0a --- /dev/null +++ b/src/lang/bg/months.php @@ -0,0 +1,16 @@ + "Януари", + "february" => "Февруари", + "march" => "Март", + "april" => "Април", + "may" => "Май", + "june" => "Юни", + "july" => "Юли", + "august" => "Август", + "september" => "Септември", + "october" => "Октомври", + "november" => "Ноември", + "december" => "Декември", +); diff --git a/src/lang/fa/months.php b/src/lang/fa/months.php new file mode 100644 index 0000000..715bb59 --- /dev/null +++ b/src/lang/fa/months.php @@ -0,0 +1,15 @@ + "ژانویه", + "february" => "فوریه", + "march" => "مارچ", + "april" => "آپریل", + "may" => "می", + "june" => "جون", + "july" => "جولای", + "august" => "آگوست", + "september" => "سپتامبر", + "october" => "اکتبر", + "november" => "نوامبر", + "december" => "دسامبر", +); diff --git a/src/lang/fa/units.php b/src/lang/fa/units.php new file mode 100644 index 0000000..1f2c332 --- /dev/null +++ b/src/lang/fa/units.php @@ -0,0 +1,10 @@ + "ثانیه", + "minute" => "دقیقه", + "hour" => "ساعت", + "day" => "روز", + "week" => "هفته", + "month" => "ماه", + "year" => "سال", +); diff --git a/src/lang/fr/months.php b/src/lang/fr/months.php new file mode 100644 index 0000000..4b3feae --- /dev/null +++ b/src/lang/fr/months.php @@ -0,0 +1,16 @@ + 'Janvier', + 'february' => 'Février', + 'march' => 'Mars', + 'april' => 'Avril', + 'may' => 'Mai', + 'june' => 'Juin', + 'july' => 'Juillet', + 'august' => 'Août', + 'september' => 'Septembre', + 'october' => 'Octobre', + 'november' => 'Novembre', + 'december' => 'Décembre' +); +?> diff --git a/src/lang/it/months.php b/src/lang/it/months.php new file mode 100644 index 0000000..04a5a37 --- /dev/null +++ b/src/lang/it/months.php @@ -0,0 +1,15 @@ + "Gennaio", + "february" => "Febbraio", + "march" => "Marzo", + "april" => "Aprile", + "may" => "Maggio", + "june" => "Giugno", + "july" => "Luglio", + "august" => "Agosto", + "september" => "Settembre", + "october" => "Ottobre", + "november" => "Novembre", + "december" => "Dicembre", +); diff --git a/src/lang/it/units.php b/src/lang/it/units.php new file mode 100644 index 0000000..17ce0f8 --- /dev/null +++ b/src/lang/it/units.php @@ -0,0 +1,10 @@ + "secondo|secondi", + "minute" => "minuto|minuti", + "hour" => "ora|ore", + "day" => "giorno|giorni", + "week" => "settimana|settimane", + "month" => "mese|mesi", + "year" => "anno|anni", +); diff --git a/src/lang/nl/months.php b/src/lang/nl/months.php new file mode 100644 index 0000000..a688ada --- /dev/null +++ b/src/lang/nl/months.php @@ -0,0 +1,16 @@ + "januari", + "february" => "februari", + "march" => "maart", + "april" => "april", + "may" => "mei", + "june" => "juni", + "july" => "juli", + "august" => "augustus", + "september" => "september", + "october" => "oktober", + "november" => "november", + "december" => "december", +); diff --git a/src/lang/ro/months.php b/src/lang/ro/months.php new file mode 100644 index 0000000..e080b7b --- /dev/null +++ b/src/lang/ro/months.php @@ -0,0 +1,16 @@ + "Ianuarie", + "february" => "Februarie", + "march" => "Martie", + "april" => "Aprilie", + "may" => "Mai", + "june" => "Iunie", + "july" => "Iulie", + "august" => "August", + "september" => "Septembrie", + "october" => "Octombrie", + "november" => "Noiembrie", + "december" => "Decembrie", +); diff --git a/src/lang/ro/units.php b/src/lang/ro/units.php new file mode 100644 index 0000000..1c101fe --- /dev/null +++ b/src/lang/ro/units.php @@ -0,0 +1,11 @@ + "secundă|secunde|secunde", + "minute" => "minut|minute|minute", + "hour" => "oră|ore|ore", + "day" => "zi|zile|zile", + "week" => "săptămână|săptămâni|săptămâni", + "month" => "lună|luni|luni", + "year" => "an|ani|ani", +); diff --git a/src/lang/sv/months.php b/src/lang/sv/months.php new file mode 100755 index 0000000..ffba4af --- /dev/null +++ b/src/lang/sv/months.php @@ -0,0 +1,16 @@ + "Januari", + "february" => "Februari", + "march" => "Mars", + "april" => "April", + "may" => "Maj", + "june" => "Juni", + "july" => "Juli", + "august" => "Augusti", + "september" => "September", + "october" => "Oktober", + "november" => "November", + "december" => "December", +); diff --git a/src/lang/sv/units.php b/src/lang/sv/units.php new file mode 100755 index 0000000..c3cc431 --- /dev/null +++ b/src/lang/sv/units.php @@ -0,0 +1,11 @@ + "sekund|sekunder", + "minute" => "minut|minuter", + "hour" => "timme|timmar", + "day" => "dag|dagar", + "week" => "vecka|veckor", + "month" => "månad|månader", + "year" => "år", +); diff --git a/tests/RoLocalizedCarbonTest.php b/tests/RoLocalizedCarbonTest.php new file mode 100644 index 0000000..88eb13f --- /dev/null +++ b/tests/RoLocalizedCarbonTest.php @@ -0,0 +1,61 @@ +subSecond(1); + $this->assertEquals('acum o secundă', LocalizedCarbon::instance($oneSecondAgo)->diffForHumans()); + + $inOneSecond = Carbon::now()->addSecond(1); + $this->assertEquals('peste o secundă', LocalizedCarbon::instance($inOneSecond)->diffForHumans()); + + $fiveSeconsAgo = Carbon::now()->subSecond(5); + $this->assertEquals('acum 5 secunde', LocalizedCarbon::instance($fiveSeconsAgo)->diffForHumans()); + + $inFiveSeconds = Carbon::now()->addSecond(5); + $this->assertEquals('peste 5 secunde', LocalizedCarbon::instance($inFiveSeconds)->diffForHumans()); + + $moreSeconsAgo = Carbon::now()->subSecond(59); + $this->assertEquals('acum 59 secunde', LocalizedCarbon::instance($moreSeconsAgo)->diffForHumans()); + + $inMoreSeconds = Carbon::now()->addSecond(59); + $this->assertEquals('peste 59 secunde', LocalizedCarbon::instance($inMoreSeconds)->diffForHumans()); + + $oneMinuteAgo = Carbon::now()->subMinute(1); + $this->assertEquals('acum un minut', LocalizedCarbon::instance($oneMinuteAgo)->diffForHumans()); + + $inOneMinute = Carbon::now()->addMinute(1); + $this->assertEquals('peste un minut', LocalizedCarbon::instance($inOneMinute)->diffForHumans()); + + $fiveMinutesAgo = Carbon::now()->subMinute(5); + $this->assertEquals('acum 5 minute', LocalizedCarbon::instance($fiveMinutesAgo)->diffForHumans()); + + $twentyfourMinutesAgo = Carbon::now()->subMinute(24); + $this->assertEquals('acum 24 minute', LocalizedCarbon::instance($twentyfourMinutesAgo)->diffForHumans()); + + $inTwentyfourMinutes = Carbon::now()->addMinute(24); + $this->assertEquals('peste 24 minute', LocalizedCarbon::instance($inTwentyfourMinutes)->diffForHumans()); + + $oneYearAgo = Carbon::now()->subMonth(13); + $this->assertEquals('acum un an', LocalizedCarbon::instance($oneYearAgo)->diffForHumans()); + $twoYearsAgo = Carbon::now()->subMonth(25); + $this->assertEquals('acum 2 ani', LocalizedCarbon::instance($twoYearsAgo)->diffForHumans()); + + $fourWeeksAgo = Carbon::now()->subDays(32); + $this->assertEquals('acum 4 săptămâni', LocalizedCarbon::instance($fourWeeksAgo)->diffForHumans()); + + $oneMonthAgo = Carbon::now()->subWeek(7); + $this->assertEquals('acum o lună', LocalizedCarbon::instance($oneMonthAgo)->diffForHumans()); + } + + +}