Hi everyone,

I'm using a german translation of Drupal. Webform is fully translated, the months are showing up right, but in the E-Mail confirmation the months aren't translated. I tried "Locale" and "String Overrides" - no success. Anyone any suggestion?

Greetings from Germany,

towlie

Don't forget to bring a towel!

CommentFileSizeAuthor
#10 webform-date.patch489 bytesdayre
#5 webform-375874-5.patch722 bytesdjalloway
#1 date.inc_.patch510 bytesAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Title: Wrong language in E-Mail » Use Drupal's date_format function to theme dates in mails
Version: 6.x-2.4 » 6.x-2.6
Component: Translation » Code
Status: Active » Needs review
FileSize
510 bytes

I believe that's the same issue I stumbled upon. However, it can be resolved with a simple patch. In date.inc (theme_webform_mail_date) instead of using PHP's date() function Drupal's date_format() function should be used. Patch file is attached, please review. Thanks.

towlie’s picture

Status: Needs review » Fixed

Works great! Thanks a lot!
Should be added to the next release. (Maybe someone should check it in an english version as well.)

quicksketch’s picture

Status: Fixed » Reviewed & tested by the community

Ah, great. Thanks mglanznig! I'm moving this to patch, RTBC, so I remember to add it.

towlie’s picture

Version: 6.x-2.6 » 6.x-2.7
Status: Reviewed & tested by the community » Active

Same problem now in the new version. I fixed the date.inc again but the patch doesn't work...

djalloway’s picture

FileSize
722 bytes

The code is good, but the patch file seems to be broken.
It is trying to remove the correct line and adding the old one.
Try this patch, should work fine.

towlie’s picture

Status: Active » Fixed

It works fine :)
Thanks!

djalloway’s picture

Status: Fixed » Reviewed & tested by the community

The patch still needs to be committed, so we'll leave the status as RTBC for now.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

Committed to all versions.

Status: Fixed » Closed (fixed)

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

dayre’s picture

FileSize
489 bytes

That patch has an error. Caused big headaches for our users....

It's calling format_date, but not passing in the correct timezone offset (0), so format_date assumes the user want's the site timezone (which is likely not GMT = 0).

To reproduce the error:

  1. Set date form component to GMT
  2. Set site timezone to America/Vancovuer
  3. Create a form entry using the date: 1954-08-03
  4. Form e-mail will show up as 1954-08-02 (- 1 day)

Attached is a new patch...

dayre’s picture

Status: Closed (fixed) » Patch (to be ported)

oops... forgot to change status

quicksketch’s picture

Version: 6.x-2.7 » 6.x-2.9
Status: Patch (to be ported) » Fixed

Thank dayre, committed to 2.x versions.

Status: Fixed » Closed (fixed)

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

foripepe’s picture

Version: 6.x-2.9 » 5.x-2.9
Status: Closed (fixed) » Active

Please, fix it in the 5.x-2.9 too.
Thanks.

quicksketch’s picture

Status: Active » Fixed

It is fixed already in 2.x, we just need to make a new release (it will be in 2.10).

foripepe’s picture

Please, do it. You can help a lot for people using date field with mails.

Status: Fixed » Closed (fixed)

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

FTF’s picture

Version: 5.x-2.9 » 6.x-2.9
Status: Closed (fixed) » Active

When you will put out new fixed release? It's very annoying bug :-(

quicksketch’s picture

Status: Active » Closed (fixed)

Anytime after #604958: %profile and %server default values broken is fixed. Seems like there are plenty of solutions, we need to find the correct one and apply it.

Jorrit’s picture

Version: 6.x-2.9 » 6.x-2.10
Priority: Normal » Major
Status: Closed (fixed) » Active

I think patch #10 was incorrect, because I am now experiencing that one-day-back error with timezone Europe/Amsterdam. It used to work because the timezone offset of strtotime() and format_date were cancelling each other. The patch caused format_date to assume GMT, while strtotime still used the system wide timezone.

The following would be better (note the +000):

$timestamp = strtotime($data[0] .'/'. $data[1] .'/'. $data[2].' +000');
$format = webform_date_format('medium');
$output .= ' '. format_date($timestamp, 'custom', $format, 0);

Edit:
One additional thought: as an internal check to see whether the right date is output, it is perhaps wise to check the hour + minute result of the format_date function. It should be 00:00:

$timestamp = strtotime($data[0] .'/'. $data[1] .'/'. $data[2].' +000');
if (format_date($timestamp, 'custom', 'H:i', 0) != '00:00') {
die('There are problems');
}
$format = webform_date_format('medium');
$output .= ' '. format_date($timestamp, 'custom', $format, 0);
quicksketch’s picture

strtotime() should always be in UTC I believe. But considering there are a hundred different ways that the timezone might be set somehow. The current patch should work for most users.

In Webform 3.x, we've fixed this by introducing a dedicated function webform_strtotime(), which uses the same approach Date module provides to force the timezone to UTC before running strtotime:

function webform_strtotime($date) {
  $current_tz = date_default_timezone_get();
  date_default_timezone_set('UTC');
  $timestamp = strtotime($date);
  date_default_timezone_set($current_tz);
  return $timestamp;
}

So in short my recommendation is upgrading to Webform 3.x, I'm not sure this will be correct in 2.10.

Jorrit’s picture

At http://nl2.php.net/strtotime I read: "This function will use the TZ environment variable (if available) to calculate the timestamp."

I will upgrade asap.

quicksketch’s picture

Another alternative is just installing the Date project, which sets the timezone to UTC for you. Though really I'd just recommend upgrading :-)

sreynen’s picture

Status: Active » Closed (fixed)

#21 suggests this issue is fixed, not active.