Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setlocale and strftime not translating month

My code:

setlocale(LC_TIME, 'ca_ES');
echo strftime("%#d %B", strtotime($ticket->date_created));

outputs something like:

28 August

instead of my expectation:

28 Agost

I expect "Agost" because that is Catalan language (set through setlocale()).

Is this how setlocale and strftime is supposed to work?

FYI: My local development machine is Windows 7, set to locale: en-PH

like image 397
Obay Avatar asked Sep 24 '12 13:09

Obay


2 Answers

You need to install the locale you want in your server.

  1. SSH into your server
  2. Check which locales are installed: locale -a
  3. if your locale is not there, install it: sudo locale-gen ca_ES
  4. Update the locales in your server: sudo update-locale
  5. Restart apache for the changes to take effect: sudo service apache2 restart

That is it!

like image 140
Mario Jaramillo Avatar answered Oct 20 '22 03:10

Mario Jaramillo


The locale names are different on Windows. It looks like it's defaulting to English.

Try the full length name (you can try several and it will pick the first found):

setlocale(LC_TIME, 'ca_ES', 'Catalan_Spain', 'Catalan');

You may look at this table, which may be helpful : http://docs.moodle.org/dev/Table_of_locales

like image 42
Sherbrow Avatar answered Oct 20 '22 04:10

Sherbrow