Merge pull request #11601 from annando/issue-11594
Issue 11594: Ensure to create notifications in the user language
This commit is contained in:
commit
fd48a8c9ab
2 changed files with 37 additions and 31 deletions
|
@ -57,12 +57,14 @@ function removeme_post(App $a)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$l10n = DI::l10n()->withLang($admin['language']);
|
||||||
|
|
||||||
$email = DI::emailer()
|
$email = DI::emailer()
|
||||||
->newSystemMail()
|
->newSystemMail()
|
||||||
->withMessage(
|
->withMessage(
|
||||||
DI::l10n()->t('[Friendica System Notify]') . ' ' . DI::l10n()->t('User deleted their account'),
|
$l10n->t('[Friendica System Notify]') . ' ' . $l10n->t('User deleted their account'),
|
||||||
DI::l10n()->t('On your Friendica node an user deleted their account. Please ensure that their data is removed from the backups.'),
|
$l10n->t('On your Friendica node an user deleted their account. Please ensure that their data is removed from the backups.'),
|
||||||
DI::l10n()->t('The user id is %d', local_user()))
|
$l10n->t('The user id is %d', local_user()))
|
||||||
->forUser($admin)
|
->forUser($admin)
|
||||||
->withRecipient($admin['email'])
|
->withRecipient($admin['email'])
|
||||||
->build();
|
->build();
|
||||||
|
|
|
@ -32,6 +32,7 @@ use Friendica\Core\Cache\Capability\ICanCache;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
|
use Friendica\Model\User;
|
||||||
use Friendica\Model\Verb;
|
use Friendica\Model\Verb;
|
||||||
use Friendica\Navigation\Notifications\Entity;
|
use Friendica\Navigation\Notifications\Entity;
|
||||||
use Friendica\Network\HTTPException;
|
use Friendica\Network\HTTPException;
|
||||||
|
@ -119,6 +120,9 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user = User::getById($Notification->uid, ['language']);
|
||||||
|
$l10n = $this->l10n->withLang($user['language']);
|
||||||
|
|
||||||
$causer = $author = Contact::getById($Notification->actorId, ['id', 'name', 'url', 'contact-type', 'pending']);
|
$causer = $author = Contact::getById($Notification->actorId, ['id', 'name', 'url', 'contact-type', 'pending']);
|
||||||
if (empty($causer)) {
|
if (empty($causer)) {
|
||||||
$this->logger->info('Causer not found', ['contact' => $Notification->actorId]);
|
$this->logger->info('Causer not found', ['contact' => $Notification->actorId]);
|
||||||
|
@ -127,9 +131,9 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
|
||||||
|
|
||||||
if ($Notification->type === Post\UserNotification::TYPE_NONE) {
|
if ($Notification->type === Post\UserNotification::TYPE_NONE) {
|
||||||
if ($causer['pending']) {
|
if ($causer['pending']) {
|
||||||
$msg = $this->l10n->t('%1$s wants to follow you');
|
$msg = $l10n->t('%1$s wants to follow you');
|
||||||
} else {
|
} else {
|
||||||
$msg = $this->l10n->t('%1$s has started following you');
|
$msg = $l10n->t('%1$s has started following you');
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $causer['name'];
|
$title = $causer['name'];
|
||||||
|
@ -193,40 +197,40 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
|
||||||
case Activity::LIKE:
|
case Activity::LIKE:
|
||||||
switch ($Notification->type) {
|
switch ($Notification->type) {
|
||||||
case Post\UserNotification::TYPE_DIRECT_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s liked your comment on %2$s');
|
$msg = $l10n->t('%1$s liked your comment on %2$s');
|
||||||
break;
|
break;
|
||||||
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s liked your post %2$s');
|
$msg = $l10n->t('%1$s liked your post %2$s');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Activity::DISLIKE:
|
case Activity::DISLIKE:
|
||||||
switch ($Notification->type) {
|
switch ($Notification->type) {
|
||||||
case Post\UserNotification::TYPE_DIRECT_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s disliked your comment on %2$s');
|
$msg = $l10n->t('%1$s disliked your comment on %2$s');
|
||||||
break;
|
break;
|
||||||
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s disliked your post %2$s');
|
$msg = $l10n->t('%1$s disliked your post %2$s');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Activity::ANNOUNCE:
|
case Activity::ANNOUNCE:
|
||||||
switch ($Notification->type) {
|
switch ($Notification->type) {
|
||||||
case Post\UserNotification::TYPE_DIRECT_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s shared your comment %2$s');
|
$msg = $l10n->t('%1$s shared your comment %2$s');
|
||||||
break;
|
break;
|
||||||
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s shared your post %2$s');
|
$msg = $l10n->t('%1$s shared your post %2$s');
|
||||||
break;
|
break;
|
||||||
case Post\UserNotification::TYPE_SHARED:
|
case Post\UserNotification::TYPE_SHARED:
|
||||||
if (($causer['id'] != $author['id']) && ($title != '')) {
|
if (($causer['id'] != $author['id']) && ($title != '')) {
|
||||||
$msg = $this->l10n->t('%1$s shared the post %2$s from %3$s');
|
$msg = $l10n->t('%1$s shared the post %2$s from %3$s');
|
||||||
} elseif ($causer['id'] != $author['id']) {
|
} elseif ($causer['id'] != $author['id']) {
|
||||||
$msg = $this->l10n->t('%1$s shared a post from %3$s');
|
$msg = $l10n->t('%1$s shared a post from %3$s');
|
||||||
} elseif ($title != '') {
|
} elseif ($title != '') {
|
||||||
$msg = $this->l10n->t('%1$s shared the post %2$s');
|
$msg = $l10n->t('%1$s shared the post %2$s');
|
||||||
} else {
|
} else {
|
||||||
$msg = $this->l10n->t('%1$s shared a post');
|
$msg = $l10n->t('%1$s shared a post');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -234,68 +238,68 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow
|
||||||
case Activity::ATTEND:
|
case Activity::ATTEND:
|
||||||
switch ($Notification->type) {
|
switch ($Notification->type) {
|
||||||
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s wants to attend your event %2$s');
|
$msg = $l10n->t('%1$s wants to attend your event %2$s');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Activity::ATTENDNO:
|
case Activity::ATTENDNO:
|
||||||
switch ($Notification->type) {
|
switch ($Notification->type) {
|
||||||
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s does not want to attend your event %2$s');
|
$msg = $l10n->t('%1$s does not want to attend your event %2$s');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Activity::ATTENDMAYBE:
|
case Activity::ATTENDMAYBE:
|
||||||
switch ($Notification->type) {
|
switch ($Notification->type) {
|
||||||
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s maybe wants to attend your event %2$s');
|
$msg = $l10n->t('%1$s maybe wants to attend your event %2$s');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Activity::POST:
|
case Activity::POST:
|
||||||
switch ($Notification->type) {
|
switch ($Notification->type) {
|
||||||
case Post\UserNotification::TYPE_EXPLICIT_TAGGED:
|
case Post\UserNotification::TYPE_EXPLICIT_TAGGED:
|
||||||
$msg = $this->l10n->t('%1$s tagged you on %2$s');
|
$msg = $l10n->t('%1$s tagged you on %2$s');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Post\UserNotification::TYPE_IMPLICIT_TAGGED:
|
case Post\UserNotification::TYPE_IMPLICIT_TAGGED:
|
||||||
$msg = $this->l10n->t('%1$s replied to you on %2$s');
|
$msg = $l10n->t('%1$s replied to you on %2$s');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Post\UserNotification::TYPE_THREAD_COMMENT:
|
case Post\UserNotification::TYPE_THREAD_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s commented in your thread %2$s');
|
$msg = $l10n->t('%1$s commented in your thread %2$s');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Post\UserNotification::TYPE_DIRECT_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s commented on your comment %2$s');
|
$msg = $l10n->t('%1$s commented on your comment %2$s');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Post\UserNotification::TYPE_COMMENT_PARTICIPATION:
|
case Post\UserNotification::TYPE_COMMENT_PARTICIPATION:
|
||||||
case Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION:
|
case Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION:
|
||||||
if (($causer['id'] == $author['id']) && ($title != '')) {
|
if (($causer['id'] == $author['id']) && ($title != '')) {
|
||||||
$msg = $this->l10n->t('%1$s commented in their thread %2$s');
|
$msg = $l10n->t('%1$s commented in their thread %2$s');
|
||||||
} elseif ($causer['id'] == $author['id']) {
|
} elseif ($causer['id'] == $author['id']) {
|
||||||
$msg = $this->l10n->t('%1$s commented in their thread');
|
$msg = $l10n->t('%1$s commented in their thread');
|
||||||
} elseif ($title != '') {
|
} elseif ($title != '') {
|
||||||
$msg = $this->l10n->t('%1$s commented in the thread %2$s from %3$s');
|
$msg = $l10n->t('%1$s commented in the thread %2$s from %3$s');
|
||||||
} else {
|
} else {
|
||||||
$msg = $this->l10n->t('%1$s commented in the thread from %3$s');
|
$msg = $l10n->t('%1$s commented in the thread from %3$s');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
|
||||||
$msg = $this->l10n->t('%1$s commented on your thread %2$s');
|
$msg = $l10n->t('%1$s commented on your thread %2$s');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Post\UserNotification::TYPE_SHARED:
|
case Post\UserNotification::TYPE_SHARED:
|
||||||
if (($causer['id'] != $author['id']) && ($title != '')) {
|
if (($causer['id'] != $author['id']) && ($title != '')) {
|
||||||
$msg = $this->l10n->t('%1$s shared the post %2$s from %3$s');
|
$msg = $l10n->t('%1$s shared the post %2$s from %3$s');
|
||||||
} elseif ($causer['id'] != $author['id']) {
|
} elseif ($causer['id'] != $author['id']) {
|
||||||
$msg = $this->l10n->t('%1$s shared a post from %3$s');
|
$msg = $l10n->t('%1$s shared a post from %3$s');
|
||||||
} elseif ($title != '') {
|
} elseif ($title != '') {
|
||||||
$msg = $this->l10n->t('%1$s shared the post %2$s');
|
$msg = $l10n->t('%1$s shared the post %2$s');
|
||||||
} else {
|
} else {
|
||||||
$msg = $this->l10n->t('%1$s shared a post');
|
$msg = $l10n->t('%1$s shared a post');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue