Skip to content

Instantly share code, notes, and snippets.

@amiriun
Last active March 7, 2022 16:30
Show Gist options
  • Save amiriun/009aba4f6bfb5727d9e4 to your computer and use it in GitHub Desktop.
Save amiriun/009aba4f6bfb5727d9e4 to your computer and use it in GitHub Desktop.
Translate Carbon Diff For Human Characters to Persian
<?php
function diffForHumans($time)
{
$get_en = \Carbon::createFromTimeStamp( $time )->diffForHumans();
$set_fa = str_replace('years','سال',$get_en);
$set_fa = str_replace('months','ماه',$set_fa);
$set_fa = str_replace('weeks','هفته',$set_fa);
$set_fa = str_replace('days','روز',$set_fa);
$set_fa = str_replace('hours','ساعت',$set_fa);
$set_fa = str_replace('minutes','دقیقه',$set_fa);
$set_fa = str_replace('seconds','ثانیه',$set_fa);
$set_fa = str_replace('year','سال',$set_fa);
$set_fa = str_replace('month','ماه',$set_fa);
$set_fa = str_replace('day','روز',$set_fa);
$set_fa = str_replace('week','هفته',$set_fa);
$set_fa = str_replace('hour','ساعت',$set_fa);
$set_fa = str_replace('minute','دقیقه',$set_fa);
$set_fa = str_replace('second','ثانیه',$set_fa);
$set_fa = str_replace('ago','پیش',$set_fa);
$set_fa = str_replace('after','بعد',$set_fa);
$set_fa = str_replace('before','قبل',$set_fa);
$set_fa = str_replace('from now','بعد',$set_fa);
return $set_fa;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment