Hi,

if not fixed meanwhile, there is the translation of the merge_end_separator / merge_separator missing.
At least the " and " in merge_end_separator needs to be translated ;-)

I found no issue for that, so I guess there is no improvement since 6.x-4.10.

CommentFileSizeAuthor
#8 patch-1007520.patch8.92 KBStalski

Comments

TS79’s picture

... may be some addtional bool settings: merge_end_separator_translation / merge_separator_translation
are benefitial to avoid, that a simple comma (eg. ", ") gets added to translateable strings.
So translated string only has to be used, if these settings are set to TRUE, otherwise current implementation should be used without any translation...

Stalski’s picture

a regular expression checking if a word is alfanumeric or something, could make this work in general.

TS79’s picture

right, the reguar expression is a smart and efficient solution

TS79’s picture

what about separators like single tags (eg "<br />")?

Stalski’s picture

Status: Active » Needs work

committed to be tested!!
The br is a good point. I will wrap it further with html entities so they are dropped out first.

TS79’s picture

Translation works so far.

But messages with transletable concat-args now aleays appear as overwritten (with "revert" link) at /admin/build/heartbeat/list.

Stalski’s picture

That problem does not exist here.
For the other things, they will be included in next commit and release.

Stalski’s picture

Status: Needs work » Needs review
StatusFileSize
new8.92 KB
TS79’s picture

Status: Needs review » Needs work

Another issue I recognised with these 2 seperators.
The spaces before should be left away.
2 Examples for a grouped message with the separators I applied in brackets:

"Some user changed their profile pictures:
User1 [,] User2 [and] User3"

"Some user changed their profile pictures:
User1 [,] User2 [and] 5 more"

I think the spaces, which are not included into the seperators can be eliminated completely.
At least the spaces before merge_seperator have to be eliminated.

Now the 2 examples without any spaces, but a little bit extended separators:

"Some user changed their profile pictures:
User1[, ]User2[and ]User3"

"Some user changed their profile pictures:
User1[, ]User2[and ]5 more"

I think grammar can be applied correct in this way. The advantage of this implementation is, that if you want to show some thumbnail user-pictures instead as grouped variable, you set all seperators to an empty string, add a little maring to the pics and get a listing like on Facebook:

"Some users changed their profile pictures:
Picture1|Picture2|5 more"

The affected code:

heartbeatactivity.inc:

/*
   * Rebuild the message with given candidate variables
   */
  public function create_grouped_message($candidates, $max_items_to_group = 5) {
...
        $i = 1;
        foreach ($unique as $stored_variables) {

          // limit them to the value given by the group variable setting
          if (isset($stored_variables["@". $target])) {
            if ($i == 1) {
              $merged_string .= ' ' . $stored_variables["@". $target];
            }
            elseif ($i < $count && $count > 2) {
              if (!empty($this->template->concat_args['merge_separator_t'])) {
                $merged_string .= ' ' . t($this->template->concat_args['merge_separator']);
              }
              else {
                $merged_string .= ' ' . $this->template->concat_args['merge_separator'];
              }
              $merged_string .= ' ' . $stored_variables["@". $target];
            }
            elseif ($i == $count || $count == 2) {
              if (!empty($this->template->concat_args['merge_end_separator_t'])) {
                $merged_string .= ' ' . t($this->template->concat_args['merge_end_separator']);
              }
              else {
                $merged_string .= ' ' . $this->template->concat_args['merge_end_separator'];
              }
              if (count($remains) >= 1 && $hidden_remains != '') {
                $attributes = array(
                  'attributes' => array(
                    'absolute' => TRUE,
                    'onclick' => 'javascript:$(\'#' . $beat . '-remaining\').toggle(\'slow\'); return false;'),
                    'fragment' => $beat);
                $merged_string .= ' ' . l(t('@num more', array('@num' => count($remains))), $base_url . request_uri(), $attributes);
                $message_extension .= $hidden_remains;
              }
              else {
                $merged_string .= ' ' . $stored_variables["@". $target];
              }
            }
          }
          $i++;
        }
        $message_template = str_replace("%". $placeholder ."%", $merged_string, $message_template);
        if (isset($message_extension)) {
          $message_template .= $message_extension;
        }
      //}
    }
...

TS79’s picture

Sorry, I did not expect your fix some minutes before submission :)

Stalski’s picture

Status: Needs work » Needs review

I know that, but i will not fix that. All people that have it installed now, will loose there separators and their sites would be screwed. I will not provide a update path for this that runs through all the message templates to override them "where in some cases the script might screw up things".

So that is something for drupal7 i will fix, but not in drupal6. It just would break too much.

TS79’s picture

Status: Needs review » Reviewed & tested by the community

yes, i know about the upgrade path problem.

concerning the overwrite problem i posted for the messages, you are right. i needed to export them to include the two new parameter into message config.

so finally there is only one message left with status overwritten: heartbeat_add_comment. i think message definition in heartbeat_heartbeat_message_info() has to be actualized as well.

TS79’s picture

the exported message with the 2 new attributes:

array (
  137 => 
  array (
    'message' => '!username replied on !title:
      <blockquote><p>!comment</p></blockquote>',
    'message_concat' => '!username replied on !title.',
    'message_id' => 'heartbeat_add_comment',
    'concat_args' => 
    array (
      'type' => 'count',
      'group_by' => 'none',
      'group_target' => '',
      'merge_separator' => '',
      'merge_end_separator' => '',
      'merge_separator_t' => '0',
      'merge_end_separator_t' => '0',
    ),
    'description' => 'user replied on some content',
    'perms' => '1',
    'custom' => 1,
    'variables' => 
    array (
      '@username' => '[user:user-name-url]  ',
      '@title' => '[node:title-link]',
      '@comment' => '[comment:comment-body-raw]',
    ),
    'attachments' => 
    array (
    ),
  ),
)
Stalski’s picture

Fixed and committed.

Stalski’s picture

Status: Reviewed & tested by the community » Fixed
TS79’s picture

Version: 6.x-4.10 » 6.x-4.11
Priority: Normal » Minor
Status: Fixed » Needs work

since you changed somethings for separation parsing, there is now the need to export the other messages in heartbeat_heartbeat_message_info() as well. this integrates the new two attributes to them. at the moment all message except the one in last comment (heartbeat_add_comment) are shown as revertable in message list.

rburgundy’s picture

subscribing

Stalski’s picture

Status: Needs work » Closed (fixed)

I reverted so there are no _t variables in the export. You can always create the changed and configured templates as features or use your own templates that do have them.

I skipped the check on merge_seperator_t.
Imo, the default is best as it is now. Most sites are not translatable and the changes are to big to other users.