Use correct plural form and add special strings for tomorrow and today

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-04-26 09:27:55 +02:00
parent f43e7a9405
commit 6c28c4ac8b
No known key found for this signature in database
GPG key ID: E166FD8976B3BAC8
2 changed files with 14 additions and 2 deletions

View file

@ -60,7 +60,19 @@ class Notifier implements INotifier {
switch ($notification->getSubject()) {
// Deal with known subjects
case 'pwd_exp_warn_days':
$notification->setParsedSubject($l->t('Your password will expire within %s day(s).', $notification->getSubjectParameters()));
$params = $notification->getSubjectParameters();
$days = (int) $params[0];
if ($days === 2) {
$notification->setParsedSubject($l->t('Your password will expire tomorrow.', $days));
} else if ($days === 1) {
$notification->setParsedSubject($l->t('Your password will expire today.', $days));
} else {
$notification->setParsedSubject($l->n(
'Your password will expire within %n day.',
'Your password will expire within %n days.',
$days
));
}
return $notification;
default:

View file

@ -683,7 +683,7 @@ class User {
->setUser($uid)
->setDateTime($currentDateTime)
->setObject('pwd_exp_warn', $uid)
->setSubject('pwd_exp_warn_days', [strval(ceil($secondsToExpiry / 60 / 60 / 24))])
->setSubject('pwd_exp_warn_days', [(int) ceil($secondsToExpiry / 60 / 60 / 24)])
;
$this->notificationManager->notify($notification);
}