Skip to content

Commit cac4aed

Browse files
committed
Add localization for quiz
Progress of adaptation: - [x] Questions - [x] Quiz - [ ] Index - [ ] Instructions - [ ] Results
1 parent 44419b5 commit cac4aed

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

locales/en/quiz.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"strongly_agree": "Strongly Agree",
3+
"agree": "Agree",
4+
"neutral": "Neutral/Unsure",
5+
"disagree": "Disagree",
6+
"strongly_disagree": "Strongly Disagree",
7+
"question_no": "Question {{current}} of {{total}}"
8+
}

locales/pt/quiz.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"strongly_agree": "Concordo fortemente",
3+
"agree": "Concordo",
4+
"neutral": "Neutro/Incerto",
5+
"disagree": "Discordo",
6+
"strongly_disagree": "Discordo fortemente",
7+
"question_no": "Pergunta {{current}} de {{total}}"
8+
}

quiz.html

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ <h1>8values</h1>
2424
<hr>
2525
<h2 style="text-align:center;" id="question-number">Loading...</h2>
2626
<p class="question" id="question-text"></p>
27-
<button class="button" onclick="next_question( 1.0)" style="background-color: #1b5e20;">Strongly Agree</button> <br>
28-
<button class="button" onclick="next_question( 0.5)" style="background-color: #4caf50;">Agree</button> <br>
29-
<button class="button" onclick="next_question( 0.0)" style="background-color: #bbbbbb;">Neutral/Unsure</button> <br>
30-
<button class="button" onclick="next_question(-0.5)" style="background-color: #f44336;">Disagree</button> <br>
31-
<button class="button" onclick="next_question(-1.0)" style="background-color: #b71c1c;">Strongly Disagree</button> <br>
27+
<button class="button" onclick="next_question( 1.0)" style="background-color: #1b5e20;" id="strongly_agree"></button> <br>
28+
<button class="button" onclick="next_question( 0.5)" style="background-color: #4caf50;" id="agree"></button> <br>
29+
<button class="button" onclick="next_question( 0.0)" style="background-color: #bbbbbb;" id="neutral"></button> <br>
30+
<button class="button" onclick="next_question(-0.5)" style="background-color: #f44336;" id="disagree"></button> <br>
31+
<button class="button" onclick="next_question(-1.0)" style="background-color: #b71c1c;" id="strongly_disagree"></button> <br>
3232
<button class="small_button" onclick="prev_question()" id="back_button">Back</button>
3333
<button class="small_button_off" id="back_button_off">Back</button><br>
3434

@@ -55,10 +55,10 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
5555
.use(window.i18nextXHRBackend)
5656
.init({
5757
"fallbackLng": "en",
58-
"ns": [ "questions" ]
58+
"ns": [ "questions", "quiz" ]
5959
}, ready)
6060

61-
var qs;
61+
var qs, qz;
6262
var max_econ, max_dipl, max_govt, max_scty; // Max possible scores
6363
max_econ = max_dipl = max_govt = max_scty = 0;
6464
var econ, dipl, govt, scty; // User's scores
@@ -74,11 +74,16 @@ <h2 style="text-align:center;" id="question-number">Loading...</h2>
7474
}
7575
function ready() {
7676
qs = i18next.getFixedT(null, 'questions')
77+
qz = i18next.getFixedT(null, 'quiz')
78+
79+
for (i of ["strongly_agree", "agree", "neutral", "disagree", "strongly_disagree"]) {
80+
document.getElementById(i).innerHTML=qz(i)
81+
}
7782
display_progress()
7883
}
7984
function display_progress() {
8085
document.getElementById("question-text").innerHTML=qs(questions[qn].question)
81-
document.getElementById("question-number").innerHTML = "Question " + (qn + 1) + " of " + (questions.length);
86+
document.getElementById("question-number").innerHTML=qz("question_no", { current: qn + 1, total: questions.length })
8287
if (prev_answer == null) {
8388
document.getElementById("back_button").style.display = 'none';
8489
document.getElementById("back_button_off").style.display = 'block';

0 commit comments

Comments
 (0)