Fix for conversation check in @-reply notification email; i18n cleanup on mail messages: fixed some bad gettext usage, added trans doc comments.

This commit is contained in:
Brion Vibber 2010-04-09 11:36:51 -07:00
parent f4ad0acd84
commit 6fb60fb57f
3 changed files with 53 additions and 26 deletions

View File

@ -699,6 +699,27 @@ class Notice extends Memcached_DataObject
return $ids; return $ids;
} }
/**
* Is this notice part of an active conversation?
*
* @return boolean true if other messages exist in the same
* conversation, false if this is the only one
*/
function hasConversation()
{
if (!empty($this->conversation)) {
$conversation = Notice::conversationStream(
$this->conversation,
1,
1
);
if ($conversation->N > 0) {
return true;
}
}
return false;
}
/** /**
* @param $groups array of Group *objects* * @param $groups array of Group *objects*
* @param $recipients array of profile *ids* * @param $recipients array of profile *ids*

View File

@ -170,8 +170,10 @@ function mail_to_user(&$user, $subject, $body, $headers=array(), $address=null)
function mail_confirm_address($user, $code, $nickname, $address) function mail_confirm_address($user, $code, $nickname, $address)
{ {
// TRANS: Subject for address confirmation email
$subject = _('Email address confirmation'); $subject = _('Email address confirmation');
// TRANS: Body for address confirmation email.
$body = sprintf(_("Hey, %s.\n\n". $body = sprintf(_("Hey, %s.\n\n".
"Someone just entered this email address on %s.\n\n" . "Someone just entered this email address on %s.\n\n" .
"If it was you, and you want to confirm your entry, ". "If it was you, and you want to confirm your entry, ".
@ -237,11 +239,13 @@ function mail_subscribe_notify_profile($listenee, $other)
$headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname); $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
$headers['From'] = mail_notify_from(); $headers['From'] = mail_notify_from();
$headers['To'] = $name . ' <' . $listenee->email . '>'; $headers['To'] = $name . ' <' . $listenee->email . '>';
// TRANS: Subject of new-subscriber notification e-mail
$headers['Subject'] = sprintf(_('%1$s is now listening to '. $headers['Subject'] = sprintf(_('%1$s is now listening to '.
'your notices on %2$s.'), 'your notices on %2$s.'),
$other->getBestName(), $other->getBestName(),
common_config('site', 'name')); common_config('site', 'name'));
// TRANS: Main body of new-subscriber notification e-mail
$body = sprintf(_('%1$s is now listening to your notices on %2$s.'."\n\n". $body = sprintf(_('%1$s is now listening to your notices on %2$s.'."\n\n".
"\t".'%3$s'."\n\n". "\t".'%3$s'."\n\n".
'%4$s'. '%4$s'.
@ -255,10 +259,13 @@ function mail_subscribe_notify_profile($listenee, $other)
common_config('site', 'name'), common_config('site', 'name'),
$other->profileurl, $other->profileurl,
($other->location) ? ($other->location) ?
// TRANS: Profile info line in new-subscriber notification e-mail
sprintf(_("Location: %s"), $other->location) . "\n" : '', sprintf(_("Location: %s"), $other->location) . "\n" : '',
($other->homepage) ? ($other->homepage) ?
// TRANS: Profile info line in new-subscriber notification e-mail
sprintf(_("Homepage: %s"), $other->homepage) . "\n" : '', sprintf(_("Homepage: %s"), $other->homepage) . "\n" : '',
($other->bio) ? ($other->bio) ?
// TRANS: Profile info line in new-subscriber notification e-mail
sprintf(_("Bio: %s"), $other->bio) . "\n\n" : '', sprintf(_("Bio: %s"), $other->bio) . "\n\n" : '',
common_config('site', 'name'), common_config('site', 'name'),
common_local_url('emailsettings')); common_local_url('emailsettings'));
@ -287,9 +294,11 @@ function mail_new_incoming_notify($user)
$headers['From'] = $user->incomingemail; $headers['From'] = $user->incomingemail;
$headers['To'] = $name . ' <' . $user->email . '>'; $headers['To'] = $name . ' <' . $user->email . '>';
// TRANS: Subject of notification mail for new posting email address
$headers['Subject'] = sprintf(_('New email address for posting to %s'), $headers['Subject'] = sprintf(_('New email address for posting to %s'),
common_config('site', 'name')); common_config('site', 'name'));
// TRANS: Body of notification mail for new posting email address
$body = sprintf(_("You have a new posting address on %1\$s.\n\n". $body = sprintf(_("You have a new posting address on %1\$s.\n\n".
"Send email to %2\$s to post new messages.\n\n". "Send email to %2\$s to post new messages.\n\n".
"More email instructions at %3\$s.\n\n". "More email instructions at %3\$s.\n\n".
@ -414,6 +423,7 @@ function mail_send_sms_notice_address($notice, $smsemail, $incomingemail)
$headers['From'] = ($incomingemail) ? $incomingemail : mail_notify_from(); $headers['From'] = ($incomingemail) ? $incomingemail : mail_notify_from();
$headers['To'] = $to; $headers['To'] = $to;
// TRANS: Subject line for SMS-by-email notification messages
$headers['Subject'] = sprintf(_('%s status'), $headers['Subject'] = sprintf(_('%s status'),
$other->getBestName()); $other->getBestName());
@ -440,11 +450,11 @@ function mail_confirm_sms($code, $nickname, $address)
$headers['From'] = mail_notify_from(); $headers['From'] = mail_notify_from();
$headers['To'] = $nickname . ' <' . $address . '>'; $headers['To'] = $nickname . ' <' . $address . '>';
// TRANS: Subject line for SMS-by-email address confirmation message
$headers['Subject'] = _('SMS confirmation'); $headers['Subject'] = _('SMS confirmation');
// FIXME: I18N // TRANS: Main body heading for SMS-by-email address confirmation message
$body = sprintf(_("%s: confirm you own this phone number with this code:"), $nickname);
$body = "$nickname: confirm you own this phone number with this code:";
$body .= "\n\n"; $body .= "\n\n";
$body .= $code; $body .= $code;
$body .= "\n\n"; $body .= "\n\n";
@ -464,10 +474,12 @@ function mail_confirm_sms($code, $nickname, $address)
function mail_notify_nudge($from, $to) function mail_notify_nudge($from, $to)
{ {
common_init_locale($to->language); common_init_locale($to->language);
// TRANS: Subject for 'nudge' notification email
$subject = sprintf(_('You\'ve been nudged by %s'), $from->nickname); $subject = sprintf(_('You\'ve been nudged by %s'), $from->nickname);
$from_profile = $from->getProfile(); $from_profile = $from->getProfile();
// TRANS: Body for 'nudge' notification email
$body = sprintf(_("%1\$s (%2\$s) is wondering what you are up to ". $body = sprintf(_("%1\$s (%2\$s) is wondering what you are up to ".
"these days and is inviting you to post some news.\n\n". "these days and is inviting you to post some news.\n\n".
"So let's hear from you :)\n\n". "So let's hear from you :)\n\n".
@ -514,10 +526,12 @@ function mail_notify_message($message, $from=null, $to=null)
} }
common_init_locale($to->language); common_init_locale($to->language);
// TRANS: Subject for direct-message notification email
$subject = sprintf(_('New private message from %s'), $from->nickname); $subject = sprintf(_('New private message from %s'), $from->nickname);
$from_profile = $from->getProfile(); $from_profile = $from->getProfile();
// TRANS: Body for direct-message notification email
$body = sprintf(_("%1\$s (%2\$s) sent you a private message:\n\n". $body = sprintf(_("%1\$s (%2\$s) sent you a private message:\n\n".
"------------------------------------------------------\n". "------------------------------------------------------\n".
"%3\$s\n". "%3\$s\n".
@ -565,8 +579,10 @@ function mail_notify_fave($other, $user, $notice)
common_init_locale($other->language); common_init_locale($other->language);
// TRANS: Subject for favorite notification email
$subject = sprintf(_('%s (@%s) added your notice as a favorite'), $bestname, $user->nickname); $subject = sprintf(_('%s (@%s) added your notice as a favorite'), $bestname, $user->nickname);
// TRANS: Body for favorite notification email
$body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s". $body = sprintf(_("%1\$s (@%7\$s) just added your notice from %2\$s".
" as one of their favorites.\n\n" . " as one of their favorites.\n\n" .
"The URL of your notice is:\n\n" . "The URL of your notice is:\n\n" .
@ -622,24 +638,25 @@ function mail_notify_attn($user, $notice)
common_init_locale($user->language); common_init_locale($user->language);
if ($notice->conversation != $notice->id) { if ($notice->hasConversation()) {
$conversationEmailText = "The full conversation can be read here:\n\n". $conversationUrl = common_local_url('conversation',
"\t%5\$s\n\n "; array('id' => $notice->conversation)).'#notice-'.$notice->id;
$conversationUrl = common_local_url('conversation', // TRANS: Line in @-reply notification e-mail. %s is conversation URL.
array('id' => $notice->conversation)).'#notice-'.$notice->id; $conversationEmailText = sprintf(_("The full conversation can be read here:\n\n".
} else { "\t%s"), $conversationUrl) . "\n\n";
$conversationEmailText = "%5\$s"; } else {
$conversationUrl = null; $conversationEmailText = '';
} }
$subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname); $subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname);
// TRANS: Body of @-reply notification e-mail.
$body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n". $body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
"The notice is here:\n\n". "The notice is here:\n\n".
"\t%3\$s\n\n" . "\t%3\$s\n\n" .
"It reads:\n\n". "It reads:\n\n".
"\t%4\$s\n\n" . "\t%4\$s\n\n" .
$conversationEmailText . "%5\$s" .
"You can reply back here:\n\n". "You can reply back here:\n\n".
"\t%6\$s\n\n" . "\t%6\$s\n\n" .
"The list of all @-replies for you here:\n\n" . "The list of all @-replies for you here:\n\n" .
@ -652,7 +669,7 @@ function mail_notify_attn($user, $notice)
common_local_url('shownotice', common_local_url('shownotice',
array('notice' => $notice->id)),//%3 array('notice' => $notice->id)),//%3
$notice->content,//%4 $notice->content,//%4
$conversationUrl,//%5 $conversationEmailText,//%5
common_local_url('newnotice', common_local_url('newnotice',
array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6 array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6
common_local_url('replies', common_local_url('replies',

View File

@ -543,18 +543,7 @@ class NoticeListItem extends Widget
function showContext() function showContext()
{ {
$hasConversation = false; if ($this->notice->hasConversation()) {
if (!empty($this->notice->conversation)) {
$conversation = Notice::conversationStream(
$this->notice->conversation,
1,
1
);
if ($conversation->N > 0) {
$hasConversation = true;
}
}
if ($hasConversation) {
$conv = Conversation::staticGet( $conv = Conversation::staticGet(
'id', 'id',
$this->notice->conversation $this->notice->conversation