torchbox/wagtail — pull request #68 by spapas (2014-02-18 11:08:56+00:00)
Title: Add support for USE_L10N=True

This allows wagtail to be used when USE_L10N=True. It also adds support for translations of the jquery datepicker sice L10N and I18N go together for the datepicker.

It defines two new components on edit_handlers.py: LocalizedDateInput and LocalizedTimeInput. The first one is a normal DateInput having the localize attribute set to True, while the LocalizedTimeInput can parse times in 24h format (since parsing localized 12h format times doesn't seem that easy). FORM_FIELD_OVERRIDES will use these new components when USE_L10N=True or else we will fall back to the Friendly date and time.

Instead of always forcing the ISO yy-mm-dd format, localized dates will be used (meaning in the format of dd/mm/yy for EU dates and mm/dd/yy for US dates). This is a common requirement from most people that have to work with ISO dates.

However, one thing to notice is that django had bad behavior when I was trying to parse localized greek dates. It seems that the localized DATE_INPUT_FORMAT has not been defined for greece (and I suspect that this may be true for other locales as well). So Django instead used the US and was not able to parse a greek date in the format dd/mm/yy !

To resolve this a custom smart node name "get_date_format_override" was defined. This smart node would check the django/conf/locale/xx/formats.py to see if DATE_INPUT_FORMATS is actually defined. If not it will return a date input format that should used by the jquery datepicker instead of the localized one (in our case it returns the ISO format).

Concerning the L10N of the jquery datepicker component, a number of files is defined in http://jquery-ui.googlecode.com/svn/tags/latest/ui/i18n/ each one with L10N and I18N options for each locale. A template tag named {% get_localized_datepicker_js %} has been defined that returns the correct '