Sfoglia il codice sorgente

Uses titleKey to generate title string containing data-i18n attribute.

master
damencho 9 anni fa
parent
commit
0455c26fb2

+ 6
- 9
modules/UI/UI.js Vedi File

@@ -76,12 +76,11 @@ JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
76 76
 function promptDisplayName() {
77 77
     let labelKey = 'dialog.enterDisplayName';
78 78
     let labelStr = APP.translation.translateString(labelKey);
79
-    let titleStr
80
-        = APP.translation.translateString('dialog.displayNameRequired');
81 79
     let defaultNickMsg = APP.translation.translateString("defaultNickname");
82 80
     let message = (
83 81
         `<div class="input-control">
84
-            <label class="input-control__label">${labelStr}</label>
82
+            <label data-i18n="${labelKey}" 
83
+                class="input-control__label">${labelStr}</label>
85 84
             <input name="displayName" type="text"
86 85
                data-i18n="[placeholder]defaultNickname"
87 86
                class="input-control__input"
@@ -94,7 +93,7 @@ function promptDisplayName() {
94 93
     let buttons = {Ok:true};
95 94
 
96 95
     let dialog = messageHandler.openDialog(
97
-        titleStr,
96
+        'dialog.displayNameRequired',
98 97
         message,
99 98
         true,
100 99
         buttons,
@@ -769,7 +768,6 @@ UI.connectionIndicatorShowMore = function(id) {
769 768
 // FIXME check if someone user this
770 769
 UI.showLoginPopup = function(callback) {
771 770
     console.log('password is required');
772
-    let titleKey = "dialog.passwordRequired";
773 771
 
774 772
     let message = (
775 773
         `<input name="username" type="text"
@@ -788,7 +786,7 @@ UI.showLoginPopup = function(callback) {
788 786
     };
789 787
 
790 788
     messageHandler.openTwoButtonDialog({
791
-        titleKey,
789
+        titleKey : "dialog.passwordRequired",
792 790
         msgString: message,
793 791
         leftButtonKey: 'dialog.Ok',
794 792
         submitFunction,
@@ -1493,12 +1491,11 @@ UI.hideUserMediaPermissionsGuidanceOverlay = function () {
1493 1491
  */
1494 1492
 UI.toggleKeyboardShortcutsPanel = function() {
1495 1493
     if (!messageHandler.isDialogOpened()) {
1496
-        let titleKey = 'keyboardShortcuts.keyboardShortcuts';
1497
-        let title = APP.translation.translateString(titleKey);
1498 1494
         let msg = $('#keyboard-shortcuts').html();
1499 1495
         let buttons = { Close: true };
1500 1496
 
1501
-        messageHandler.openDialog(title, msg, true, buttons);
1497
+        messageHandler.openDialog(
1498
+            'keyboardShortcuts.keyboardShortcuts', msg, true, buttons);
1502 1499
     } else {
1503 1500
         messageHandler.closeDialog();
1504 1501
     }

+ 2
- 2
modules/UI/authentication/LoginDialog.js Vedi File

@@ -99,13 +99,13 @@ function LoginDialog(successCallback, cancelCallback) {
99 99
             }
100 100
         },
101 101
         connecting: {
102
-            title: APP.translation.translateString('dialog.connecting'),
102
+            titleKey: 'dialog.connecting',
103 103
             html:   '<div id="connectionStatus"></div>',
104 104
             buttons: [],
105 105
             defaultButton: 0
106 106
         },
107 107
         finished: {
108
-            title: APP.translation.translateString('dialog.error'),
108
+            titleKey: 'dialog.error',
109 109
             html:   '<div id="errorMessage"></div>',
110 110
             buttons: finishedButtons,
111 111
             defaultButton: 0,

+ 11
- 13
modules/UI/invite/InviteDialogView.js Vedi File

@@ -15,8 +15,8 @@ const States = {
15 15
  */
16 16
 export default class InviteDialogView {
17 17
     constructor(model) {
18
-        let InviteAttributesKey = 'inviteUrlDefaultMsg';
19
-        let title = APP.translation.translateString(InviteAttributesKey);
18
+        let inviteAttributesKey = 'inviteUrlDefaultMsg';
19
+        let title = APP.translation.translateString(inviteAttributesKey);
20 20
 
21 21
         this.unlockHint = "unlockHint";
22 22
         this.lockHint = "lockHint";
@@ -24,7 +24,7 @@ export default class InviteDialogView {
24 24
 
25 25
         if (this.model.inviteUrl === null) {
26 26
             this.inviteAttributes = (
27
-                `data-i18n="[value]inviteUrlDefaultMsg" value="${title}"`
27
+                `data-i18n="[value]${inviteAttributesKey}" value="${title}"`
28 28
             );
29 29
         } else {
30 30
             let encodedInviteUrl = this.model.getEncodedInviteUrl();
@@ -43,11 +43,7 @@ export default class InviteDialogView {
43 43
         dialog.submitFunction = this.submitFunction.bind(this);
44 44
         dialog.loadedFunction = this.loadedFunction.bind(this);
45 45
 
46
-        let titleKey = "dialog.shareLink";
47
-        let titleString = APP.translation.generateTranslationHTML(titleKey);
48
-
49
-        dialog.titleKey = titleKey;
50
-        dialog.titleString = titleString;
46
+        dialog.titleKey = "dialog.shareLink";
51 47
         this.dialog = dialog;
52 48
 
53 49
         this.dialog.states = this.getStates();
@@ -101,7 +97,7 @@ export default class InviteDialogView {
101 97
      */
102 98
     getStates() {
103 99
         let {
104
-            titleString
100
+            titleKey
105 101
         } = this.dialog;
106 102
         let doneKey = 'dialog.done';
107 103
         let doneMsg = APP.translation.translateString(doneKey);
@@ -110,12 +106,12 @@ export default class InviteDialogView {
110 106
         buttons[`${doneMsg}`] = true;
111 107
 
112 108
         states[States.UNLOCKED] = {
113
-            title: titleString,
109
+            titleKey,
114 110
             html: this.getShareLinkBlock() + this.getAddPasswordBlock(),
115 111
             buttons
116 112
         };
117 113
         states[States.LOCKED] = {
118
-            title: titleString,
114
+            titleKey,
119 115
             html: this.getShareLinkBlock() + this.getPasswordBlock(),
120 116
             buttons
121 117
         };
@@ -135,10 +131,12 @@ export default class InviteDialogView {
135 131
         let roomUnlockKey = 'roomUnlocked';
136 132
         let roomUnlock = APP.translation.translateString(roomUnlockKey);
137 133
         let classes = 'button-control button-control_light copyInviteLink';
134
+        let title = APP.translation.translateString(this.dialog.titleKey);
138 135
         return (
139 136
             `<div class="input-control">
140
-                <label class="input-control__label" for="inviteLinkRef">
141
-                    ${this.dialog.titleString}
137
+                <label class="input-control__label" for="inviteLinkRef"
138
+                    data-i18n="${this.dialog.titleKey}">
139
+                        ${title}
142 140
                 </label>
143 141
                 <div class="input-control__container">
144 142
                     <input class="input-control__input inviteLink"

+ 12
- 15
modules/UI/util/MessageHandler.js Vedi File

@@ -41,13 +41,12 @@ var messageHandler = {
41 41
         if (!popupEnabled)
42 42
             return null;
43 43
 
44
-        let title = APP.translation.generateTranslationHTML(titleKey);
45 44
         if (!message) {
46 45
             message = APP.translation.generateTranslationHTML(messageKey);
47 46
         }
48 47
 
49 48
         return $.prompt(message, {
50
-            title: this._getFormattedTitleString(title),
49
+            title: this._getFormattedTitleString(titleKey),
51 50
             persistent: false,
52 51
             promptspeed: 0,
53 52
             classes: this._getDialogClasses(),
@@ -107,7 +106,6 @@ var messageHandler = {
107 106
         buttons.push({title: cancelButton, value: false});
108 107
 
109 108
         var message = msgString;
110
-        var title = APP.translation.generateTranslationHTML(titleKey);
111 109
         if (msgKey) {
112 110
             message = APP.translation.generateTranslationHTML(msgKey);
113 111
         }
@@ -117,7 +115,7 @@ var messageHandler = {
117 115
         }
118 116
 
119 117
         twoButtonDialog = $.prompt(message, {
120
-            title: this._getFormattedTitleString(title),
118
+            title: this._getFormattedTitleString(titleKey),
121 119
             persistent: false,
122 120
             buttons: buttons,
123 121
             defaultButton: defaultButton,
@@ -146,7 +144,7 @@ var messageHandler = {
146 144
      * Shows a message to the user with two buttons: first is given as a
147 145
      * parameter and the second is Cancel.
148 146
      *
149
-     * @param titleString the title of the message
147
+     * @param titleKey the key for the title of the message
150 148
      * @param msgString the text of the message
151 149
      * @param persistent boolean value which determines whether the message is
152 150
      *        persistent or not
@@ -158,13 +156,13 @@ var messageHandler = {
158 156
      *        loaded
159 157
      * @param closeFunction function to be called on dialog close
160 158
      */
161
-    openDialog: function (titleString, msgString, persistent, buttons,
159
+    openDialog: function (titleKey, msgString, persistent, buttons,
162 160
                               submitFunction, loadedFunction, closeFunction) {
163 161
         if (!popupEnabled)
164 162
             return;
165 163
 
166 164
         let args = {
167
-            title: this._getFormattedTitleString(titleString),
165
+            title: this._getFormattedTitleString(titleKey),
168 166
             persistent: persistent,
169 167
             buttons: buttons,
170 168
             defaultButton: 1,
@@ -187,13 +185,12 @@ var messageHandler = {
187 185
      *
188 186
      * @return the title string formatted as a div.
189 187
      */
190
-    _getFormattedTitleString(titleString) {
188
+    _getFormattedTitleString(titleKey) {
191 189
         let $titleString = $('<h2>');
192 190
         $titleString.addClass('aui-dialog2-header-main');
193
-        $titleString.append(titleString);
194
-        titleString = $('<div>').append($titleString).html();
195
-
196
-        return titleString;
191
+        $titleString.attr('data-i18n',titleKey);
192
+        $titleString.append(APP.translation.translateString(titleKey));
193
+        return $('<div>').append($titleString).html();
197 194
     },
198 195
 
199 196
     /**
@@ -238,9 +235,9 @@ var messageHandler = {
238 235
 
239 236
         for (let state in statesObject) {
240 237
             let currentState = statesObject[state];
241
-            if(currentState.title) {
242
-                let title = currentState.title;
243
-                currentState.title = this._getFormattedTitleString(title);
238
+            if(currentState.titleKey) {
239
+                currentState.title
240
+                    = this._getFormattedTitleString(currentState.titleKey);
244 241
             }
245 242
         }
246 243
         return new Impromptu(statesObject, options);

Loading…
Annulla
Salva