Best way to translate month names [closed] Best way to translate month names [closed] codeigniter codeigniter

Best way to translate month names [closed]


You can use str_ireplace() with arrays for names in english, and equivalent for names in turkmen, in same order.

Something like this:

$nmeng = array('january', 'february', ..);$nmtur = array('ocak', 'subat', ...);$dt = 'September 22, 2012';$dt = str_ireplace($nmeng, $nmtur, $dt);


Use setlocale() and strftime ...

On linux run $ locale -a to find out if the needed locale is installed and to grab its name value string.

setlocale(LC_TIME, 'ru_RU');echo strftime('%B %e, %Y', strtotime('2012-09-22 11:21:53'));

Edit:

If you use a windows server, then change %e to %d (%e does not work in windows).

echo strftime('%B %d, %Y', strtotime('2012-09-22 11:21:53'));

For windows, check here to see supported format.


best way to translate month names to put them in language file and call it like read here how to use language files in codeigniter Language library you can use in you project over and over if you have dual language site.

$this->lang->line('September');your english language file $lang['january'] = 'january';$lang['february'] = 'february';...$lang['September'] = 'September';your turkish language file $lang['january'] = 'ocak';$lang['february'] = 'subat';...$lang['September'] = 'Eylül';