Nodir Rashidov
Nodir Rashidov

Reputation: 732

how to display month names in russian in cakephp

I need to display month names in Russian, is it enough to change the defaultLocale value?

'defaultLocale' => env('APP_DEFAULT_LOCALE', 'ru_RU')

This doesnt seem to work, because <?= h($news->created->format('d F, Y')) ?> displays 01 October, 2016

Do I need to make changes anywhere else?

Upvotes: 1

Views: 1008

Answers (1)

ndm
ndm

Reputation: 60473

Changing the locale is enough in terms of configuration changes required, however in order to get localized output, you have to use the proper locale aware formatting methods, that is i18nFormat().

It should be noted that this method uses ICU formatting patterns, not the standard PHP ones, see: https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax

So long story short, to get a localized variant of d F, Y, use

$news->created->i18nFormat('dd MMMM, yyyy')

For ru_RU this should return 01 октября, 2016.

See also

Upvotes: 1

Related Questions