How to set russian locale globally

Notice: This thread is very old.
RWNET
Member | 3
+
0
-

Hello everybody!

I recently started to learn Nette Framework but faced with such a problem. I need to set russian locale for dates at least. I get it from DB through presenter and echo with {foreach}. I've tried to write setlocale in bootstrap.php but it doesn't works.

setlocale(LC_ALL, 'ru_RU.UTF8');

In view I bring the data through

{$item->date_end|date:'%d.%B.%Y'}

How to setup russian locale?

Majkl578
Moderator | 1364
+
+3
-

Nette doesn't override locale settings so I assume it should work as long as the locale is set correctly. Also it needs the locale to be properly generated in the target environment, i.e. on Debian you can check generated locales by $ cat /etc/locale.gen | grep -vF '#'.
If you check return value of setlocale, it should indicate whether it was successful or not.

Anyway I'd recommend using more high level API, e.g. ICU API through Intl. You could use IntlDateFormatter like this:

$fmt = new IntlDateFormatter('ru_RU.UTF-8', IntlDateFormatter::LONG, IntlDateFormatter::LONG);
echo $fmt->format(new DateTime());
// outputs: 26 февраля 2016 г., 19:50:14 GMT+1
CZechBoY
Member | 3598
+
0
-

Hi,
what does the setlocale call return? Try another parameters or find what locales are installed on your server.

RWNET
Member | 3
+
0
-

CZechBoY wrote:

Hi,
what does the setlocale call return? Try another parameters or find what locales are installed on your server.

Thank you for reply. I tried to set

setlocale(LC_TIME, '');

to get the default system locale. It returned Russian, but in View date dissapear. By default I saw english date and now nothing.