here is a little patch to add localization support to the popup datepicker.
You must use jquery ui module to benefit from this patch.
jquery-ui has a great datepicker plugin that is distributed with a large set of pre-defined i18n presets
This patch will load the right i18n preset according to drupal current language (global $language)
IMHO this feature should be part of this module
File attached
You can locate all i18n presets under modules\jquery_ui\jquery.ui\ui\i18n
I also included code changes summary for reference
function date_popup_load() {
...
if (module_exists('jquery_ui')) {
jquery_ui_add('ui.datepicker');
// Add i18n support
global $language;
if ($language->language != 'en') {
drupal_add_js (JQUERY_UI_PATH.'/ui/i18n/ui.datepicker-'.($language->language).'.js');
}
}
...
}
function date_popup_process_date(&$element, $edit = NULL, $date = NULL) {
...
$year_range = date_range_string($range);
// When using jquery ui, we load the language settings
// So we don't need to use drupal translations
if (module_exists('jquery_ui')) {
$settings = array(
//'buttonImage' => base_path() . drupal_get_path('module', 'date_api') ."/images/calendar.png",
//'buttonImageOnly' => TRUE,
'autoPopUp' => 'focus',
'closeAtTop' => FALSE,
'speed' => 'immediate',
'yearRange' => $year_range,
// Custom setting, will be expanded in Drupal.behaviors.date_popup()
'fromTo' => isset($fromto),
);
}
else {
global $language;
$settings = array(
...
'isRTL' => $language->direction == LANGUAGE_RTL,
);
}
...
}
Comments
Comment #1
optalgin commentedAnd here is the file
Comment #2
jedihe commentedIn the meanwhile, there is a workaround that can be implemented in template.php:
I haven't tested it thoroughly, but it works ok with a couple webform nodes on a site I'm developing. This one also depends on jQuery UI
That's it, that way you can avoid patching a module, which is highly discouraged. Hopefully the actual localization support will be added soon.
Comment #3
YK85 commentedsubscribing
Comment #4
dway commentedsubscribing
Comment #5
dway commentedComment #2 is not working in CCK content type forms : the MYTHEME_preprocess_node() function seems not be called in these cases. I've put the code in the MYTHEME_preprocess_page instead and it works fine.
Comment #6
karens commentedThis is not a patch. The current code uses t() on the month and day names. Is that not sufficient? If not, please explain how this will help, make it into a real patch, and it needs to be tested by others who use i18n.
Comment #7
karens commentedComment #8
optalgin commentedThe jQuery date picker has its own translation files, including RTL support and more,
using drupal's t() is not the preferred way here.
My patch includes the jQuery datepicker own translation files (user need to download from jquery ui site)
and by this uses the full i18n features of the datepicker widget.
I am sorry but I cannot produce a patch file, I attached my code and made it as clear as I can see original post
Comment #9
webflo commentedI rerolled this patch from #1 with some modifications. Localization is handeld by jquery.ui module. Please review.
Comment #10
mvc#975320: Date picker not translated was just committed, which solves half this problem. rerolled with just the second half for 6.x-2.x-dev.
Comment #11
damienmckennaUnfortunately the D6 branch is no longer supported.