From 4d62f8a97142ab856cb20da506ca73d8b955211a Mon Sep 17 00:00:00 2001 From: germanocaumo <germanocaumo@gmail.com> Date: Thu, 27 May 2021 18:16:11 +0000 Subject: [PATCH] fix: translate poll answer key for default polls --- .../message-chat-item/poll-list-item/component.jsx | 2 +- bigbluebutton-html5/imports/ui/components/poll/service.js | 5 +++-- .../imports/ui/components/polling/component.jsx | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/chat/time-window-list/time-window-chat-item/message-chat-item/poll-list-item/component.jsx b/bigbluebutton-html5/imports/ui/components/chat/time-window-list/time-window-chat-item/message-chat-item/poll-list-item/component.jsx index a2286a62d9..91856398e6 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/time-window-list/time-window-chat-item/message-chat-item/poll-list-item/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/chat/time-window-list/time-window-chat-item/message-chat-item/poll-list-item/component.jsx @@ -45,7 +45,7 @@ function PollListItem(props) { }; const { answers, numRespondents } = pollResultData; - let { resultString, optionsString } = getPollResultString(isDefaultPoll, answers, numRespondents) + let { resultString, optionsString } = getPollResultString(isDefaultPoll, answers, numRespondents, intl) resultString = sanitize(resultString); optionsString = sanitize(optionsString); diff --git a/bigbluebutton-html5/imports/ui/components/poll/service.js b/bigbluebutton-html5/imports/ui/components/poll/service.js index 2446a8350f..d7a976983f 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/service.js +++ b/bigbluebutton-html5/imports/ui/components/poll/service.js @@ -58,7 +58,7 @@ const pollAnswerIds = { }, }; -const getPollResultString = (isDefaultPoll, answers, numRespondents) => { +const getPollResultString = (isDefaultPoll, answers, numRespondents, intl) => { let responded = 0; let resultString = ''; let optionsString = ''; @@ -72,7 +72,8 @@ const getPollResultString = (isDefaultPoll, answers, numRespondents) => { const pctBars = "|".repeat(pct * MAX_POLL_RESULT_BARS / 100); const pctFotmatted = `${Number.isNaN(pct) ? 0 : pct}%`; if (isDefaultPoll) { - resultString += `${item.key}: ${item.numVotes || 0} |${pctBars} ${pctFotmatted}\n`; + const translatedKey = intl.formatMessage(pollAnswerIds[item.key.toLowerCase()]); + resultString += `${translatedKey}: ${item.numVotes || 0} |${pctBars} ${pctFotmatted}\n`; } else { resultString += `${item.id+1}: ${item.numVotes || 0} |${pctBars} ${pctFotmatted}\n`; optionsString += `${item.id+1}: ${item.key}\n`; diff --git a/bigbluebutton-html5/imports/ui/components/polling/component.jsx b/bigbluebutton-html5/imports/ui/components/polling/component.jsx index a47c684803..c95a5e1e18 100644 --- a/bigbluebutton-html5/imports/ui/components/polling/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/polling/component.jsx @@ -20,7 +20,7 @@ const intlMessages = defineMessages({ pollAnswerDesc: { id: 'app.polling.pollAnswerDesc', }, - pollQestionTitle: { + pollQuestionTitle: { id: 'app.polling.pollQuestionTitle', }, submitLabel: { @@ -122,7 +122,7 @@ class Polling extends Component { question.length > 0 && ( <span className={styles.qHeader}> <div className={styles.qTitle}> - {intl.formatMessage(intlMessages.pollQestionTitle)} + {intl.formatMessage(intlMessages.pollQuestionTitle)} </div> <div data-test="pollQuestion" className={styles.qText}>{question}</div> </span> -- GitLab