Download & Extend

Use drupals format_date to avoid localization issues

Project:GCal Events
Version:6.x-1.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Instead of using php's date, use drupal's format_date to avoid problems with non-english dates.

Comments

#1

Are there problems with non-english dates? I think php is i18n-aware - I've seen somebody using this application in a foreign language and the month names were changed to match.

The problem with using format_date() will be that it forces you to use the same date format as the rest of drupal, and the same date format in every block. In some cases it might be beneficial to use just the time, or just the month name in one block, and a full date in another. People seem to like customizations of things like this.

I could probably patch it such that the default date is the one selected in drupal admin, but still leave it overridable.

#2

The Drupal API states that format_date can be called with $type = 'custom' and the $format set to a PHP-date compatible string. It would simply be a matter och changing date($timestamp, $format) to format_date($timestamp, 'custom', $format). This should be fully compatible with the current code or am I missing something? The benefit of the change would be that it allows multiple languages on the same drupal site.

#3

Version:6.x-1.4» 6.x-1.x-dev

Hi,
the php date() function does not translate weekdays' and months' names, (e.g. date("F") will output "February" even when drupal is translated). As Joackim said, drupal format_date() can be used as a replacement for php date() using $type='custom'.

So I made a patch that changes the various date() to format_date(), keeping the per-block date format.
I added also various missing t() that I hope will aid the overall module i18n.

P.S.: keep up the good work with this great module! :)

AttachmentSize
gcal_events_module-i18n.diff 15.21 KB

#4

Status:active» needs review

I forgot to change the status of the issue.

#5

Actually, PHP DOES translate dates, as long as you "tell" the script the country and language you want the date for. Check "setlocale" function for details.

#6

How do I use the setlocale function exactly? I have no knowledge of PHP, but I want to display the weekdays and month names in a different language than english. I currently use the 7.x version of the module.

nobody click here