From a13a81848534303634f71849a3c31fe0d2439416 Mon Sep 17 00:00:00 2001 From: moanos Date: Thu, 17 Apr 2025 21:45:37 +0200 Subject: [PATCH] feat: Add various translations --- public/i18n/de.json | 18 +++++++++++++++++- public/i18n/en.json | 5 ++++- public/index.html | 1 + src/sus.js | 16 +++++++--------- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/public/i18n/de.json b/public/i18n/de.json index a8b12d9..425fa75 100644 --- a/public/i18n/de.json +++ b/public/i18n/de.json @@ -38,5 +38,21 @@ "minimum-length-short-side": "Die kurze Seite des Käfig muss mindestens {{ minimum_length_short_side }}cm lang sein.", "cage-complies-with-all-criteria": "Der Käfig erfüllt alle Kriterien!", "cage-for-x-rats": "Käfig für {{ num_rats }} Ratten", - "overall-area": "Die Gesamtfläche für {{ numRats }} Ratten muss mindestens {{ minimumOverallArea }}m² betragen." + "overall-area": "Die Gesamtfläche für {{ numRats }} Ratten muss mindestens {{ minimumOverallArea }}m² betragen.", + "strongly-disagree": "Stimme gar nicht zu", + "strongly-agree": "Stimme voll zu", + "sus-question-easy-to-use": "I thought CageCalc is easy to use", + "sus-question-like-to-use-frequently": "I would like to use CageCalc frequently", + "sus-question-unnecessarily-complex": "I find CageCalc unnecessarily complex", + "sus-question-need-support-of-technical-person": "I think that I need the support of a technical person to be able to use CageCalc", + "sus-question-well-integrated": "I found various functions in CageCalc were well integrated", + "sus-question-inconsistency": "I thought there was too much inconsistency in CageCalc", + "sus-question-learn-quickly": "I would imagine that most people would learn to use CageCalc very quickly", + "sus-question-cumbersome": "I found CageCalc very cumbersome to use", + "sus-question-confident": "I felt very confident using CageCalc", + "sus-question-need-to-learn": "I needed to learn a lot of things before I could get going with CageCalc", + "question-whats-missing": "Welche Funktion fehlt dir?", + "question-pain-points": "Was muss aus deiner Sicht an XX geändert werden?", + "question-other-feedback": "Was willst du uns mitgeben?", + "explanation-feedback": "Dein Feedback hilft uns den Rechner zu verbessern. Wir sammeln dabei keinerlei persönliche Daten. Du tust uns einfach nur einen großen Gefallen!" } diff --git a/public/i18n/en.json b/public/i18n/en.json index 79b8314..c76d5bb 100644 --- a/public/i18n/en.json +++ b/public/i18n/en.json @@ -23,6 +23,7 @@ "give-feedback": "Give Feedback", "feedback": "Feedback", "sus-title": "Rate the calculator", + "explanation-feedback": "", "submit": "Submit", "failed-base-area": "The base area of the cage must not be below {{ MINIMUM_BASE_AREA }}m².", "failed-overall-area": "The overall area in the cage is to small.", @@ -38,5 +39,7 @@ "minimum-length-short-side": "The short side of the cage must be at least {{ minimum_length_short_side }}cm.", "cage-complies-with-all-criteria": "This cage complies with all criteria!", "cage-for-x-rats": "Cage for {{ num_rats }} rats", - "overall-area": "The overall area in the cage must be above {{ minimumOverallArea }}m² for {{ numRats }} rats." + "overall-area": "The overall area in the cage must be above {{ minimumOverallArea }}m² for {{ numRats }} rats.", + "strongly-disagree": "Strongly Disagree", + "strongly-agree": "Strongly Agree" } diff --git a/public/index.html b/public/index.html index ec7ccbb..75d06f4 100644 --- a/public/index.html +++ b/public/index.html @@ -296,6 +296,7 @@

Bewerte den Rechner

+

diff --git a/src/sus.js b/src/sus.js index c21fe16..9ed6794 100644 --- a/src/sus.js +++ b/src/sus.js @@ -1,3 +1,5 @@ +import i18next from "i18next"; + const scaleQuestions = [ "sus-question-easy-to-use", // I thought CageCalc is easy to use "sus-question-like-to-use-frequently", // I would like to use CageCalc frequently @@ -29,11 +31,8 @@ function prepareQuestionnaire() {

- Strongly Disagree - Disagree - Neutral - Agree - Strongly Agree + ${i18next.t('strongly-disagree')} + ${i18next.t('strongly-agree')}

`; @@ -64,7 +63,6 @@ window.addEventListener('DOMContentLoaded', () => { const jsonData = {}; for (let [key, value] of formData.entries()) { - console.log(key, value); if (key.startsWith("sws-question")) { jsonData[key] = parseInt(value, 10); } else { @@ -87,11 +85,11 @@ window.addEventListener('DOMContentLoaded', () => { if (response.ok) { messageDiv.className = "notification is-success"; messageDiv.setAttribute("data-i18n", "submit-success"); - messageDiv.textContent = "Survey submitted successfully!"; + messageDiv.textContent = i18next.t("Survey submitted successfully!"); } else { messageDiv.className = "notification is-danger"; messageDiv.setAttribute("data-i18n", "submit-error"); - messageDiv.textContent = "There was an error submitting the survey."; + messageDiv.textContent = i18next.t("There was an error submitting the survey."); } messageDiv.classList.remove("is-hidden"); @@ -100,7 +98,7 @@ window.addEventListener('DOMContentLoaded', () => { const messageDiv = document.getElementById("response-message"); messageDiv.className = "notification is-danger"; messageDiv.removeAttribute("data-i18n"); // For dynamic error message - messageDiv.textContent = "Network error: " + error.message; + messageDiv.textContent = i18next.t("Network error: {{errorMessage}}",{"errorMessage": error.message}); messageDiv.classList.remove("is-hidden"); } });