fix: translate poll answer key for default polls

This commit is contained in:
germanocaumo 2021-05-27 18:16:11 +00:00
parent b3c698a2a9
commit 4d62f8a971
3 changed files with 6 additions and 5 deletions

View File

@ -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);

View File

@ -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`;

View File

@ -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>