瀏覽代碼

Always use formatting inside translatable strings (#983)

This helps translators reorder words in the string.
linkmauve 7 年之前
父節點
當前提交
561bdbba35
共有 2 個文件被更改,包括 18 次插入11 次删除
  1. 2 2
      src/converse-core.js
  2. 16 9
      src/converse-muc.js

+ 2 - 2
src/converse-core.js

@@ -581,8 +581,8 @@
             } else if (status === Strophe.Status.CONNFAIL) {
             } else if (status === Strophe.Status.CONNFAIL) {
                 let feedback = message;
                 let feedback = message;
                 if (message === "host-unknown" || message == "remote-connection-failed") {
                 if (message === "host-unknown" || message == "remote-connection-failed") {
-                    feedback = __("Sorry, we could not connect to the XMPP host with domain: ") +
-                        `\"${Strophe.getDomainFromJid(_converse.connection.jid)}\"`;
+                    feedback = __("Sorry, we could not connect to the XMPP host with domain: %1$s",
+                        `\"${Strophe.getDomainFromJid(_converse.connection.jid)}\"`);
                 } else if (!_.isUndefined(message) && message === _.get(Strophe, 'ErrorCondition.NO_AUTH_MECH')) {
                 } else if (!_.isUndefined(message) && message === _.get(Strophe, 'ErrorCondition.NO_AUTH_MECH')) {
                     feedback = __("The XMPP server did not offer a supported authentication mechanism");
                     feedback = __("The XMPP server did not offer a supported authentication mechanism");
                 }
                 }

+ 16 - 9
src/converse-muc.js

@@ -1845,12 +1845,14 @@
                             tpl_info({
                             tpl_info({
                                 'data': `data-leavejoin="${nick}"`,
                                 'data': `data-leavejoin="${nick}"`,
                                 'isodate': moment().format(),
                                 'isodate': moment().format(),
-                                'message': __(nick+' has left and re-entered the room.')
+                                'message': __('%1$s has left and re-entered the room.', nick)
                             });
                             });
                     } else {
                     } else {
-                        let  message = __(nick+' has entered the room.');
+                        let  message;
                         if (_.get(stat, 'textContent')) {
                         if (_.get(stat, 'textContent')) {
-                            message = message + ' "' + stat.textContent + '"';
+                            message = __('%1$s has entered the room. "%2$s"', nick, stat.textContent);
+                        } else {
+                            message = __('%1$s has entered the room.', nick);
                         }
                         }
                         const data = {
                         const data = {
                             'data': `data-join="${nick}"`,
                             'data': `data-join="${nick}"`,
@@ -1877,9 +1879,11 @@
                     if (_.includes(_.get(last_el, 'classList', []), 'chat-info') &&
                     if (_.includes(_.get(last_el, 'classList', []), 'chat-info') &&
                             _.get(last_el, 'dataset', {}).join === `"${nick}"`) {
                             _.get(last_el, 'dataset', {}).join === `"${nick}"`) {
 
 
-                        let message = __('%1$s has entered and left the room.', nick);
+                        let message;
                         if (_.get(stat, 'textContent')) {
                         if (_.get(stat, 'textContent')) {
-                            message = message + ' "' + stat.textContent + '"';
+                            message = __('%1$s has entered and left the room. "%2$s"', nick, stat.textContent);
+                        } else {
+                            message = __('%1$s has entered and left the room.', nick);
                         }
                         }
                         last_el.outerHTML =
                         last_el.outerHTML =
                             tpl_info({
                             tpl_info({
@@ -1888,9 +1892,11 @@
                                 'message': message
                                 'message': message
                             });
                             });
                     } else {
                     } else {
-                        let  message = __('%1$s has left the room.', nick);
+                        let message;
                         if (_.get(stat, 'textContent')) {
                         if (_.get(stat, 'textContent')) {
-                            message = message + ' "' + stat.textContent + '"';
+                            message = __('%1$s has left the room. "%2$s"', nick, stat.textContent);
+                        } else {
+                            message = __('%1$s has left the room.', nick);
                         }
                         }
                         const data = {
                         const data = {
                             'message': message,
                             'message': message,
@@ -2462,8 +2468,9 @@
 
 
                 promptForInvite (suggestion) {
                 promptForInvite (suggestion) {
                     const reason = prompt(
                     const reason = prompt(
-                        __('You are about to invite %1$s to the chat room "%2$s". ', suggestion.text.label, this.model.get('id')) +
-                        __("You may optionally include a message, explaining the reason for the invitation.")
+                        __('You are about to invite %1$s to the chat room "%2$s". '+
+                           'You may optionally include a message, explaining the reason for the invitation.',
+                           suggestion.text.label, this.model.get('id'))
                     );
                     );
                     if (reason !== null) {
                     if (reason !== null) {
                         this.chatroomview.directInvite(suggestion.text.value, reason);
                         this.chatroomview.directInvite(suggestion.text.value, reason);