Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Instead of using php's date, use drupal's format_date to avoid problems with non-english dates.
Comment | File | Size | Author |
---|---|---|---|
#8 | gcal_events-i18n-support-373071.patch | 6.91 KB | bohemier |
#3 | gcal_events_module-i18n.diff | 15.21 KB | giuppe |
Comments
Comment #1
Se7enLC CreditAttribution: Se7enLC commentedAre 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.
Comment #2
Joackim CreditAttribution: Joackim commentedThe 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.
Comment #3
giuppe CreditAttribution: giuppe commentedHi,
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! :)
Comment #4
giuppe CreditAttribution: giuppe commentedI forgot to change the status of the issue.
Comment #5
nachenko CreditAttribution: nachenko commentedActually, 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.
Comment #6
Metasequoia CreditAttribution: Metasequoia commentedHow 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.
Comment #7
jdwfly CreditAttribution: jdwfly commentedWill look at soon.
Comment #8
bohemier CreditAttribution: bohemier commentedRecreated the patch for 7.x-1.x-dev