如何在cakephp中以俄语显示月份名称
how to display month names in russian in cakephp
我需要用俄语显示月份名称,是否足以更改 defaultLocale
值?
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'ru_RU')
这似乎不起作用,因为 <?= h($news->created->format('d F, Y')) ?>
显示 01 October, 2016
我需要在其他地方进行更改吗?
就所需的配置更改而言,更改语言环境就足够了,但是为了获得本地化输出,您必须使用正确的语言环境感知格式化方法,即 i18nFormat()
。
需要注意的是,此方法使用的是 ICU 格式化模式,而不是标准的 PHP 模式,请参阅:https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
长话短说,要获得 d F, Y
的本地化变体,请使用
$news->created->i18nFormat('dd MMMM, yyyy')
对于 ru_RU
这应该 return 01 октября, 2016
.
另见
我需要用俄语显示月份名称,是否足以更改 defaultLocale
值?
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'ru_RU')
这似乎不起作用,因为 <?= h($news->created->format('d F, Y')) ?>
显示 01 October, 2016
我需要在其他地方进行更改吗?
就所需的配置更改而言,更改语言环境就足够了,但是为了获得本地化输出,您必须使用正确的语言环境感知格式化方法,即 i18nFormat()
。
需要注意的是,此方法使用的是 ICU 格式化模式,而不是标准的 PHP 模式,请参阅:https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
长话短说,要获得 d F, Y
的本地化变体,请使用
$news->created->i18nFormat('dd MMMM, yyyy')
对于 ru_RU
这应该 return 01 октября, 2016
.
另见