feat: Add various translations

This commit is contained in:
moanos [he/him] 2025-04-17 21:45:37 +02:00
parent d5a467aa55
commit a13a818485
4 changed files with 29 additions and 11 deletions

View File

@ -38,5 +38,21 @@
"minimum-length-short-side": "Die kurze Seite des Käfig muss mindestens {{ minimum_length_short_side }}cm lang sein.", "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-complies-with-all-criteria": "Der Käfig erfüllt alle Kriterien!",
"cage-for-x-rats": "Käfig für {{ num_rats }} Ratten", "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!"
} }

View File

@ -23,6 +23,7 @@
"give-feedback": "Give Feedback", "give-feedback": "Give Feedback",
"feedback": "Feedback", "feedback": "Feedback",
"sus-title": "Rate the calculator", "sus-title": "Rate the calculator",
"explanation-feedback": "",
"submit": "Submit", "submit": "Submit",
"failed-base-area": "The base area of the cage must not be below {{ MINIMUM_BASE_AREA }}m².", "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.", "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.", "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-complies-with-all-criteria": "This cage complies with all criteria!",
"cage-for-x-rats": "Cage for {{ num_rats }} rats", "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"
} }

View File

@ -296,6 +296,7 @@
</div> </div>
<div class="section"> <div class="section">
<h1 class="title" data-i18n="sus-title">Bewerte den Rechner</h1> <h1 class="title" data-i18n="sus-title">Bewerte den Rechner</h1>
<p class="is-spaced mb-4" data-i18n="explanation-feedback"></p>
<form id="sus-form"> <form id="sus-form">
<!--- Questions here ---> <!--- Questions here --->
<div class="control" id="sus-control"> <div class="control" id="sus-control">

View File

@ -1,3 +1,5 @@
import i18next from "i18next";
const scaleQuestions = [ const scaleQuestions = [
"sus-question-easy-to-use", // I thought CageCalc is easy to use "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-like-to-use-frequently", // I would like to use CageCalc frequently
@ -29,11 +31,8 @@ function prepareQuestionnaire() {
<p class="control"> <p class="control">
<input class="sus-slider" type="range" min="1" max="5" step="1" name=${key} required> <input class="sus-slider" type="range" min="1" max="5" step="1" name=${key} required>
<div class="slider-labels"> <div class="slider-labels">
<span data-i18n="strongly-disagree">Strongly Disagree</span> <span data-i18n="strongly-disagree">${i18next.t('strongly-disagree')}</span>
<span data-i18n="disagree">Disagree</span> <span data-i18n="strongly-agree">${i18next.t('strongly-agree')}</span>
<span data-i18n="neutral">Neutral</span>
<span data-i18n="agree">Agree</span>
<span data-i18n="strongly-agree">Strongly Agree</span>
</div> </div>
</p> </p>
`; `;
@ -64,7 +63,6 @@ window.addEventListener('DOMContentLoaded', () => {
const jsonData = {}; const jsonData = {};
for (let [key, value] of formData.entries()) { for (let [key, value] of formData.entries()) {
console.log(key, value);
if (key.startsWith("sws-question")) { if (key.startsWith("sws-question")) {
jsonData[key] = parseInt(value, 10); jsonData[key] = parseInt(value, 10);
} else { } else {
@ -87,11 +85,11 @@ window.addEventListener('DOMContentLoaded', () => {
if (response.ok) { if (response.ok) {
messageDiv.className = "notification is-success"; messageDiv.className = "notification is-success";
messageDiv.setAttribute("data-i18n", "submit-success"); messageDiv.setAttribute("data-i18n", "submit-success");
messageDiv.textContent = "Survey submitted successfully!"; messageDiv.textContent = i18next.t("Survey submitted successfully!");
} else { } else {
messageDiv.className = "notification is-danger"; messageDiv.className = "notification is-danger";
messageDiv.setAttribute("data-i18n", "submit-error"); 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"); messageDiv.classList.remove("is-hidden");
@ -100,7 +98,7 @@ window.addEventListener('DOMContentLoaded', () => {
const messageDiv = document.getElementById("response-message"); const messageDiv = document.getElementById("response-message");
messageDiv.className = "notification is-danger"; messageDiv.className = "notification is-danger";
messageDiv.removeAttribute("data-i18n"); // For dynamic error message 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"); messageDiv.classList.remove("is-hidden");
} }
}); });