Fix a bug notifications sidebar in client-side not being translated

This commit is contained in:
Hadi Nategh 2018-01-11 17:23:58 +01:00
parent 6f2f0c4a8d
commit 2bf7597647
3 changed files with 28 additions and 17 deletions

View File

@ -72,7 +72,7 @@ egw.extend('lang', egw.MODULE_GLOBAL, function()
_msg = _msg.toLowerCase();
// search apps in given order for a replacement
var apps = this.lang_order || ['custom', this.getAppName(), 'etemplate', 'common'];
var apps = this.lang_order || ['custom', this.getAppName(), 'etemplate', 'common', 'notifications'];
for(var i = 0; i < apps.length; ++i)
{
if (typeof lang_arr[apps[i]] != "undefined" &&

View File

@ -19,9 +19,16 @@ if ($GLOBALS['egw_info']['user']['apps']['notifications'])
{
$notification_config = Api\Config::read('notifications');
Api\Translation::add_app('notifications');
$langRequire = array (
'app' => 'notifications',
'lang' => Api\Translation::$userlang,
'etag' => Api\Translation::etag('notifications', Api\Translation::$userlang)
);
$popup_poll_interval = empty($notification_config['popup_poll_interval']) ? 60 : $notification_config['popup_poll_interval'];
echo '<script src="'. $GLOBALS['egw_info']['server']['webserver_url']. '/notifications/js/notificationajaxpopup.js?'.
filemtime(EGW_SERVER_ROOT.'/notifications/js/notificationajaxpopup.js'). '" type="text/javascript" id="notifications_script_id" data-poll-interval="'.$popup_poll_interval.'"></script>';
filemtime(EGW_SERVER_ROOT.'/notifications/js/notificationajaxpopup.js').
'" type="text/javascript" id="notifications_script_id" data-poll-interval="'.$popup_poll_interval.
'" data-langRequire="'. htmlspecialchars(json_encode($langRequire)).'"></script>';
echo '
<div id="egwpopup" style="display: none; z-index: 999;">
<div id="egwpopup_header">'.lang('Notifications').

View File

@ -559,20 +559,24 @@
var lab = egw_LAB || $LAB;
var self = notifications;
lab.wait(function(){
if (typeof window.app == 'undefined') window.app = {};
window.app.notifications = new self();
// toggle notifications bar
jQuery('.egwpopup_toggle').click(function(){window.app.notifications.toggle();});
jQuery('#egwpopup_fw_notifications').click(function(){window.app.notifications.toggle();});
jQuery(".egwpopup_deleteall", '#egwpopup').click(function(){
et2_dialog.show_dialog( function(_button){
if (_button == 2) window.app.notifications.delete_all();
},
egw.lang('Are you sure you want to delete all notifications?'),
egw.lang('Delete notifications'),
null, et2_dialog.BUTTON_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw
);
});
jQuery(".egwpopup_seenall", '#egwpopup').click(function(){window.app.notifications.mark_all_seen()});
var langRequire = jQuery('#notifications_script_id').attr('data-langRequire');
egw.langRequire(window, [JSON.parse(langRequire)], function()
{
if (typeof window.app == 'undefined') window.app = {};
window.app.notifications = new self();
// toggle notifications bar
jQuery('.egwpopup_toggle').click(function(){window.app.notifications.toggle();});
jQuery('#egwpopup_fw_notifications').click(function(){window.app.notifications.toggle();});
jQuery(".egwpopup_deleteall", '#egwpopup').click(function(){
et2_dialog.show_dialog( function(_button){
if (_button == 2) window.app.notifications.delete_all();
},
egw.lang('Are you sure you want to delete all notifications?'),
egw.lang('Delete notifications'),
null, et2_dialog.BUTTON_YES_NO, et2_dialog.WARNING_MESSAGE, undefined, egw
);
});
jQuery(".egwpopup_seenall", '#egwpopup').click(function(){window.app.notifications.mark_all_seen()});
}, this);
});
})();