laravel - formatLocalized 总是以英文给出结果
问题描述
如果我使用$post->created_at->formatLocalized('%A %e %B')
结果总是英文,即使我设置locale
为'nl'
in config/app
。
我尝试添加\Carbon\Carbon::setLocale(config('app.locale'));
并AppServiceProvider
运行php artisan optimize:clear
但没有运气。
解决方案
你可以通过这种方式在你的 Carbon 上设置语言环境Russian
:
@php
\Carbon\Carbon::setLocale('ru');
@endphp
{{ $post->created_at->translatedFormat('%A %e %B') }}
推荐阅读
- c# - VSTHRD010:访问项目只能在主线程上完成
- r - UseMethod(“group_by_”)中的错误:没有适用于“group_by_”的方法应用于“list”类的对象
- ms-access - access中所有科目满分中少数科目满分之和
- ruby-on-rails - 将表单发送到同一页面后,GET请求参数消失
- sql - 如何使用排序顺序列对层次结构进行排序
- c# - IRouter接口中的GetVirtualPath方法有什么用
- react-native - 键盘启动时反应本机标题被切断
- java - 错误在自定义键类上找不到哈希方法
- numpy - 如何使用布尔数组跳过数组中元素的昂贵计算?
- c# - 连接未打开错误 Visual Studio c# OleDB