I'm trying to set the same global locale of laravel which is :
config('app.locale')
与Carbon 一起工作.
似乎你可以通过以下两种方式来实现:
Carbon::setLocale('fr')
or
setlocale(LC_TIME, 'theLocale');
所以我try 使用中间件或提供者,但没有成功.
(为什么这不是laravel的默认功能?)
I'm trying to set the same global locale of laravel which is :
config('app.locale')
与Carbon 一起工作.
似乎你可以通过以下两种方式来实现:
Carbon::setLocale('fr')
or
setlocale(LC_TIME, 'theLocale');
所以我try 使用中间件或提供者,但没有成功.
(为什么这不是laravel的默认功能?)
这是我的错,Carbon实际上使用的是php
setlocale();
the
Carbon::setLocale('fr')
方法仅适用于
->diffForHumans()
方法. Notice that the php setlocale() reference to the locale stored on your OS to choose one of the installed one use
locale -a
在你的控制台上
secondly, you have to use
->formatLocalized()
方法 instead of
->format()
方法
and lastly all the usefull 方法s like
->toDateString()
->toFormattedDateString()
->toTimeString()
->toDateTimeString()
->toDayDateTimeString()
没有被本地化
and lastly you have to use these parsing letters