PHP setlocale works. Sometimes.

Von in linux, php

Did you ever face the pro­blem that set­lo­ca­le works like a charm, until you rel­oad the page? In one case it does what it is sup­po­sed to do, the other one it fails and dis­plays the ser­ver fall­back set­ting. Lets have a look at the fol­lo­wing state­ment:

setlocale(LC_ALL, 'ru_RU');

… which should return the cur­rent month in Rus­si­an bey­ond any doubt. It would, but becau­se Rus­si­an was not instal­led on your ser­ver, you did the fol­lo­wing befo­re:

sudo locale-gen ru_RU

I don’t real­ly under­stand why it just works now and then after­wards. But what I do know is, that a reboot of your Apa­che will batt­le the issue. In case you are a fri­end of Nginx (like me) rest­ar­ting the linux ser­ver does the trick, if a “ser­vice nginx restart” didn’t.