尝试以另一种语言在网站上提供所有日期。 但这并没有任何改变。
我在config / app.php文件中设置了'locale'=>'tr'。
下面的我的AppServiceProvider.php:
public function boot(\Illuminate\Contracts\View\Factory $factory)
{
$factory->composer('*', 'App\Http\Views\Composers\AuthenticatedComposer');
Carbon::setLocale('tr');
}
我的资源文件如下:
public function toArray($request)
{
Carbon::setLocale('tr');
$user = Auth::user();
setlocale(LC_TIME, 'Turkish');
return [
"id" => $this->id,
"customer" => $this->customer,
"vehicle" => $this->vehicle,
"basket" => $this->basket,
"total" => $this->total,
"discount" => $this->discount,
"net_total" => $this->total-$this->discount,
"status" => $this->status,
"created_at" => Carbon::parse($this->created_at)->formatLocalized('%A %d %B %Y'),
"edit_allowed" => $user->power('process', 'edit'),
"delete_allowed" => $user->power('process', 'delete'),
"detail_allowed" => $user->power('process', 'detail')
];
}
我希望日期转换为土耳其语。 但是它返回的英文日期为:“ 2020年9月6日,星期日”
怎么了?
答案 0 :(得分:0)
我认为它应该是这样的语言代码:tr-TR
除非它是因为intl扩展名不在服务器上。在这种情况下,请尝试安装“ sudo apt-get install php-intl”