Adds multi language support for notifications.
This commit is contained in:
parent
e0645b41d3
commit
79cdd94833
|
@ -19,7 +19,7 @@
|
||||||
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
|
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
|
||||||
<script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
|
<script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
|
||||||
<script src="interface_config.js?v=5"></script>
|
<script src="interface_config.js?v=5"></script>
|
||||||
<script src="libs/app.bundle.js?v=10"></script>
|
<script src="libs/app.bundle.js?v=11"></script>
|
||||||
|
|
||||||
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
|
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
|
||||||
<link rel="stylesheet" href="css/font.css?v=6"/>
|
<link rel="stylesheet" href="css/font.css?v=6"/>
|
||||||
|
|
|
@ -108,7 +108,13 @@
|
||||||
"notify": {
|
"notify": {
|
||||||
"disconnected": "disconnected",
|
"disconnected": "disconnected",
|
||||||
"moderator": "Moderator rights granted !",
|
"moderator": "Moderator rights granted !",
|
||||||
"connected": "connected"
|
"connected": "connected",
|
||||||
|
"somebody": "Somebody",
|
||||||
|
"me": "Me",
|
||||||
|
"focus": "Conference focus",
|
||||||
|
"focusFail": "__component__ not available - retry in __ms__ sec",
|
||||||
|
"grantedTo": "Moderator rights granted to __to__!",
|
||||||
|
"grantedToUnknown": "Moderator rights granted to $t(somebody)!"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1625,9 +1625,9 @@ function onMucLeft(jid) {
|
||||||
console.log('left.muc', jid);
|
console.log('left.muc', jid);
|
||||||
var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
|
var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
|
||||||
'>.displayname').html();
|
'>.displayname').html();
|
||||||
messageHandler.notify(displayName || 'Somebody',
|
messageHandler.notify(displayName,'notify.somebody', "Somebody",
|
||||||
'disconnected',
|
'disconnected',
|
||||||
'disconnected');
|
'notify.disconnected', "disconnected");
|
||||||
// Need to call this with a slight delay, otherwise the element couldn't be
|
// Need to call this with a slight delay, otherwise the element couldn't be
|
||||||
// found for some reason.
|
// found for some reason.
|
||||||
// XXX(gp) it works fine without the timeout for me (with Chrome 38).
|
// XXX(gp) it works fine without the timeout for me (with Chrome 38).
|
||||||
|
@ -1659,8 +1659,9 @@ function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
|
||||||
|
|
||||||
if (isModerator) {
|
if (isModerator) {
|
||||||
Authentication.closeAuthenticationWindow();
|
Authentication.closeAuthenticationWindow();
|
||||||
messageHandler.notify(
|
messageHandler.notify(null, "notify.me",
|
||||||
'Me', 'connected', 'Moderator rights granted !');
|
'Me', 'connected', "notify.moderator",
|
||||||
|
'Moderator rights granted !');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1704,9 +1705,9 @@ function onPasswordReqiured(callback) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function onMucEntered(jid, id, displayName) {
|
function onMucEntered(jid, id, displayName) {
|
||||||
messageHandler.notify(displayName || 'Somebody',
|
messageHandler.notify(displayName,'notify.somebody', "Somebody",
|
||||||
'connected',
|
'connected',
|
||||||
'connected');
|
'notify.connected', "connected");
|
||||||
|
|
||||||
// Add Peer's container
|
// Add Peer's container
|
||||||
VideoLayout.ensurePeerContainerExists(jid,id);
|
VideoLayout.ensurePeerContainerExists(jid,id);
|
||||||
|
@ -1721,14 +1722,22 @@ function onMucRoleChanged(role, displayName) {
|
||||||
VideoLayout.showModeratorIndicator();
|
VideoLayout.showModeratorIndicator();
|
||||||
|
|
||||||
if (role === 'moderator') {
|
if (role === 'moderator') {
|
||||||
var displayName = displayName;
|
var messageKey, messageOptions = {};
|
||||||
if (!displayName) {
|
var lDisplayName = displayName;
|
||||||
displayName = 'Somebody';
|
if (!lDisplayName) {
|
||||||
|
lDisplayName = 'Somebody';
|
||||||
|
messageKey = "notify.grantedToUnknown";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
messageKey = "notify.grantedTo";
|
||||||
|
messageOptions = {to: displayName};
|
||||||
}
|
}
|
||||||
messageHandler.notify(
|
messageHandler.notify(
|
||||||
displayName,
|
displayName,'notify.somebody', "Somebody",
|
||||||
'connected',
|
'connected', messageKey,
|
||||||
'Moderator rights granted to ' + displayName + '!');
|
'Moderator rights granted to ' + lDisplayName + '!',
|
||||||
|
messageOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5520,13 +5529,32 @@ var messageHandler = (function(my) {
|
||||||
messageHandler.openMessageDialog(title, message);
|
messageHandler.openMessageDialog(title, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
my.notify = function(displayName, cls, message) {
|
my.notify = function(displayName, displayNameKey, displayNameDefault,
|
||||||
|
cls, messageKey, messageDefault, messageArguments) {
|
||||||
|
var displayNameSpan = '<span class="nickname" ';
|
||||||
|
if(displayName)
|
||||||
|
{
|
||||||
|
displayNameSpan += ">" + displayName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
displayNameSpan += "data-i18n='" + displayNameKey +
|
||||||
|
"'>" + APP.translation.translateString(displayNameKey, null,
|
||||||
|
{defaultValue: displayNameDefault});
|
||||||
|
}
|
||||||
|
displayNameSpan += "</span>";
|
||||||
|
var lMessageArguments = messageArguments;
|
||||||
|
if(!messageArguments)
|
||||||
|
lMessageArguments = {};
|
||||||
|
lMessageArguments.defaultValue = messageDefault;
|
||||||
toastr.info(
|
toastr.info(
|
||||||
'<span class="nickname">' +
|
displayNameSpan + '<br>' +
|
||||||
displayName +
|
'<span class=' + cls + ' data-i18n="' + messageKey + '"' +
|
||||||
'</span><br>' +
|
(messageArguments?
|
||||||
'<span class=' + cls + '>' +
|
" i18n-options='" + JSON.stringify(messageArguments) + "'"
|
||||||
message +
|
: "") + ">" +
|
||||||
|
APP.translation.translateString(messageKey, null,
|
||||||
|
lMessageArguments) +
|
||||||
'</span>');
|
'</span>');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7507,7 +7535,7 @@ var VideoLayout = (function (my) {
|
||||||
"top");
|
"top");
|
||||||
videoMutedSpan.appendChild(mutedIndicator);
|
videoMutedSpan.appendChild(mutedIndicator);
|
||||||
//translate texts for muted indicator
|
//translate texts for muted indicator
|
||||||
APP.translation.translateElement($('#' + videoSpanId + " > i"));
|
APP.translation.translateElement($('#' + videoSpanId + " > span > i"));
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoLayout.updateMutePosition(videoSpanId);
|
VideoLayout.updateMutePosition(videoSpanId);
|
||||||
|
@ -11443,13 +11471,13 @@ module.exports = {
|
||||||
options.lng = lang;
|
options.lng = lang;
|
||||||
i18n.init(options, initCompleted);
|
i18n.init(options, initCompleted);
|
||||||
},
|
},
|
||||||
translateString: function (key, cb) {
|
translateString: function (key, cb, defaultValue) {
|
||||||
if(!cb)
|
if(!cb)
|
||||||
return i18n.t(key);
|
return i18n.t(key, defaultValue);
|
||||||
|
|
||||||
if(initialized)
|
if(initialized)
|
||||||
{
|
{
|
||||||
cb(i18n.t(key));
|
cb(i18n.t(key, defaultValue));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -14506,11 +14534,13 @@ var Moderator = {
|
||||||
var waitMs = getNextErrorTimeout();
|
var waitMs = getNextErrorTimeout();
|
||||||
console.error("Focus error, retry after " + waitMs, error);
|
console.error("Focus error, retry after " + waitMs, error);
|
||||||
// Show message
|
// Show message
|
||||||
APP.UI.messageHandler.notify(
|
APP.UI.messageHandler.notify( null, "notify.focus",
|
||||||
'Conference focus', 'disconnected',
|
'Conference focus', 'disconnected',"notify.focusFail",
|
||||||
Moderator.getFocusComponent() +
|
Moderator.getFocusComponent() +
|
||||||
' not available - retry in ' +
|
' not available - retry in ' +
|
||||||
(waitMs / 1000) + ' sec');
|
(waitMs / 1000) + ' sec',
|
||||||
|
{component: Moderator.getFocusComponent(),
|
||||||
|
ms: (waitMs / 1000)});
|
||||||
// Reset response timeout
|
// Reset response timeout
|
||||||
getNextTimeout(true);
|
getNextTimeout(true);
|
||||||
window.setTimeout(
|
window.setTimeout(
|
||||||
|
|
|
@ -390,9 +390,9 @@ function onMucLeft(jid) {
|
||||||
console.log('left.muc', jid);
|
console.log('left.muc', jid);
|
||||||
var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
|
var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
|
||||||
'>.displayname').html();
|
'>.displayname').html();
|
||||||
messageHandler.notify(displayName || 'Somebody',
|
messageHandler.notify(displayName,'notify.somebody', "Somebody",
|
||||||
'disconnected',
|
'disconnected',
|
||||||
'disconnected');
|
'notify.disconnected', "disconnected");
|
||||||
// Need to call this with a slight delay, otherwise the element couldn't be
|
// Need to call this with a slight delay, otherwise the element couldn't be
|
||||||
// found for some reason.
|
// found for some reason.
|
||||||
// XXX(gp) it works fine without the timeout for me (with Chrome 38).
|
// XXX(gp) it works fine without the timeout for me (with Chrome 38).
|
||||||
|
@ -424,8 +424,9 @@ function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
|
||||||
|
|
||||||
if (isModerator) {
|
if (isModerator) {
|
||||||
Authentication.closeAuthenticationWindow();
|
Authentication.closeAuthenticationWindow();
|
||||||
messageHandler.notify(
|
messageHandler.notify(null, "notify.me",
|
||||||
'Me', 'connected', 'Moderator rights granted !');
|
'Me', 'connected', "notify.moderator",
|
||||||
|
'Moderator rights granted !');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,9 +470,9 @@ function onPasswordReqiured(callback) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function onMucEntered(jid, id, displayName) {
|
function onMucEntered(jid, id, displayName) {
|
||||||
messageHandler.notify(displayName || 'Somebody',
|
messageHandler.notify(displayName,'notify.somebody', "Somebody",
|
||||||
'connected',
|
'connected',
|
||||||
'connected');
|
'notify.connected', "connected");
|
||||||
|
|
||||||
// Add Peer's container
|
// Add Peer's container
|
||||||
VideoLayout.ensurePeerContainerExists(jid,id);
|
VideoLayout.ensurePeerContainerExists(jid,id);
|
||||||
|
@ -486,14 +487,22 @@ function onMucRoleChanged(role, displayName) {
|
||||||
VideoLayout.showModeratorIndicator();
|
VideoLayout.showModeratorIndicator();
|
||||||
|
|
||||||
if (role === 'moderator') {
|
if (role === 'moderator') {
|
||||||
var displayName = displayName;
|
var messageKey, messageOptions = {};
|
||||||
if (!displayName) {
|
var lDisplayName = displayName;
|
||||||
displayName = 'Somebody';
|
if (!lDisplayName) {
|
||||||
|
lDisplayName = 'Somebody';
|
||||||
|
messageKey = "notify.grantedToUnknown";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
messageKey = "notify.grantedTo";
|
||||||
|
messageOptions = {to: displayName};
|
||||||
}
|
}
|
||||||
messageHandler.notify(
|
messageHandler.notify(
|
||||||
displayName,
|
displayName,'notify.somebody', "Somebody",
|
||||||
'connected',
|
'connected', messageKey,
|
||||||
'Moderator rights granted to ' + displayName + '!');
|
'Moderator rights granted to ' + lDisplayName + '!',
|
||||||
|
messageOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,13 +149,32 @@ var messageHandler = (function(my) {
|
||||||
messageHandler.openMessageDialog(title, message);
|
messageHandler.openMessageDialog(title, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
my.notify = function(displayName, cls, message) {
|
my.notify = function(displayName, displayNameKey, displayNameDefault,
|
||||||
|
cls, messageKey, messageDefault, messageArguments) {
|
||||||
|
var displayNameSpan = '<span class="nickname" ';
|
||||||
|
if(displayName)
|
||||||
|
{
|
||||||
|
displayNameSpan += ">" + displayName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
displayNameSpan += "data-i18n='" + displayNameKey +
|
||||||
|
"'>" + APP.translation.translateString(displayNameKey, null,
|
||||||
|
{defaultValue: displayNameDefault});
|
||||||
|
}
|
||||||
|
displayNameSpan += "</span>";
|
||||||
|
var lMessageArguments = messageArguments;
|
||||||
|
if(!messageArguments)
|
||||||
|
lMessageArguments = {};
|
||||||
|
lMessageArguments.defaultValue = messageDefault;
|
||||||
toastr.info(
|
toastr.info(
|
||||||
'<span class="nickname">' +
|
displayNameSpan + '<br>' +
|
||||||
displayName +
|
'<span class=' + cls + ' data-i18n="' + messageKey + '"' +
|
||||||
'</span><br>' +
|
(messageArguments?
|
||||||
'<span class=' + cls + '>' +
|
" i18n-options='" + JSON.stringify(messageArguments) + "'"
|
||||||
message +
|
: "") + ">" +
|
||||||
|
APP.translation.translateString(messageKey, null,
|
||||||
|
lMessageArguments) +
|
||||||
'</span>');
|
'</span>');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1422,7 +1422,7 @@ var VideoLayout = (function (my) {
|
||||||
"top");
|
"top");
|
||||||
videoMutedSpan.appendChild(mutedIndicator);
|
videoMutedSpan.appendChild(mutedIndicator);
|
||||||
//translate texts for muted indicator
|
//translate texts for muted indicator
|
||||||
APP.translation.translateElement($('#' + videoSpanId + " > i"));
|
APP.translation.translateElement($('#' + videoSpanId + " > span > i"));
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoLayout.updateMutePosition(videoSpanId);
|
VideoLayout.updateMutePosition(videoSpanId);
|
||||||
|
|
|
@ -82,13 +82,13 @@ module.exports = {
|
||||||
options.lng = lang;
|
options.lng = lang;
|
||||||
i18n.init(options, initCompleted);
|
i18n.init(options, initCompleted);
|
||||||
},
|
},
|
||||||
translateString: function (key, cb) {
|
translateString: function (key, cb, defaultValue) {
|
||||||
if(!cb)
|
if(!cb)
|
||||||
return i18n.t(key);
|
return i18n.t(key, defaultValue);
|
||||||
|
|
||||||
if(initialized)
|
if(initialized)
|
||||||
{
|
{
|
||||||
cb(i18n.t(key));
|
cb(i18n.t(key, defaultValue));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -231,11 +231,13 @@ var Moderator = {
|
||||||
var waitMs = getNextErrorTimeout();
|
var waitMs = getNextErrorTimeout();
|
||||||
console.error("Focus error, retry after " + waitMs, error);
|
console.error("Focus error, retry after " + waitMs, error);
|
||||||
// Show message
|
// Show message
|
||||||
APP.UI.messageHandler.notify(
|
APP.UI.messageHandler.notify( null, "notify.focus",
|
||||||
'Conference focus', 'disconnected',
|
'Conference focus', 'disconnected',"notify.focusFail",
|
||||||
Moderator.getFocusComponent() +
|
Moderator.getFocusComponent() +
|
||||||
' not available - retry in ' +
|
' not available - retry in ' +
|
||||||
(waitMs / 1000) + ' sec');
|
(waitMs / 1000) + ' sec',
|
||||||
|
{component: Moderator.getFocusComponent(),
|
||||||
|
ms: (waitMs / 1000)});
|
||||||
// Reset response timeout
|
// Reset response timeout
|
||||||
getNextTimeout(true);
|
getNextTimeout(true);
|
||||||
window.setTimeout(
|
window.setTimeout(
|
||||||
|
|
Loading…
Reference in New Issue