Skip to content
Snippets Groups Projects
Commit 4d62f8a9 authored by germanocaumo's avatar germanocaumo
Browse files

fix: translate poll answer key for default polls

parent b3c698a2
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ function PollListItem(props) { ...@@ -45,7 +45,7 @@ function PollListItem(props) {
}; };
const { answers, numRespondents } = pollResultData; const { answers, numRespondents } = pollResultData;
let { resultString, optionsString } = getPollResultString(isDefaultPoll, answers, numRespondents) let { resultString, optionsString } = getPollResultString(isDefaultPoll, answers, numRespondents, intl)
resultString = sanitize(resultString); resultString = sanitize(resultString);
optionsString = sanitize(optionsString); optionsString = sanitize(optionsString);
......
...@@ -58,7 +58,7 @@ const pollAnswerIds = { ...@@ -58,7 +58,7 @@ const pollAnswerIds = {
}, },
}; };
const getPollResultString = (isDefaultPoll, answers, numRespondents) => { const getPollResultString = (isDefaultPoll, answers, numRespondents, intl) => {
let responded = 0; let responded = 0;
let resultString = ''; let resultString = '';
let optionsString = ''; let optionsString = '';
...@@ -72,7 +72,8 @@ const getPollResultString = (isDefaultPoll, answers, numRespondents) => { ...@@ -72,7 +72,8 @@ const getPollResultString = (isDefaultPoll, answers, numRespondents) => {
const pctBars = "|".repeat(pct * MAX_POLL_RESULT_BARS / 100); const pctBars = "|".repeat(pct * MAX_POLL_RESULT_BARS / 100);
const pctFotmatted = `${Number.isNaN(pct) ? 0 : pct}%`; const pctFotmatted = `${Number.isNaN(pct) ? 0 : pct}%`;
if (isDefaultPoll) { 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 { } else {
resultString += `${item.id+1}: ${item.numVotes || 0} |${pctBars} ${pctFotmatted}\n`; resultString += `${item.id+1}: ${item.numVotes || 0} |${pctBars} ${pctFotmatted}\n`;
optionsString += `${item.id+1}: ${item.key}\n`; optionsString += `${item.id+1}: ${item.key}\n`;
......
...@@ -20,7 +20,7 @@ const intlMessages = defineMessages({ ...@@ -20,7 +20,7 @@ const intlMessages = defineMessages({
pollAnswerDesc: { pollAnswerDesc: {
id: 'app.polling.pollAnswerDesc', id: 'app.polling.pollAnswerDesc',
}, },
pollQestionTitle: { pollQuestionTitle: {
id: 'app.polling.pollQuestionTitle', id: 'app.polling.pollQuestionTitle',
}, },
submitLabel: { submitLabel: {
...@@ -122,7 +122,7 @@ class Polling extends Component { ...@@ -122,7 +122,7 @@ class Polling extends Component {
question.length > 0 && ( question.length > 0 && (
<span className={styles.qHeader}> <span className={styles.qHeader}>
<div className={styles.qTitle}> <div className={styles.qTitle}>
{intl.formatMessage(intlMessages.pollQestionTitle)} {intl.formatMessage(intlMessages.pollQuestionTitle)}
</div> </div>
<div data-test="pollQuestion" className={styles.qText}>{question}</div> <div data-test="pollQuestion" className={styles.qText}>{question}</div>
</span> </span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment