Whenever I add a new translation for an existing node, a new Heartbeat message is created which leads to duplicated messages, one message for each translation. Can Heartbeat handle it the same way like i18n module, i.e. depending on the language settings from the Drupal backend and the language chosen by the user (in the language picker for example) only the messages matching the language are displaced or otherwise the default version as fallback (if a translation in the selected language is not available)?

Comments

Stalski’s picture

Status: Active » Needs work

this could be done yes. dont know if it the best or easiest way. In your case, you are adding translations later on. I'll give it some thought.

Stalski’s picture

At the time of logging - and if the drupal setting for languages for that node type is "" - then the logging should only happen for that specific language only. That's the most reasonable solution i can come up with.

Stalski’s picture

Status: Needs work » Fixed

committed that sollution. In short, following the drupal way:
If i have a node and their is a language defined (whatever way it is configured) , i use it and log it for that language only. In all other cases i will log the both language because "user updates profile" is the same and has to be translated separately

jaochoo’s picture

Could you elaborate a little bit more detailled how to achieve it? In the meantime I worked on an own solution which is hiding the messages in the theme layer:

function heartbeat_example_heartbeat_theme_alter(&$messages, HeartbeatAccess $stream) {
  global $language;
  
  foreach ($messages as $key => $message) {

    if ($message->nid > 0) { // message is a node
      $node = node_load($message->nid);
	  
      // we only display those nodes whose language match the selected language
      // or those which are not translated yet
      if ($node->language == $language->language || $node->tnid == 0) {
	 
         $message->message = "This is just an example.";
	  
	  } else {
	    $message->message = "";
		unset($messages[$key]);
      }
	  
    } else {
	// message is a shout
         $message->message = "This is a shout";
	}
  }
}

Furthermore disabling creation of a message whenever a node gets updated/edited (because a new language is considered as a node update).

However, if your solution is at the message layer already it seems to be better. So could you please elaborate how to use it? Is there a new dev-version which includes it?

Stalski’s picture

You wont need this hook for this anymore (besides it's the wrong hook. hook_heartbeat_messages_alter would be better).
But as i mentioned above, the fix is committed. So when a language is known on the node (saving for englisch, later a translation, ...) will only log for that language specific. So it's no problem anymore.

Please review the commit (cvs update).

Stalski’s picture

if for some reason, you still need your hook implemenetation, just change the function to messages_alter (they have the same parameters). Buy my guess is that you wont need it anymore.

Stalski’s picture

Status: Fixed » Closed (fixed)
jaochoo’s picture

Category: feature » support
Status: Closed (fixed) » Active

Another related question: When using Node comments to store Heartbeat comments and having multilanguage Nodes, will the comments be synchronized for the translations?

Stalski’s picture

Status: Active » Closed (fixed)

Please dont reopen tickets for questions. The issue queue is hard enough for me to follow. It only causes me to slow down on feature requests and answers.
The answer is : comments will be shown for all languages.