碳地区格式和下降 [英] Carbon locale format and decline

查看:91
本文介绍了碳地区格式和下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置语言环境的格式? 我有约会:

How I can set locale to carbon with format? I have date:

setlocale(LC_TIME, 'ru_RU.UTF-8');
Carbon::setLocale('ru');
$dt = Carbon::now()->formatLocalized('%d %M');

我通过以下方式获得月份

I Get Month with:

25декабрь

25 декабрь

我如何才能获得语言环境的下降?示例:

How I can get locale with decline? Example:

25декабря

25 декабря

推荐答案

我只是测试了,这将返回25 декабря:

Carbon::now()->formatLocalized('%d %B');

在评论中,您说过您对日期有疑问.尝试从Carbon Docs中修复此问题:

In comments, you've said you have trouble with the date. Try this fix, from the Carbon Docs:

在Linux上

如果您在翻译时遇到问题,请检查系统中安装的语言环境(本地和生产环境).

on Linux If you have trouble with translations, check locales installed in your system (local and production).

locale -a列出已启用的语言环境.

locale -a to list locales enabled.

sudo locale-gen fr_FR.UTF-8以安装新的语言环境.

sudo locale-gen fr_FR.UTF-8 to install a new locale.

sudo dpkg-重新配置区域设置以发布所有启用的区域设置.

sudo dpkg-reconfigure locales to publish all locale enabled.

然后重新启动系统.

http://carbon.nesbot.com/docs/

这篇关于碳地区格式和下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆