Using setlocale isn't easy. You have to know the exact name of the language package you want to use,
On ubuntu, to see the list of available options, we can perform "locale -a". To install a new language, "apt-get install language-pack-**-base" and then restart apache.
Showing posts with label Language. Show all posts
Showing posts with label Language. Show all posts
Wednesday, December 9, 2009
Thursday, November 8, 2007
Naming dates (not in english)
It is very common to the problem of wanting to put "November 8, 2007" in a language different from english... In general, a switch is used to translate the name of the month, but there is a much simpler way to do it. PHP brings the ability to configure the location, and then select "regional" settings like language, currency, numbers.
To do so, we must first set the region with setlocale and then we can use the date format with strftime
Example
setlocale(LC_ALL, 'sp');
echo strftime('%d de %B de %Y');
?>
To do so, we must first set the region with setlocale and then we can use the date format with strftime
Example
setlocale(LC_ALL, 'sp');
echo strftime('%d de %B de %Y');
?>
Subscribe to:
Posts (Atom)