R
R
reuse2013-04-16 15:46:18
linux
reuse, 2013-04-16 15:46:18

Month names not inflected (centos+php)?

The names of the months in Russian and Ukrainian are not inclined:

  • instead of "April 16" - "April 16"
  • and instead of "16 April" - "16 April"

Server :
CentOS release 6.4 (Final)
PHP Version 5.3.3
Test script :
<?php
echo setlocale(LC_ALL, 'ru_RU.utf8'); // аналогично и echo setlocale(LC_ALL, 'uk_UA.utf8');
echo strftime("%d %B");

Result :
ru_RU.utf8
16 Апрель

Required :
ru_RU.utf8
16 Апреля

Tell me how you can cure?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
adebt, 2013-04-16
@reuse

“being your own evil pinocchio” is to produce crutches, instead of using already implemented functionality
On the question itself:
an excerpt from the CentOS Ukrainian locale file

% Initially alt_digits was supposed to hold alternative symbols for _digits_,
% corresponding to %O modified conversion specification.
% Although in Ukrainian language alternate _names_ are used instead of digits.
% We'll use this keyword to present a list of month names in proper form for
% date, see mon. (%Om)
%
% This hack is dedicated for months it won't work for other %O* modifiers
% (weeks, days etc).
%

In short, the essence is that for the correct declination of months in the strftime function, you need to use the %Om modifier instead of the %B modifier . As a result, the date from April 16, 2013, 16:22 changed to April 16, 2013, 16:22

E
egorinsk, 2013-04-16
@egorinsk

If you need to display dates in Russian in the application, I would write my own function. To use strftime for this is to be an evil pinocchio to yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question