Google Groups

Datefield i18n sorrow


Martimiz Sep 15, 2012 9:10 AM
Posted in group: SilverStripe Core Development
Hi guys

Lately I've been wrestling with the DateField and the jQuery-UI DatePicker in an attempt tu use month shortnames in a different locale (dutch in my case). Numeric dates are not really a problem as long as we stick to the formats in Zend/Date.php (although I haven't tried them all), but character type dates like month shortnames do pose a problem:

First there are 3 separate units that have to work together:
- SilverStripe DateField
- Zend Date (and Locale)
- jQuery UI

Issue 1:
The jQuery-UI datepicker doesn't translate out of the box: DateField wants there to be a framework/thirdparty/jquery-UI/minified/i18n/jquery.ui.datepicker-nl.min.js file (path and filename hardcoded). At the moment they do not exist in SilverStripe but are easily downloaded here: http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/ (or whereelse??).

Issue 2:
The Zend localization files can be found in thirdparty/Zend/Locale/Data/nl.XML Unfortunately, for Dutch at least, the shortnames are different from the ones in jquire-ui, so they'll never validate

Issue 3:
Zend Format uses iconv_strpos($number, $name, 0, 'UTF-8')) !== false) to check if the monthname is part of the Zend list of valid monthnames. Unfortunately this comparison seems to be case sensitive. And unfortunately again, DateField.php wants the first char of every word to be always uppercase (#203):  if(is_string($val)) $val = ucwords(strtolower($val)); probably to make sure en_US dates always validate, but this again breaks Dutch validation

Last but not least: if you set the admin profile to dutch, Datefield will send the Dutch locale to Zend. Bottom line: now you cannot use shortdates or longdates, unless you make sure there is a jquery localization file, it is equal to the Zend version, and you disable the DatField ucword setting.

Maybe a small issue for most en_US people, still it took me quite a couple of hours, and I'd like to streamline this for SilverStripe. So how can we best do this, any advice?

Martine