Revision #4 has been created by jpablo on Jan 23, 2012, 6:17:06 AM with the memo:
Forum post added
« previous (#3)
How to handle decimal separators (e.g comma instead of dot) for l18n
Yii i18n does not cover decimal format. Some languages like Spanish (I live in Argentina) uses comma ',' instead of dot '.' as decimal separator.
A localized web app should:
1- Display decimal values with the local decimal separator.
2- Allow entering decimal values with the local decimal separator.
Yii does not provides a way to do it, there is an extesion to solve this situation (decimali18nbehavior), but it has a couple of severe issues: User input is transformed to DB format using 'beforeSave', that's after rules validation. Every number validation will fail because Yii will try to validate as a number with dot separator a value with comma separator. By the other hand, decimali18nbehavior formats the decimal values before displaying usign the afterFind event. That's prevents to be able to make any math operation on the values. In other word, un version is made too late, and the other conversion is made too early.
[...]I know that it's not an elegant solution, but as far as I know there is no way to override a core class reusing the original class code. If anyone has any idea to improve this approach just post a message.