Quote from: Djamoer at Mar 01, 2006, 05:19 AM
Another problem
Be carefull - setting a locale which uses commas instead of dots in numbers may cause a mysql db not to understand the query:
<?php
setlocale(LC_ALL,"pl");
$price = 1234 / 100; // now the price looks like 12,34
$query = mysql_query("SELECT Id FROM table WHERE price=’".$price."’");
?>
Even if there is a price 12.34 - nothing will be found
Do you guys think implementing our own locale will be much better?
All we need to do is to let each language file define the currency code, coma or dot, and bla bla bla. MODx will use this as the output and input. I’ll need to research this further, because it seems to me that the current setlocale functionality is not as mature as the one provided by ASP .Net. Is there any changes in PHP5 for this capability?
So, where do we stand on this issue? One thing to consider if we’re going to take the approach doing our own thing rather than using setlocale() is month names.
Personally, my main interest in locale settings is for date formatting, and one of the things provided by setlocale() is locale-appropriate versions of the month names. For example, if my locale is set for U.S. English, the date format "%e %B %Y" results in a string such as "23 March 2006". If, however, my locale is set for Spanish, that same date format results in "23 marzo 2006".
I’m all for a solution that’s better than setlocale() because of the MySQL issues, but whatever the final solution turns out to be, it needs to accout for the issue of month names as well as simple formatting characters like decimal points, etc.