The date pop-up from the Date module does not get translated.

I had a look at the code in both date.inc from webform and date_popup.module from the date_popup module, but could not easily fix this issue.

  • function theme_webform_date() [file: date.inc] calls date_popup_load(); which only loads the required js files from jquery.ui.
  • overriding the default options for the date picker happens in function date_popup_process_date() [file: date_popup.module]
  • which uses function date_popup_js_settings_id() [file: date_popup.module] to emit the javascript code
  • and which gets called by date_popup_process() [file: date_popup.module]

So it seems more logical to call date_popup_process() instead of date_popup_load(), but the former seems to expect a (CCK) date form element, whereas the webform module does not create a separate element for the date picker.

One solution might be to conform to the interface of date_popup_process() and to create and pass the correct elements. However, another solution might be to copy the inner part of date_popup_process_date() (with the $settings = .. code and the call to date_popup_js_settings_id()) and integrate it correctly in your own code.

My knowledge of both modules is too restricted to confidently patch this myself, but am willing to give it a try, if one of the maintainers can give some hints and advice.

CommentFileSizeAuthor
#5 975320.patch744 bytesmvc
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fietserwin’s picture

Well, it seems that just adding these lines of code after the line thats calls date_popup_load() kind of solves the issue.

// [file: date.inc]
function theme_webform_date($element) {
  ...
  // Add the JavaScript calendar if available (provided by Date module package).
  if (!empty($element['#datepicker']) && function_exists('date_popup_load')) {
    date_popup_load();
    // 4 new lines:
    global $language;
    if ($language->language != 'en') {
      jquery_ui_add("i18n/ui.datepicker-{$language->language}");
    }
    ...
  }
  ...
}

Notes:

  • This may not be the Drupal way to solve it, as no Drupal translations are used and no other Drupal settings overrides are passed in. However for pure translation of the date popup it works fine.
  • No checks are done on the existence of the specific language file, which may lead to a Drupal error message box about a missing file
  • jquery_ui may be expected to be loaded as it is a prerequisite for date_popup module. Moreover, date_popup_load() also uses a call to jquery_ui_add(), so no checks for that are necessary.
quicksketch’s picture

Project: Webform » Date
Version: 6.x-3.4 » 6.x-2.6
Component: Code » Date Popup

This sounds like date_popup module should account for language automatically in date_popup_load(), which Webform utilizes. Then this would add the translation everywhere Date Popup is used rather than just in Webform.

mahnster’s picture

Subscribe. Really do need date popup to be translatable.

Tonnie’s picture

Subscribe

mvc’s picture

Version: 6.x-2.6 » 6.x-2.7
Status: Active » Needs review
FileSize
744 bytes

I agree with quicksketch; this should be done in date.module. Patch attached. This seems to be safe, meaning it does the "right thing" if no such translation file exists.

If you have this problem, please review!

acrollet’s picture

Status: Needs review » Reviewed & tested by the community

Works for Me (TM)

pavloukos’s picture

Patch works fine! Thank you.

malc0mn’s picture

Just to confirm: works like a charm.

mvc’s picture

Version: 6.x-2.7 » 6.x-2.x-dev

patch still applies cleanly against HEAD of 6.x-2.x-dev branch, updating version.

gynekolog’s picture

KarenS’s picture

Status: Reviewed & tested by the community » Fixed

Finally got this committed. Thanks!

http://drupalcode.org/project/date.git/commit/79af565

j0rd’s picture

@KarenS You need to check and see if the file exists first before attempting to add it, otherwise you'll get a file not found error in Drupal. I was thinking of asking the jquery_ui module to do the check, but it makes more sense for them to actual fail, if a file is not found, so I think date module should do the check.

global $language;
if ($language->language != 'en') {
      jquery_ui_add("i18n/ui.datepicker-{$language->language}");
}

Reason this is failing for me, is because I have added the Klingon language to my site, but unfortunately those from Kronos have not yet translated jquery ui.

Also there's another bug related to this implementation, which jquery_ui should fix.
http://drupal.org/node/749126#comment-5973866

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ench0’s picture

Version: 6.x-2.x-dev » 7.x-2.6
Status: Closed (fixed) » Needs review
Issue tags: +localized install, +julio

I see that this is closed and I have the latest 7.x version installed (7.x-2.6) and the problem is still happening.

I am seeing the problem on my Julio site with Bulgarian localization. All modules and core are up-to date.

I have created a replica of the site - PLEASE, use this to access and verify the problem is still happening:
http://velkova.info/105-dev/users
admin:admin - administrator account
editor:editor - content creator account

To reproduce the problem:
- login as editor
- the editor account is a member of the "Parents and Guardians" group (BG="Родители")
- go to the guardians page (http://velkova.info/105-dev/guardians)
- you should see the title change to "Родители"
- try to create a new Event (click on the last item from the top menu "Currently in: Родители Create new Галерия Групова Статия Обява Събитие").
- if you can not read the above then go to this link: "http://velkova.info/105-dev/guardians#overlay=node/add/julio-event%3Fjul..."
- enter any title + content, then chose the "Preview" button at the bottom (BG="Предварителен преглед"). It is the right of the two buttons at the bottom of the page.
======
You should see an error which looks like this:

The value input for field Event date Start date is invalid:
The value Февр. 10 2013 04:24pm does not match the expected format.

podarok’s picture

Version: 7.x-2.6 » 7.x-2.x-dev
Issue summary: View changes
Status: Needs review » Needs work
podarok’s picture

Status: Needs work » Needs review
Issue tags: -localized install, -julio
vijaycs85’s picture

Status: Needs review » Needs work

Ok, seems the implementation in 7.x is very different to the one in 6.x. Needs a new patch.

sjeandroz’s picture

this bug is currently here. Is there a patch to remove it?

Thanks in advanced and sorry for my bad english

mibfire’s picture

I am struggling with this too. Drupal 7.21, Date 7.x-2.7+6-dev

Here you can check: http://www.froccs.hu/hu/online-jelentkezes The page is hungarian but the date popup is english. If i cleared the cache then it would be working for a while, but this is not a solution. Some idea would be great cos this issue is major!

Thx

mibfire’s picture

Priority: Normal » Major
mibfire’s picture

Somehow the Drupal.t wont be called after a certain time.

anpolimus’s picture

Assigned: Unassigned » anpolimus