When Drupal 6 display time in format "x ago" (for example "3 hours ago"), there are two strings - for singular and plural. Singular string for hours is "1 hour", plural string is "@count hours". My question is - is this a bug? Shouldn't be there "@count hour"?
Today, something strange happened to me. I went back to my site where I posted a comment yesterday around this time. However, in recent comments block, there was my comment marked as "1 hour 15 minutes ago" (in my language, not English - that's important!).
After I checked that time zone, server time and comment time are correct, I started debugging the Drupal. Finally, I found the culprit; it's the method format_interval(). At start of the method, there are strings definitions. For hour it's
'1 hour|@count hours' -
1 hour for singular,
@count hours for plural.
I found out that my comment was posted 21 hours ago and that
locale_get_plural() function returned 0 - which is interpreted as singular.
And that's the problem - in my language we read "21 hour", NOT "21 hourS"! However, the count variable is not used, so for each numeric value read as singular (1, 21, 31, 41, ..., 91, 101, 121, 131, ...) (note: yeah, 11 is not singular in my language), the displayed value will be always 1!
I'm writing about hours, but this is same for all other values - years, weeks, minutes and seconds. Experimentally, I changed translation of "1 hour" to "@count hour" (in my language, not English) and the displayed time become correct. However, this is not clean solution, so my question is: is this a bug? If not, how should I solve this correctly?
- I use Drupal 6
- Happening on my machine (Xubuntu 14.04) and server (some Gentoo)
- My language is Czech