if ($other->hasRight(Right::EMAILONSUBSCRIBE) &&
$listenee->email && $listenee->emailnotifysub) {
+ // use the recipient's localization
+ common_init_locale($listenee->language);
+
$profile = $listenee->getProfile();
$name = $profile->getBestName();
$recipients = $listenee->email;
- // use the recipient's localization
- common_switch_locale($listenee->language);
-
$headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
$headers['From'] = mail_notify_from();
$headers['To'] = $name . ' <' . $listenee->email . '>';
common_local_url('emailsettings'));
// reset localization
- common_switch_locale();
+ common_init_locale();
mail_send($recipients, $headers, $body);
}
}
function mail_notify_nudge($from, $to)
{
- common_switch_locale($to->language);
+ common_init_locale($to->language);
// TRANS: Subject for 'nudge' notification email
$subject = sprintf(_('You\'ve been nudged by %s'), $from->nickname);
$from->nickname,
common_local_url('all', array('nickname' => $to->nickname)),
common_config('site', 'name'));
- common_switch_locale();
+ common_init_locale();
$headers = _mail_prepare_headers('nudge', $to->nickname, $from->nickname);
return true;
}
- common_switch_locale($to->language);
+ common_init_locale($to->language);
// TRANS: Subject for direct-message notification email
$subject = sprintf(_('New private message from %s'), $from->nickname);
$headers = _mail_prepare_headers('message', $to->nickname, $from->nickname);
- common_switch_locale();
+ common_init_locale();
return mail_to_user($to, $subject, $body, $headers);
}
$bestname = $profile->getBestName();
- common_switch_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);
$headers = _mail_prepare_headers('fave', $other->nickname, $user->nickname);
- common_switch_locale();
+ common_init_locale();
mail_to_user($other, $subject, $body, $headers);
}
$err->showPage();
}
-/**
- * This should only be used at setup; processes switching languages
- * to send text to other users should use common_switch_locale().
- *
- * @param string $language Locale language code (optional; empty uses
- * current user's preference or site default)
- * @return mixed success
- */
function common_init_locale($language=null)
{
if(!$language) {
return $ok;
}
-/**
- * Initialize locale and charset settings and gettext with our message catalog,
- * using the current user's language preference or the site default.
- *
- * This should generally only be run at framework initialization; code switching
- * languages at runtime should call common_switch_language().
- *
- * @access private
- */
function common_init_language()
{
mb_internal_encoding('UTF-8');
function mail_facebook_app_removed($user)
{
+ common_init_locale($user->language);
+
$profile = $user->getProfile();
$site_name = common_config('site', 'name');
- common_switch_locale($user->language);
-
$subject = sprintf(
_m('Your %1$s Facebook application access has been disabled.',
$site_name));
"re-installing the %2\$s Facebook application.\n\nRegards,\n\n%2\$s"),
$user->nickname, $site_name);
- common_switch_locale();
+ common_init_locale();
return mail_to_user($user, $subject, $body);
}
function mail_twitter_bridge_removed($user)
{
- $profile = $user->getProfile();
+ common_init_locale($user->language);
- common_switch_locale($user->language);
+ $profile = $user->getProfile();
$subject = sprintf(_m('Your Twitter bridge has been disabled.'));
common_local_url('twittersettings'),
common_config('site', 'name'));
- common_switch_locale();
+ common_init_locale();
return mail_to_user($user, $subject, $body);
}