mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Make sure popup notifications are fully in recipient's language
"Message from" and "Linked entries" were in sender's language
This commit is contained in:
parent
da2291be12
commit
be93c24def
@ -258,6 +258,41 @@ class Translation
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translates a phrase according to the given user's language preference,
|
||||||
|
* which may be different from the current user.
|
||||||
|
*
|
||||||
|
* @param int $account_id
|
||||||
|
* @param string $message
|
||||||
|
* @param array $vars =null vars to replace the placeholders, or null for none
|
||||||
|
*/
|
||||||
|
static function translate_as($account_id, $message, $vars=null)
|
||||||
|
{
|
||||||
|
if(!is_numeric($account_id))
|
||||||
|
{
|
||||||
|
return static::translate($message, $vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
$preferences = new Preferences($account_id);
|
||||||
|
$prefs = $preferences->read();
|
||||||
|
if($prefs['common']['lang'] != $GLOBALS['egw_info']['user']['preferences']['common']['lang'])
|
||||||
|
{
|
||||||
|
$old_lang = self::$userlang;
|
||||||
|
$GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $prefs['common']['lang'];
|
||||||
|
$apps = array_keys(self::$loaded_apps);
|
||||||
|
self::init(true);
|
||||||
|
self::add_app($apps);
|
||||||
|
}
|
||||||
|
$phrase = static::translate($message, $vars);
|
||||||
|
if($old_lang)
|
||||||
|
{
|
||||||
|
$GLOBALS['egw_info']['user']['preferences']['common']['lang'] = $old_lang;
|
||||||
|
self::init(true);
|
||||||
|
self::add_app($apps);
|
||||||
|
}
|
||||||
|
return $phrase;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds translations for (multiple) application(s)
|
* Adds translations for (multiple) application(s)
|
||||||
*
|
*
|
||||||
|
@ -172,7 +172,7 @@ class notifications_popup implements notifications_iface {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if(count($rendered_links) > 0) {
|
if(count($rendered_links) > 0) {
|
||||||
return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
|
return Api\Html::hr().Api\Html::bold(Api\Translation::translate_as($this->recipient->account_id,'Linked entries:')).$newline.implode($newline,$rendered_links);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class notifications_popup implements notifications_iface {
|
|||||||
$newline = "<br />";
|
$newline = "<br />";
|
||||||
|
|
||||||
$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
|
$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
|
||||||
$infos[] = lang('Message from').': '.$sender;
|
$infos[] = Api\Translation::translate_as($this->recipient->account_id, 'Message from').': '.$sender;
|
||||||
if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
|
if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
|
||||||
return implode($newline,$infos);
|
return implode($newline,$infos);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user