setlocale() modifies local configuration on the server. An extract on the php documentation for parameters :
* LC_ALL for all of the below
* LC_COLLATE for string comparison, see strcoll()
* LC_CTYPE for character classification and conversion, for example strtoupper()
* LC_MONETARY for localeconv()
* LC_NUMERIC for decimal separator (See also localeconv())
* LC_TIME for date and time formatting with strftime()
* LC_MESSAGES for system responses (available if PHP was compiled with libintl)
It is very useful to adapt Modx in every language. Error strings, date, ect...
For exemple, it permits to format date like this :
/* Set locale to Dutch */
setlocale(LC_ALL, 'nl_NL');
/* Output: vrijdag 22 december 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
/* Set locale to English */
setlocale(LC_ALL, 'en_EN');
/* Output: February 22 december 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
/* Set locale to French */
setlocale(LC_ALL, 'fr_FR');
/* Output: février 22 décembre 1978 */
echo strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
I know it is possible to display monetary symbol but I have not tested it.
In french, it is euro (€). In american, dollar ($).
Many possiblities are offered but I know only a few part.
A restriction of this function (setlocale) is that is not implemented in all PHP function (I think at date()).
Person says to use setlocale(LC_ALL, ’fr_FR.UTF-8’) make formating with accents but I can’t make work this.
Also, it is prefered to use utf8_encode when the PHP function return in ISO format by default.
For localization, french community has found a tip to display correctly some values : put setlocale(LC_ALL, ’fr_FR’) on the top of the language file. With this way, I have found one problem : strftime is not affected by this. It’s for that that I use utf8_encode.
A restriction is that the server must be compiled with the localization asked. Else, localization used is the default (in general english).
I hope this could help you.
Other questions ?