Send notifications with the language of the recipient
This commit is contained in:
@@ -117,15 +117,17 @@ class Config extends Base
|
|||||||
'fr_FR' => 'fr',
|
'fr_FR' => 'fr',
|
||||||
'it_IT' => 'it',
|
'it_IT' => 'it',
|
||||||
'hu_HU' => 'hu',
|
'hu_HU' => 'hu',
|
||||||
|
'nl_NL' => 'nl',
|
||||||
'pl_PL' => 'pl',
|
'pl_PL' => 'pl',
|
||||||
'pt_BR' => 'pt-br',
|
'pt_BR' => 'pt-br',
|
||||||
'ru_RU' => 'ru',
|
'ru_RU' => 'ru',
|
||||||
|
'sr_Latn_RS' => 'sr',
|
||||||
'fi_FI' => 'fi',
|
'fi_FI' => 'fi',
|
||||||
'sv_SE' => 'sv',
|
'sv_SE' => 'sv',
|
||||||
|
'tr_TR' => 'tr',
|
||||||
'zh_CN' => 'zh-cn',
|
'zh_CN' => 'zh-cn',
|
||||||
'ja_JP' => 'ja',
|
'ja_JP' => 'ja',
|
||||||
'th_TH' => 'th',
|
'th_TH' => 'th',
|
||||||
'tr_TR' => 'tr',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$lang = $this->getCurrentLanguage();
|
$lang = $this->getCurrentLanguage();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
use Core\Session;
|
use Core\Session;
|
||||||
|
use Core\Translator;
|
||||||
use Swift_Message;
|
use Swift_Message;
|
||||||
use Swift_Mailer;
|
use Swift_Mailer;
|
||||||
use Swift_TransportException;
|
use Swift_TransportException;
|
||||||
@@ -36,7 +37,7 @@ class Notification extends Base
|
|||||||
|
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(User::TABLE)
|
->table(User::TABLE)
|
||||||
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email')
|
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email', User::TABLE.'.language')
|
||||||
->eq('notifications_enabled', '1')
|
->eq('notifications_enabled', '1')
|
||||||
->neq('email', '')
|
->neq('email', '')
|
||||||
->notin(User::TABLE.'.id', $exclude_users)
|
->notin(User::TABLE.'.id', $exclude_users)
|
||||||
@@ -45,7 +46,7 @@ class Notification extends Base
|
|||||||
|
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(ProjectPermission::TABLE)
|
->table(ProjectPermission::TABLE)
|
||||||
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email')
|
->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email', User::TABLE.'.language')
|
||||||
->join(User::TABLE, 'id', 'user_id')
|
->join(User::TABLE, 'id', 'user_id')
|
||||||
->eq('project_id', $project_id)
|
->eq('project_id', $project_id)
|
||||||
->eq('notifications_enabled', '1')
|
->eq('notifications_enabled', '1')
|
||||||
@@ -110,19 +111,34 @@ class Notification extends Base
|
|||||||
|
|
||||||
$mailer = Swift_Mailer::newInstance($this->container['mailer']);
|
$mailer = Swift_Mailer::newInstance($this->container['mailer']);
|
||||||
|
|
||||||
$message = Swift_Message::newInstance()
|
foreach ($users as $user) {
|
||||||
|
|
||||||
|
$this->container['logger']->debug('Send email notification to '.$user['username'].' lang='.$user['language']);
|
||||||
|
|
||||||
|
// Use the user language otherwise use the application language (do not use the session language)
|
||||||
|
if (! empty($user['language'])) {
|
||||||
|
Translator::load($user['language']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Translator::load($this->config->get('application_language', 'en_US'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the message
|
||||||
|
$message = Swift_Message::newInstance()
|
||||||
->setSubject($this->getMailSubject($template, $data))
|
->setSubject($this->getMailSubject($template, $data))
|
||||||
->setFrom(array(MAIL_FROM => $author ?: 'Kanboard'))
|
->setFrom(array(MAIL_FROM => $author ?: 'Kanboard'))
|
||||||
->setBody($this->getMailContent($template, $data), 'text/html');
|
->setBody($this->getMailContent($template, $data), 'text/html')
|
||||||
|
->setTo(array($user['email'] => $user['name'] ?: $user['username']));
|
||||||
|
|
||||||
foreach ($users as $user) {
|
|
||||||
$message->setTo(array($user['email'] => $user['name'] ?: $user['username']));
|
|
||||||
$mailer->send($message);
|
$mailer->send($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Swift_TransportException $e) {
|
catch (Swift_TransportException $e) {
|
||||||
$this->container['logger']->error($e->getMessage());
|
$this->container['logger']->error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore locales
|
||||||
|
$this->config->setupTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@ vendor_css="jquery-ui.min chosen.min fullcalendar.min font-awesome.min"
|
|||||||
|
|
||||||
app_js="base board calendar analytic swimlane dashboard budget screenshot"
|
app_js="base board calendar analytic swimlane dashboard budget screenshot"
|
||||||
vendor_js="jquery-1.11.1.min jquery-ui.min jquery.ui.touch-punch.min chosen.jquery.min dropit.min moment.min fullcalendar.min mousetrap.min mousetrap-global-bind.min app.min"
|
vendor_js="jquery-1.11.1.min jquery-ui.min jquery.ui.touch-punch.min chosen.jquery.min dropit.min moment.min fullcalendar.min mousetrap.min mousetrap-global-bind.min app.min"
|
||||||
lang_js="da de es fi fr hu it ja nl pl pt-br ru sv th tr zh-cn"
|
lang_js="da de es fi fr hu it ja nl pl pt-br ru sv sr th tr zh-cn"
|
||||||
|
|
||||||
function merge_css {
|
function merge_css {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user