Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #99 from LaravelRUS/master
Browse files Browse the repository at this point in the history
Merge from master
  • Loading branch information
Amegatron authored Apr 22, 2018
2 parents dc891ed + 511fd42 commit 03dc289
Show file tree
Hide file tree
Showing 24 changed files with 398 additions and 12 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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).
Expand All @@ -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).
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
18 changes: 18 additions & 0 deletions src/Laravelrus/LocalizedCarbon/DiffFormatters/AfDiffFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php namespace Laravelrus\LocalizedCarbon\DiffFormatters;

class AfDiffFormatter implements DiffFormatterInterface {

public function format($isNow, $isFuture, $delta, $unit) {
$txt = $delta . ' ' . $unit;
$txt .= $delta == 1 ? '' : 's';

if ($isNow) {
$txt .= ($isFuture) ? ' van nou af' : ' terug';
return $txt;
}

$txt .= ($isFuture) ? ' na' : ' voor';
return $txt;
}

}
13 changes: 13 additions & 0 deletions src/Laravelrus/LocalizedCarbon/DiffFormatters/FaDiffFotmatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace Laravelrus\LocalizedCarbon\DiffFormatters;
class FaDiffFormatter implements DiffFormatterInterface {
public function format($isNow, $isFuture, $delta, $unit) {
$txt = $delta . ' ' . $unit;
if ($isNow) {
$txt .= ($isFuture) ? ' از حالا' : ' گذشته';
return $txt;
}
$txt .= ($isFuture) ? ' بعد' : ' قبل';
return $txt;
}
}
31 changes: 31 additions & 0 deletions src/Laravelrus/LocalizedCarbon/DiffFormatters/ItDiffFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php namespace Laravelrus\LocalizedCarbon\DiffFormatters;
class ItDiffFormatter implements DiffFormatterInterface {
public function format($isNow, $isFuture, $delta, $unit) {
$unitStr = \Lang::choice("localized-carbon::units." . $unit, $delta, array(), 'it');
if($delta == 1){
switch($unit){
case 'hour':
$delta = 'Un\'';
break;
case 'week':
$delta = 'Una';
break;
default:
$delta = 'Un';
break;
}
}
$txt = $delta . ' ' . $unitStr;
if ($isNow) {
if($isFuture){
$pre= 'Tra ';
return $pre . strtolower($txt);
}
else{
$suffix= ' fa';
return $txt . $suffix;
}
}
return $txt .= ($isFuture) ? ' dopo' : ' prima';
}
}
49 changes: 49 additions & 0 deletions src/Laravelrus/LocalizedCarbon/DiffFormatters/RoDiffFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Laravelrus\LocalizedCarbon\DiffFormatters;


class RoDiffFormatter implements DiffFormatterInterface {

public function format($isNow, $isFuture, $delta, $unit) {
$unitStr = \Lang::choice("localized-carbon::units." . $unit, $delta, array(), 'ro');

if ($isNow) {
$pre = $isFuture ? 'peste ' : 'acum ';
$suffix = '';

switch ($unit) {
case 'second': $deltaInWords = 'o'; break;
case 'minute': $deltaInWords = 'un'; break;
case 'hour': $deltaInWords = 'o'; break;
case 'day': $deltaInWords = 'o'; break;
case 'week': $deltaInWords = 'o'; break;
case 'month': $deltaInWords = 'o'; break;
case 'year': $deltaInWords = 'un'; break;
}

if($delta == 1) {
$delta = $deltaInWords;
$suffix = '';
}

return $pre . $delta . ' ' . $unitStr . $suffix;
} else {
$post = ($isFuture) ? ' înainte' : ' după';

if($delta == 1) {
switch ($unit) {
case 'second': $delta = 'o'; break;
case 'minute': $delta = 'un'; break;
case 'hour': $delta = 'o'; break;
case 'day': $delta = 'o'; break;
case 'week': $delta = 'o'; break;
case 'month': $delta = 'o'; break;
case 'year': $delta = 'un'; break;
}
}

return $delta . ' ' . $unitStr . $post;
}
}
}
16 changes: 16 additions & 0 deletions src/Laravelrus/LocalizedCarbon/DiffFormatters/SvDiffFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php namespace Laravelrus\LocalizedCarbon\DiffFormatters;


class SvDiffFormatter implements DiffFormatterInterface {

public function format($isNow, $isFuture, $delta, $unit) {
$txt = \Lang::choice("localized-carbon::units." . $unit, $delta, array(), 'sv');
$txt = $delta.' '.$txt;
if ($isNow) {
$txt .= ($isFuture) ? ' från nu' : ' sedan';
return 'för '.$txt;
}
$txt .= ($isFuture) ? ' efter' : ' före';
return 'om '.$txt;
}
}
2 changes: 1 addition & 1 deletion src/Laravelrus/LocalizedCarbon/LocalizedCarbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function determineLanguage() {
return \App::getLocale();
}

public function diffForHumans(Carbon $other = null, $formatter = null) {
public function diffForHumans($other = null, $formatter = null, $short = false, $parts = 1) {
if ($formatter === null) {
$language = self::determineLanguage();
$formatter = DiffFactoryFacade::get($language);
Expand Down
15 changes: 15 additions & 0 deletions src/lang/af/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
return array(
"januarie" => "Januarie",
"februarie" => "Februarie",
"maart" => "Maart",
"april" => "April",
"mei" => "Mei",
"junie" => "Junie",
"julie" => "Julie",
"augustus" => "Augustus",
"september" => "September",
"oktober" => "Oktober",
"november" => "November",
"december" => "December",
);
10 changes: 10 additions & 0 deletions src/lang/af/units.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
return array(
"second" => "sekonde|sekondes",
"minute" => "minuut|minute",
"hour" => "uur|ure",
"day" => "dag|dae",
"week" => "week|weke",
"month" => "maand|maande",
"year" => "jaar|jare",
);
16 changes: 16 additions & 0 deletions src/lang/ar/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
// Created by : Abdellah Chadidi => https://github.com/chadidi
return array(
"january" => "يناير",
"february" => "فبراير",
"march" => "مارس",
"april" => "أبريل",
"may" => "مايو",
"june" => "يونيو",
"july" => "يوليو",
"august" => "أغسطس",
"september" => "سبتمبر",
"october" => "أكتوبر",
"november" => "نوفمبر",
"december" => "ديسمبر",
);
16 changes: 8 additions & 8 deletions src/lang/ar/units.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

// Created by : Abdellah Chadidi => 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 سَنَة",
);
16 changes: 16 additions & 0 deletions src/lang/bg/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return array(
"january" => "Януари",
"february" => "Февруари",
"march" => "Март",
"april" => "Април",
"may" => "Май",
"june" => "Юни",
"july" => "Юли",
"august" => "Август",
"september" => "Септември",
"october" => "Октомври",
"november" => "Ноември",
"december" => "Декември",
);
15 changes: 15 additions & 0 deletions src/lang/fa/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
return array(
"january" => "ژانویه",
"february" => "فوریه",
"march" => "مارچ",
"april" => "آپریل",
"may" => "می",
"june" => "جون",
"july" => "جولای",
"august" => "آگوست",
"september" => "سپتامبر",
"october" => "اکتبر",
"november" => "نوامبر",
"december" => "دسامبر",
);
10 changes: 10 additions & 0 deletions src/lang/fa/units.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
return array(
"second" => "ثانیه",
"minute" => "دقیقه",
"hour" => "ساعت",
"day" => "روز",
"week" => "هفته",
"month" => "ماه",
"year" => "سال",
);
16 changes: 16 additions & 0 deletions src/lang/fr/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
return array(
'january' => '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'
);
?>
15 changes: 15 additions & 0 deletions src/lang/it/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
return array(
"january" => "Gennaio",
"february" => "Febbraio",
"march" => "Marzo",
"april" => "Aprile",
"may" => "Maggio",
"june" => "Giugno",
"july" => "Luglio",
"august" => "Agosto",
"september" => "Settembre",
"october" => "Ottobre",
"november" => "Novembre",
"december" => "Dicembre",
);
10 changes: 10 additions & 0 deletions src/lang/it/units.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
return array(
"second" => "secondo|secondi",
"minute" => "minuto|minuti",
"hour" => "ora|ore",
"day" => "giorno|giorni",
"week" => "settimana|settimane",
"month" => "mese|mesi",
"year" => "anno|anni",
);
16 changes: 16 additions & 0 deletions src/lang/nl/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return array(
"january" => "januari",
"february" => "februari",
"march" => "maart",
"april" => "april",
"may" => "mei",
"june" => "juni",
"july" => "juli",
"august" => "augustus",
"september" => "september",
"october" => "oktober",
"november" => "november",
"december" => "december",
);
16 changes: 16 additions & 0 deletions src/lang/ro/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return array(
"january" => "Ianuarie",
"february" => "Februarie",
"march" => "Martie",
"april" => "Aprilie",
"may" => "Mai",
"june" => "Iunie",
"july" => "Iulie",
"august" => "August",
"september" => "Septembrie",
"october" => "Octombrie",
"november" => "Noiembrie",
"december" => "Decembrie",
);
11 changes: 11 additions & 0 deletions src/lang/ro/units.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return array(
"second" => "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",
);
16 changes: 16 additions & 0 deletions src/lang/sv/months.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

return array(
"january" => "Januari",
"february" => "Februari",
"march" => "Mars",
"april" => "April",
"may" => "Maj",
"june" => "Juni",
"july" => "Juli",
"august" => "Augusti",
"september" => "September",
"october" => "Oktober",
"november" => "November",
"december" => "December",
);
Loading

0 comments on commit 03dc289

Please sign in to comment.