Skip to content

Commit

Permalink
Use translation resource in survey summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourgreens committed Oct 5, 2017
1 parent c740404 commit 2ce959b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/classifier/tasks/survey/summary.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Translate from 'react-translate-component';
import Utility from './utility';
import translations from '../../../pages/project/translations';

class SurveySummary extends React.Component {
constructor(props) {
Expand All @@ -16,16 +16,16 @@ class SurveySummary extends React.Component {

render() {
const { task, annotation } = this.props;
const taskStrings = translations.strings.workflow.tasks;
const choiceSummaries = annotation.value.map((identification) => {
const choice = task.choices[identification.choice];
const questionIds = Utility.getQuestionIDs(task, identification.choice);
const filteredQuestionIds = questionIds.filter(questionId => Object.keys(identification.answers).indexOf(questionId) > -1);
const allAnswers = filteredQuestionIds.map(questionId =>
[].concat(identification.answers[questionId])
.map(answerId => task.questions[questionId].answers[answerId].label)
.join(', ')
);
return `${choice.label}: ${allAnswers.join('; ')}`;
const translationChoiceKey = `${annotation.task}.choices.${identification.choice}.label`;
const allAnswers = Object.keys(identification.answers).map((questionId) => {
const translationQuestionKey = `${annotation.task}.questions.${questionId}`;
const answerKeys = [].concat(identification.answers[questionId]);
const answers = answerKeys.map(answerId => taskStrings[`${translationQuestionKey}.answers.${answerId}.label`]);
return answers.join(', ');
});
return `${taskStrings[translationChoiceKey]}: ${allAnswers.join('; ')}`;
});
return (
<div>
Expand Down

0 comments on commit 2ce959b

Please sign in to comment.