D
D
denism3002021-03-22 10:52:49
MODX
denism300, 2021-03-22 10:52:49

How to overcome error in MODx Could not set the locale?

How to get rid of the error

Could not set the locale. Please check if the locale ru_RU.UTF-8​ exists on your system

in the system settings, the locale is registered ru_RU.UTF-8

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Golyagin, 2021-04-05
@denism300

I looked at my sites - those that are on a regular shared hosting - everything is normal there. Those who are on the VPS are also pouring in there. Reason for the error and solution:
On the server, the locale was en_US.UTF-8 UTF-8
Registered locale en_US.UTF-8 in the modx settings and the error went away
To use ru_RU.UTF-8
Generated two locales on the
[email protected] server: ~# cat /etc/locale.gen | grep -v '#'
en_US.UTF-8 UTF-8
ru_RU.UTF-8 UTF-8
At the same time, I set the Cyrillic locale as the main one, and everything is buzzing.
you can check it like this
[email protected]:~# echo $LANG
If without reconfiguring the server, then set the en_US.UTF-8 locale, and to display dates in Russian, use the snippet:

The dateRU snippet code itself:

<?php
$month_arr = array(
    '01' => 'Января',
    '02' => 'Февраля',
    '03' => 'Марта',
    '04' => 'Апреля',
    '05' => 'Мая',
    '06' => 'Июня',
    '07' => 'Июля',
    '08' => 'Августа',
    '09' => 'Сентября',
    '10' => 'Октября',
    '11' => 'Ноября',
    '12' => 'Декабря'
);

$d = $input;
$month = strftime("%m",$d);
$year = strftime("%Y",$d);
$day = strftime("%d",$d);
$month = $month_arr[$month];

return "$day $month $year";
?>

If, after formatting, instead of the Russian date format, the English date is displayed, then create the setLocale snippet and paste the code:
<?php
setlocale(LC_ALL, "ru_RU.UTF-8");
?>

After inserting this snippet at the beginning of the template, where you want to display the date formatting. If the Russian date is displayed as questions, check the site encoding, it should be the same as in the database (preferably using UTF-8).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question