/**
 * Helper function for usage with drupal_map_assoc to display month names.
 */
function map_month($month) {
  return format_date(gmmktime(0, 0, 0, $month, 2, 1970), 'custom', 'M', 0);
}

A format_date() to return a localized month? What about a nice and clean associative array with 12 entries?

CommentFileSizeAuthor
#1 329273-sad-map-month.patch822 bytesdamien tournoud

Comments

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new822 bytes

This very complex new implementation is about 3 times faster than the previous one, and a lot happier (which is priceless).

damien tournoud’s picture

Of course in that case we actually can call t() with a variable, because months names (both in their short and long form) are added manually to the common.po file by the extractor.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Much better :)

drewish’s picture

Status: Reviewed & tested by the community » Needs review

I feel like I had some similar code in the station module and got some crap from translators because there wasn't enough context on some of the strings--though maybe it was just "May"... perhaps we could just cache the results of a call to date()?

damien tournoud’s picture

Status: Needs review » Reviewed & tested by the community

@drewish: that's an other issue completely: format_date() uses t() on the short month names already (technically: the result of date('M')).

You are right that this should be changed, but this is not the issue for this. Back to RTBC, if you don't mind.

drewish’s picture

dmaz, fair enough but i'm not seeing the benefit of bothering with the static caching of the array. it seems like if we're going to bother with caching we should cache the results of the t() calls.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Muchos betteros. Thanks.

Status: Fixed » Closed (fixed)

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