0

Short story:

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"?

Long story:

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?

Notes

  • I use Drupal 6
  • Happening on my machine (Xubuntu 14.04) and server (some Gentoo)
  • My language is Czech

1 Answer 1

0

The change you have made should work until you download and install an update to the drupal core language file.

The Drupal Localize site would allow you to download an check the latest versions of the core language files to see if the bug also exists latest versions of 6, 7 and 8.

https://localize.drupal.org/translate/languages/cs

Perhaps you could sign up and posting a message into the Czech language forum on the localize site. You can also find out more about contributing on the localize website.

https://localize.drupal.org

1
  • Note: I use a module which automatically downloads and installs localization (modified strings are kept) so it should be updated. Anyway, do you think it's ok to translate (officially) "1 hour" as "@count hour"? My point is that I'm not sure whether it's translation bug or bug in Drupal itself...
    – Neelam
    Jul 26, 2015 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.