diff --git a/lang/main.json b/lang/main.json
index 86de9cc2d..95f1b6e1b 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -1,5 +1,5 @@
{
- "contactlist": "Participants",
+ "contactlist": "Participants (__pcount__)",
"addParticipants": "Add Participants",
"roomLocked": "Callers must enter a password",
"roomUnlocked": "Anyone with the link can join",
@@ -99,6 +99,7 @@
"cameraDisabled": "Camera is not available",
"micDisabled": "Microphone is not available",
"filmstrip": "Show / hide videos",
+ "profile": "Edit your profile",
"raiseHand": "Raise hand to speak"
},
"bottomtoolbar": {
@@ -135,7 +136,8 @@
"profile": {
"title": "Profile",
"setDisplayNameLabel": "Set your display name",
- "setEmailLabel": "Set your gravatar email"
+ "setEmailLabel": "Set your gravatar email",
+ "setEmailInput": "Enter e-mail"
},
"videothumbnail":
{
@@ -342,7 +344,7 @@
"ATTACHED": "Attached",
"FETCH_SESSION_ID": "Obtaining session-id...",
"GOT_SESSION_ID": "Obtaining session-id... Done",
- "GET_SESSION_ID_ERROR": "Get session-id error: ",
+ "GET_SESSION_ID_ERROR": "Get session-id error: __code__",
"USER_CONNECTION_INTERRUPTED": "__displayName__ is having connectivity issues..."
},
"recording":
diff --git a/lang/readme.md b/lang/readme.md
index 2911c3412..e9b8ca244 100644
--- a/lang/readme.md
+++ b/lang/readme.md
@@ -1,20 +1,20 @@
Jitsi Meet Translation
==========================
-Jitsi Meet uses [i18next](http://i18next.com) library for translation.
-i18next uses separate json files for each language.
+Jitsi Meet uses [i18next](http://i18next.com) library for translation.
+i18next uses separate json files for each language.
Translating Jitsi Meet
======================
-The translation of Jitsi Meet is integrated with Pootle. You can translate Jitsi Meet via our Pootle user interface on
-[http://translate.jitsi.org](http://translate.jitsi.org).
+The translation of Jitsi Meet is integrated with Pootle. You can translate Jitsi Meet via our Pootle user interface on
+[http://translate.jitsi.org](http://translate.jitsi.org).
**WARNING: Please don't create or edit manually the language files! Please use our Pootle user interface!**
Development
===========
If you want to add new functionality for Jitsi Meet and you have texts that need to be translated please use our translation module.
-It is located in modules/translation. You must add key and value in main.json file in English for each translatable text.
+It is located in modules/translation. You must add key and value in main.json file in English for each translatable text.
Than you can use the key to get the translated text for the current language.
**WARNING: Please don't change the other language files except main.json! They must be updated and translated via our Pootle user interface!**
@@ -36,21 +36,19 @@ You can add translatable text in the HTML:
```
APP.translation.generateTranslationHTML("dialog.OK") // returns OK
```
-
+
The value in the options parameter will be added in data-i18n-options attribute of the element.
-
+
**Note:** If you dynamically add HTML elements don't forget to call APP.translation.translateElement(jquery_selector) to translate the text initially.
-* **via Javascript string** - call APP.translation.translateString(key, options). You can use that method to get the translated string in Javascript and then attach it in the HTML.
-
+
```
- APP.translation.translateString("dialog.OK") // returns the value for the key of the current language file. "OK" for example.
+ APP.translation.translateString("dialog.OK") // returns the value for the key of the current language file. "OK" for example.
```
-For the available values of ``options`` parameter for the above methods of translation module see [i18next documentation](http://i18next.com/pages/doc_features).
+For the available values of ``options`` parameter for the above methods of translation module see [i18next documentation](http://i18next.com/pages/doc_features).
**Note:** It is useful to add attributes in the HTML for persistent HTML elements because when the language is changed the text will be automatically translated.
- Otherwise you should call ``APP.translation.translateString`` and manually change the text every time the language is changed.
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index 64690b411..74917a5ef 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -75,17 +75,13 @@ JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
*/
function promptDisplayName() {
let labelKey = 'dialog.enterDisplayName';
- let labelStr = APP.translation.translateString(labelKey);
- let titleStr
- = APP.translation.translateString('dialog.displayNameRequired');
- let defaultNickMsg = APP.translation.translateString("defaultNickname");
let message = (
`
-
+
+ autofocus>
`
);
@@ -94,7 +90,7 @@ function promptDisplayName() {
let buttons = {Ok:true};
let dialog = messageHandler.openDialog(
- titleStr,
+ 'dialog.displayNameRequired',
message,
true,
buttons,
@@ -167,11 +163,10 @@ UI.notifyGracefulShutdown = function () {
* Notify user that reservation error happened.
*/
UI.notifyReservationError = function (code, msg) {
- var title = APP.translation.generateTranslationHTML(
- "dialog.reservationError");
var message = APP.translation.generateTranslationHTML(
"dialog.reservationErrorMsg", {code: code, msg: msg});
- messageHandler.openDialog(title, message, true, {}, () => false);
+ messageHandler.openDialog(
+ "dialog.reservationError", message, true, {}, () => false);
};
/**
@@ -190,9 +185,8 @@ UI.notifyKicked = function () {
UI.notifyConferenceDestroyed = function (reason) {
//FIXME: use Session Terminated from translation, but
// 'reason' text comes from XMPP packet and is not translated
- const title
- = APP.translation.generateTranslationHTML("dialog.sessTerminated");
- messageHandler.openDialog(title, reason, true, {}, () => false);
+ messageHandler.openDialog(
+ "dialog.sessTerminated", reason, true, {}, () => false);
};
/**
@@ -750,8 +744,6 @@ UI.connectionIndicatorShowMore = function(id) {
// FIXME check if someone user this
UI.showLoginPopup = function(callback) {
console.log('password is required');
- let titleKey = "dialog.passwordRequired";
- let titleString = APP.translation.translateString(titleKey);
let message = (
` false);
+ messageHandler.openDialog("dialog.error", message, true, {}, () => false);
};
@@ -924,13 +912,10 @@ UI.notifyConnectionFailed = function (stropheErrorMsg) {
* Notify user that maximum users limit has been reached.
*/
UI.notifyMaxUsersLimitReached = function () {
- var title = APP.translation.generateTranslationHTML(
- "dialog.error");
-
var message = APP.translation.generateTranslationHTML(
"dialog.maxUsersLimitReached");
- messageHandler.openDialog(title, message, true, {}, () => false);
+ messageHandler.openDialog("dialog.error", message, true, {}, () => false);
};
/**
@@ -1046,7 +1031,7 @@ UI.updateDTMFSupport = function (isDTMFSupported) {
* @returns {Promise} Resolved with value - false if the dialog is enabled and
* resolved with true if the dialog is disabled or the feedback was already
* submitted. Rejected if another dialog is already displayed. This values are
- * used to display or not display the thank you dialog from
+ * used to display or not display the thank you dialog from
* conference.maybeRedirectToWelcomePage method.
*/
UI.requestFeedbackOnHangup = function () {
@@ -1191,10 +1176,8 @@ UI.getLargeVideo = function () {
UI.showExtensionRequiredDialog = function (url) {
messageHandler.openMessageDialog(
"dialog.extensionRequired",
- null,
- null,
- APP.translation.generateTranslationHTML(
- "dialog.firefoxExtensionPrompt", {url: url}));
+ "dialog.firefoxExtensionPrompt",
+ {url: url});
};
/**
@@ -1216,9 +1199,7 @@ UI.showExtensionExternalInstallationDialog = function (url) {
messageHandler.openTwoButtonDialog({
titleKey: 'dialog.externalInstallationTitle',
- titleString: '',
msgKey: 'dialog.externalInstallationMsg',
- msgString: '',
leftButtonKey: 'dialog.goToStore',
submitFunction,
loadedFunction: $.noop,
@@ -1263,8 +1244,6 @@ UI.showDeviceErrorDialog = function (micError, cameraError) {
}
}
- let title = getTitleKey();
- let titleMsg = ``;
let cameraJitsiTrackErrorMsg = cameraError
? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
: undefined;
@@ -1318,7 +1297,7 @@ UI.showDeviceErrorDialog = function (micError, cameraError) {
deviceErrorDialog && deviceErrorDialog.close();
deviceErrorDialog = messageHandler.openDialog(
- titleMsg,
+ getTitleKey(),
message,
false,
{Ok: true},
@@ -1342,8 +1321,6 @@ UI.showDeviceErrorDialog = function (micError, cameraError) {
}
);
- APP.translation.translateElement($(".jqibox"));
-
function getTitleKey() {
let title = "dialog.error";
@@ -1369,9 +1346,7 @@ UI.showTrackNotWorkingDialog = function (stream) {
messageHandler.openMessageDialog(
"dialog.error",
stream.isAudioTrack()? "dialog.micNotSendingData" :
- "dialog.cameraNotSendingData",
- null,
- null);
+ "dialog.cameraNotSendingData");
};
UI.updateDevicesAvailability = function (id, devices) {
@@ -1483,12 +1458,11 @@ UI.hideUserMediaPermissionsGuidanceOverlay = function () {
*/
UI.toggleKeyboardShortcutsPanel = function() {
if (!messageHandler.isDialogOpened()) {
- let titleKey = 'keyboardShortcuts.keyboardShortcuts';
- let title = APP.translation.translateString(titleKey);
let msg = $('#keyboard-shortcuts').html();
let buttons = { Close: true };
- messageHandler.openDialog(title, msg, true, buttons);
+ messageHandler.openDialog(
+ 'keyboardShortcuts.keyboardShortcuts', msg, true, buttons);
} else {
messageHandler.closeDialog();
}
diff --git a/modules/UI/authentication/AuthHandler.js b/modules/UI/authentication/AuthHandler.js
index 8ce8246ba..ec224211c 100644
--- a/modules/UI/authentication/AuthHandler.js
+++ b/modules/UI/authentication/AuthHandler.js
@@ -146,16 +146,13 @@ function doXmppAuth (room, lockPassword) {
room.getName(), APP.conference._getConferenceOptions()
);
- loginDialog.displayConnectionStatus(
- APP.translation.translateString('connection.FETCH_SESSION_ID')
- );
+ loginDialog.displayConnectionStatus('connection.FETCH_SESSION_ID');
newRoom.room.moderator.authenticate().then(function () {
connection.disconnect();
loginDialog.displayConnectionStatus(
- APP.translation.translateString('connection.GOT_SESSION_ID')
- );
+ 'connection.GOT_SESSION_ID');
// authenticate conference on the fly
room.join(lockPassword);
@@ -166,11 +163,8 @@ function doXmppAuth (room, lockPassword) {
console.error('Auth on the fly failed', error);
- let errorMsg = APP.translation.translateString(
- 'connection.GET_SESSION_ID_ERROR'
- );
-
- loginDialog.displayError(errorMsg + code);
+ loginDialog.displayError(
+ 'connection.GET_SESSION_ID_ERROR', {code: code});
});
}, function (err) {
loginDialog.displayError(err);
diff --git a/modules/UI/authentication/LoginDialog.js b/modules/UI/authentication/LoginDialog.js
index 6ee3606f3..8eb01d22f 100644
--- a/modules/UI/authentication/LoginDialog.js
+++ b/modules/UI/authentication/LoginDialog.js
@@ -1,4 +1,4 @@
-/* global APP, config */
+/* global $, APP, config */
/**
* Build html for "password required" dialog.
@@ -15,8 +15,7 @@ function getPasswordInputHtml() {
placeholder=${placeholder} autofocus>
`;
+ data-i18n="[placeholder]dialog.userPassword">`;
}
/**
@@ -67,7 +66,7 @@ function LoginDialog(successCallback, cancelCallback) {
value: true
}];
let finishedButtons = [{
- title: APP.translation.translateString('dialog.retry'),
+ title: APP.translation.generateTranslationHTML('dialog.retry'),
value: 'retry'
}];
@@ -79,7 +78,7 @@ function LoginDialog(successCallback, cancelCallback) {
const states = {
login: {
- title: APP.translation.translateString('dialog.passwordRequired'),
+ titleKey: 'dialog.passwordRequired',
html: getPasswordInputHtml(),
buttons: loginButtons,
focus: ':input:first',
@@ -99,13 +98,13 @@ function LoginDialog(successCallback, cancelCallback) {
}
},
connecting: {
- title: APP.translation.translateString('dialog.connecting'),
+ titleKey: 'dialog.connecting',
html: '',
buttons: [],
defaultButton: 0
},
finished: {
- title: APP.translation.translateString('dialog.error'),
+ titleKey: 'dialog.error',
html: '',
buttons: finishedButtons,
defaultButton: 0,
@@ -128,27 +127,31 @@ function LoginDialog(successCallback, cancelCallback) {
/**
* Displays error message in 'finished' state which allows either to cancel
* or retry.
- * @param message the final message to be displayed.
+ * @param messageKey the key to the message to be displayed.
+ * @param options the options to the error message (optional)
*/
- this.displayError = function (message) {
+ this.displayError = function (messageKey, options) {
let finishedState = connDialog.getState('finished');
let errorMessageElem = finishedState.find('#errorMessage');
- errorMessageElem.text(message);
+ errorMessageElem.attr("data-i18n", messageKey);
+
+ APP.translation.translateElement($(errorMessageElem), options);
connDialog.goToState('finished');
};
/**
* Show message as connection status.
- * @param {string} message
+ * @param {string} messageKey the key to the message
*/
- this.displayConnectionStatus = function (message) {
+ this.displayConnectionStatus = function (messageKey) {
let connectingState = connDialog.getState('connecting');
let connectionStatus = connectingState.find('#connectionStatus');
- connectionStatus.text(message);
+ connectionStatus.attr("data-i18n", messageKey);
+ APP.translation.translateElement($(connectionStatus));
};
/**
@@ -202,9 +205,6 @@ export default {
* @returns dialog
*/
showAuthRequiredDialog: function (roomName, onAuthNow) {
- var title = APP.translation.generateTranslationHTML(
- "dialog.WaitingForHost"
- );
var msg = APP.translation.generateTranslationHTML(
"dialog.WaitForHostMsg", {room: roomName}
);
@@ -215,7 +215,7 @@ export default {
var buttons = [{title: buttonTxt, value: "authNow"}];
return APP.UI.messageHandler.openDialog(
- title,
+ "dialog.WaitingForHost",
msg,
true,
buttons,
diff --git a/modules/UI/feedback/FeedbackWindow.js b/modules/UI/feedback/FeedbackWindow.js
index 1a2a375f2..f6254557e 100644
--- a/modules/UI/feedback/FeedbackWindow.js
+++ b/modules/UI/feedback/FeedbackWindow.js
@@ -35,7 +35,6 @@ function toggleStars(starCount) {
* @returns {string} the contructed html string
*/
function createRateFeedbackHTML() {
- let feedbackHelp = APP.translation.translateString('dialog.feedbackHelp');
let starClassName = (interfaceConfig.ENABLE_FEEDBACK_ANIMATION)
? "icon-star-full shake-rotate"
@@ -67,8 +66,8 @@ function createRateFeedbackHTML() {
-
+
`;
}
@@ -147,10 +146,10 @@ export default class Dialog {
this.submitted = false;
this.onCloseCallback = function() {};
- this.setDefoulOptions();
+ this.setDefaultOptions();
}
- setDefoulOptions() {
+ setDefaultOptions() {
var self = this;
this.options = {
diff --git a/modules/UI/invite/AskForPassword.js b/modules/UI/invite/AskForPassword.js
index 47bc5b309..77a27ddf4 100644
--- a/modules/UI/invite/AskForPassword.js
+++ b/modules/UI/invite/AskForPassword.js
@@ -8,12 +8,10 @@ import UIUtil from '../util/UIUtil';
*/
export default function askForPassword () {
let titleKey = "dialog.passwordRequired";
- let passMsg = APP.translation.translateString("dialog.password");
let msgString = `
- `;
+ autofocus>`;
return new Promise(function (resolve, reject) {
APP.UI.messageHandler.openTwoButtonDialog({
titleKey,
diff --git a/modules/UI/invite/Invite.js b/modules/UI/invite/Invite.js
index df5774088..23ebd79ef 100644
--- a/modules/UI/invite/Invite.js
+++ b/modules/UI/invite/Invite.js
@@ -191,8 +191,10 @@ class Invite {
* @param isLocked
*/
setLockedFromElsewhere(isLocked) {
- let oldLockState = this.roomLocker.lockedElsewhere;
- if (oldLockState !== isLocked) {
+ // isLocked can be 1, true or false
+ let newLockState = (isLocked === 1) || isLocked;
+ let oldLockState = this.roomLocker.isLocked;
+ if (oldLockState !== newLockState) {
this.roomLocker.lockedElsewhere = isLocked;
APP.UI.emitEvent(UIEvents.TOGGLE_ROOM_LOCK);
this.updateView();
diff --git a/modules/UI/invite/InviteDialogView.js b/modules/UI/invite/InviteDialogView.js
index 8a2a10eb5..95ee622b6 100644
--- a/modules/UI/invite/InviteDialogView.js
+++ b/modules/UI/invite/InviteDialogView.js
@@ -15,20 +15,15 @@ const States = {
*/
export default class InviteDialogView {
constructor(model) {
- let InviteAttributesKey = 'inviteUrlDefaultMsg';
- let title = APP.translation.translateString(InviteAttributesKey);
-
this.unlockHint = "unlockHint";
this.lockHint = "lockHint";
this.model = model;
if (this.model.inviteUrl === null) {
- this.inviteAttributes = (
- `data-i18n="[value]inviteUrlDefaultMsg" value="${title}"`
- );
+ this.inviteAttributes = `data-i18n="[value]inviteUrlDefaultMsg"`;
} else {
- let encodedInviteUrl = this.model.getEncodedInviteUrl();
- this.inviteAttributes = `value="${encodedInviteUrl}"`;
+ this.inviteAttributes
+ = `value="${this.model.getEncodedInviteUrl()}"`;
}
this.initDialog();
@@ -43,11 +38,7 @@ export default class InviteDialogView {
dialog.submitFunction = this.submitFunction.bind(this);
dialog.loadedFunction = this.loadedFunction.bind(this);
- let titleKey = "dialog.shareLink";
- let titleString = APP.translation.generateTranslationHTML(titleKey);
-
- dialog.titleKey = titleKey;
- dialog.titleString = titleString;
+ dialog.titleKey = "dialog.shareLink";
this.dialog = dialog;
this.dialog.states = this.getStates();
@@ -101,21 +92,20 @@ export default class InviteDialogView {
*/
getStates() {
let {
- titleString
+ titleKey
} = this.dialog;
- let doneKey = 'dialog.done';
- let doneMsg = APP.translation.translateString(doneKey);
+ let doneMsg = APP.translation.generateTranslationHTML('dialog.done');
let states = {};
let buttons = {};
buttons[`${doneMsg}`] = true;
states[States.UNLOCKED] = {
- title: titleString,
+ titleKey,
html: this.getShareLinkBlock() + this.getAddPasswordBlock(),
buttons
};
states[States.LOCKED] = {
- title: titleString,
+ titleKey,
html: this.getShareLinkBlock() + this.getPasswordBlock(),
buttons
};
@@ -128,34 +118,24 @@ export default class InviteDialogView {
* @returns {string}
*/
getShareLinkBlock() {
- let copyKey = 'dialog.copy';
- let copyText = APP.translation.translateString(copyKey);
- let roomLockDescKey = 'dialog.roomLocked';
- let roomLockDesc = APP.translation.translateString(roomLockDescKey);
- let roomUnlockKey = 'roomUnlocked';
- let roomUnlock = APP.translation.translateString(roomUnlockKey);
let classes = 'button-control button-control_light copyInviteLink';
return (
`
-
+
-
+
- ${roomLockDesc}
+
- ${roomUnlock}
+
`
);
@@ -166,27 +146,21 @@ export default class InviteDialogView {
* @returns {string}
*/
getAddPasswordBlock() {
- let addPassKey = 'dialog.addPassword';
- let addPassText = APP.translation.translateString(addPassKey);
- let addKey = 'dialog.add';
- let addText = APP.translation.translateString(addKey);
- let hintKey = 'dialog.createPassword';
- let hintMsg = APP.translation.translateString(hintKey);
let html;
if (this.model.isModerator) {
html = (`
`);
-
- return html;
},
/**
* Adds layout for lock description
*/
getLockDescriptionLayout(key) {
let classes = "input-control__hint input-control_full-width";
- let description = APP.translation.translateString(key);
let padlockSuffix = '';
if (key === this.lockKey) {
padlockSuffix = '-locked';
@@ -130,7 +123,7 @@ var ContactListView = {
return `
- ${description}
+
`;
},
/**
@@ -198,6 +191,7 @@ var ContactListView = {
createDisplayNameParagraph(
isLocal ? interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME : null,
isLocal ? null : interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME));
+ APP.translation.translateElement($(newContact));
if (APP.conference.isLocalId(id)) {
contactlist.prepend(newContact);
diff --git a/modules/UI/toolbars/Toolbar.js b/modules/UI/toolbars/Toolbar.js
index 01c02b31f..05f1fe92c 100644
--- a/modules/UI/toolbars/Toolbar.js
+++ b/modules/UI/toolbars/Toolbar.js
@@ -279,7 +279,6 @@ function showSipNumberInput () {
? config.defaultSipNumber
: '';
let titleKey = "dialog.sipMsg";
- let sipMsg = APP.translation.generateTranslationHTML("dialog.sipMsg");
let msgString = (`
@@ -287,7 +286,6 @@ function showSipNumberInput () {
APP.UI.messageHandler.openTwoButtonDialog({
titleKey,
- titleString: sipMsg,
msgString,
leftButtonKey: "dialog.Dial",
submitFunction: function (e, v, m, f) {
diff --git a/modules/UI/util/JitsiPopover.js b/modules/UI/util/JitsiPopover.js
index 6331c647a..f49c4ea50 100644
--- a/modules/UI/util/JitsiPopover.js
+++ b/modules/UI/util/JitsiPopover.js
@@ -1,22 +1,26 @@
/* global $ */
var JitsiPopover = (function () {
+ /**
+ * The default options
+ */
+ const defaultOptions = {
+ skin: 'white',
+ content: '',
+ hasArrow: true,
+ onBeforePosition: undefined
+ };
+
/**
* Constructs new JitsiPopover and attaches it to the element
* @param element jquery selector
* @param options the options for the popover.
+ * - {Function} onBeforePosition - function executed just before
+ * positioning the popover. Useful for translation.
* @constructor
*/
function JitsiPopover(element, options)
{
- let { skin, content, hasArrow } = options;
- this.options = {};
- this.options.skin = skin || 'white';
- this.options.content = content || '';
- this.options.hasArrow = true;
-
- if (typeof(hasArrow) !== 'undefined') {
- this.options.hasArrow = false;
- }
+ this.options = Object.assign({}, defaultOptions, options);
this.elementIsHovered = false;
this.popoverIsHovered = false;
@@ -86,7 +90,11 @@ var JitsiPopover = (function () {
*/
JitsiPopover.prototype.createPopover = function () {
$("body").append(this.template);
- $(".jitsipopover > .jitsipopover__content").html(this.options.content);
+ let popoverElem = $(".jitsipopover > .jitsipopover__content");
+ popoverElem.html(this.options.content);
+ if(typeof this.options.onBeforePosition === "function") {
+ this.options.onBeforePosition($(".jitsipopover"));
+ }
var self = this;
$(".jitsipopover").on("mouseenter", function () {
self.popoverIsHovered = true;
@@ -136,4 +144,4 @@ var JitsiPopover = (function () {
return JitsiPopover;
})();
-module.exports = JitsiPopover;
\ No newline at end of file
+module.exports = JitsiPopover;
diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.js
index 0a478a599..fcc3b008e 100644
--- a/modules/UI/util/MessageHandler.js
+++ b/modules/UI/util/MessageHandler.js
@@ -29,30 +29,20 @@ var messageHandler = {
*
* @param titleKey the key used to find the translation of the title of the
* message, if a message title is not provided.
- * @param messageKey the key used to find the translation of the message,
- * if a message is not provided.
- * @param title the title of the message. If a falsy value is provided,
- * titleKey will be used to get a title via the translation API.
- * @param message the message to show. If a falsy value is provided,
- * messageKey will be used to get a message via the translation API.
+ * @param messageKey the key used to find the translation of the message
+ * @param i18nOptions the i18n options (optional)
* @param closeFunction function to be called after
* the prompt is closed (optional)
* @return the prompt that was created, or null
*/
- openMessageDialog: function(titleKey, messageKey, title, message,
- closeFunction) {
+ openMessageDialog:
+ function(titleKey, messageKey, i18nOptions, closeFunction) {
if (!popupEnabled)
return null;
- if (!title) {
- title = APP.translation.generateTranslationHTML(titleKey);
- }
- if (!message) {
- message = APP.translation.generateTranslationHTML(messageKey);
- }
-
- return $.prompt(message, {
- title: this._getFormattedTitleString(title),
+ let dialog = $.prompt(
+ APP.translation.generateTranslationHTML(messageKey, i18nOptions), {
+ title: this._getFormattedTitleString(titleKey),
persistent: false,
promptspeed: 0,
classes: this._getDialogClasses(),
@@ -61,12 +51,14 @@ var messageHandler = {
closeFunction(e, v, m, f);
}
});
+ APP.translation.translateElement(dialog, i18nOptions);
+ return dialog;
},
/**
* Shows a message to the user with two buttons: first is given as a
* parameter and the second is Cancel.
*
- * @param titleString the title of the message
+ * @param titleKey the key for the title of the message
* @param msgString the text of the message
* @param persistent boolean value which determines whether the message is
* persistent or not
@@ -84,7 +76,6 @@ var messageHandler = {
openTwoButtonDialog: function(options) {
let {
titleKey,
- titleString,
msgKey,
msgString,
leftButtonKey,
@@ -112,10 +103,7 @@ var messageHandler = {
= APP.translation.generateTranslationHTML("dialog.Cancel");
buttons.push({title: cancelButton, value: false});
- var message = msgString, title = titleString;
- if (titleKey) {
- title = APP.translation.generateTranslationHTML(titleKey);
- }
+ var message = msgString;
if (msgKey) {
message = APP.translation.generateTranslationHTML(msgKey);
}
@@ -125,7 +113,7 @@ var messageHandler = {
}
twoButtonDialog = $.prompt(message, {
- title: this._getFormattedTitleString(title),
+ title: this._getFormattedTitleString(titleKey),
persistent: false,
buttons: buttons,
defaultButton: defaultButton,
@@ -147,6 +135,7 @@ var messageHandler = {
}
}
});
+ APP.translation.translateElement(twoButtonDialog);
return twoButtonDialog;
},
@@ -154,7 +143,7 @@ var messageHandler = {
* Shows a message to the user with two buttons: first is given as a
* parameter and the second is Cancel.
*
- * @param titleString the title of the message
+ * @param titleKey the key for the title of the message
* @param msgString the text of the message
* @param persistent boolean value which determines whether the message is
* persistent or not
@@ -166,13 +155,13 @@ var messageHandler = {
* loaded
* @param closeFunction function to be called on dialog close
*/
- openDialog: function (titleString, msgString, persistent, buttons,
+ openDialog: function (titleKey, msgString, persistent, buttons,
submitFunction, loadedFunction, closeFunction) {
if (!popupEnabled)
return;
let args = {
- title: this._getFormattedTitleString(titleString),
+ title: this._getFormattedTitleString(titleKey),
persistent: persistent,
buttons: buttons,
defaultButton: 1,
@@ -187,7 +176,9 @@ var messageHandler = {
args.closeText = '';
}
- return new Impromptu(msgString, args);
+ let dialog = new Impromptu(msgString, args);
+ APP.translation.translateElement(dialog.getPrompt());
+ return dialog;
},
/**
@@ -195,13 +186,11 @@ var messageHandler = {
*
* @return the title string formatted as a div.
*/
- _getFormattedTitleString(titleString) {
+ _getFormattedTitleString(titleKey) {
let $titleString = $('