/**
* 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?
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 329273-sad-map-month.patch | 822 bytes | damien tournoud |
Comments
Comment #1
damien tournoud commentedThis very complex new implementation is about 3 times faster than the previous one, and a lot happier (which is priceless).
Comment #2
damien tournoud commentedOf 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.
Comment #3
catchMuch better :)
Comment #4
drewish commentedI 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()?
Comment #5
damien tournoud commented@drewish: that's an other issue completely:
format_date()usest()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.
Comment #6
drewish commenteddmaz, 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.
Comment #7
dries commentedMuchos betteros. Thanks.