Where can I translate the "time ago" string from the heartbeat settings page "Show the time of action in message displays"? Generally the terms hours/days/time and "ago" seems to be translated (by already translated Drupal strings, I guess) but I cannot find the string from Hearbeat itself. The problem is that it displays: "1 Stunde vor" but in German it should be: "vor 1 Stunde". Can you give me a short hint or should I open a new issue for that?

Comments

design.er’s picture

Thank you for opening this! :)

Stalski’s picture

This is fixed in next snapshot, release to 4.10 will come soon.
See http://drupal.org/cvs?commit=408280

Stalski’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

mstef’s picture

I'm having this problem to with a module of my own...

You can translate the "ago" part, but what about 'hours' 'minutes' days' etc??

Stalski’s picture

Hey Mike,

It seems to me that it could be my mistake. format_interval function can take the third argument $langcode. However, when i checked the format_interval, which delegates to format_plural which in his turn delegates to the t function, it is supposed to take the global language as translatable language context. My function to theme the time is like this:

/**
 *
 * @return String Formatted date.
 */
function _theme_time_ago($time) {
  return t('@time ago', array('@time' => format_interval(($_SERVER['REQUEST_TIME'] - $time), 1)));
}

Sidenote: in heartbeat this is fixed to this issue, not in the last stable release i think. So in 10 it will be available.

Now in custom module, it depends ofcourse on how you trigger it.
So within drupal the format_interval would have to translate the units (being year, month, etc ...).
I tested it on the demosite and translated "@count hours" and "@count ago". This is visible in dutch (sorry for that), but proves it should work as long as you use the heartbeat helper function or the format_interval itself.
http://heartbeat.menhireffect.be/nl

Are you helped with this?

mstef’s picture

Thanks, but not really. I know that format_interval takes a langcode but what should be passed?

It's not a big deal. I just made the time format admin-optional. If they need translation, they can use regular time instead. That should work.. (just to remind, this isn't about heartbeat).

Thanks again

Stalski’s picture

Yes, i know it's not about heartbeat ;) that's why i am not reopening this.

But as i see it, as long as you use format_interval without the langcode OR putting the $GLOBALS['language']->language in there manually, it should work. Meaning all parts of the generated time are translatable. Or they should be. I had that problem once in a site too and it happened to be that the global $language was incorrect.

regards

mstef’s picture

you'd like format_interval would do that for you...

Stalski’s picture

I am not sure what you mean by this.
I mean that format_interval does that exactly, without having to pass the language. (well the t-function does, where it's delegating too)