fix(i18n): correct translation directions in socialnetwork.json files
All checks were successful
Deploy to production / deploy (push) Successful in 3m24s
All checks were successful
Deploy to production / deploy (push) Successful in 3m24s
- Updated translation keys in German, English, and Spanish localization files to accurately reflect the intended language direction for vocabulary translation. - Adjusted the `translateTo` and `translateFrom` keys to ensure consistency across all language files.
This commit is contained in:
@@ -1699,49 +1699,43 @@ export default {
|
||||
|
||||
return matches;
|
||||
},
|
||||
buildChoiceOptions(correctAnswers, allVocabs, excludePrompt = null) {
|
||||
/**
|
||||
* @param {'L2R'|'R2L'} direction L2R: Antwort = reference (Zielsprache, z. B. Bisaya). R2L: Antwort = learning (Muttersprache, z. B. Deutsch).
|
||||
* Distraktoren kommen immer nur aus derselben Sprache wie die richtige Antwort.
|
||||
*/
|
||||
buildChoiceOptions(correctAnswers, allVocabs, excludePrompt = null, direction = 'L2R') {
|
||||
const normalizedCorrectAnswers = Array.isArray(correctAnswers) ? correctAnswers : [correctAnswers];
|
||||
const options = new Set(normalizedCorrectAnswers.filter(Boolean));
|
||||
// Normalisiere alle Werte für den Vergleich (trim + lowercase)
|
||||
const normalizedExcludeSet = new Set();
|
||||
normalizedCorrectAnswers.forEach((answer) => {
|
||||
normalizedExcludeSet.add(this.normalizeVocab(answer));
|
||||
});
|
||||
// Wichtig: Der Prompt (die Frage) darf nicht in den Optionen erscheinen
|
||||
if (excludePrompt) {
|
||||
normalizedExcludeSet.add(this.normalizeVocab(excludePrompt));
|
||||
}
|
||||
|
||||
// Sammle alle verfügbaren Distraktoren aus beiden Richtungen
|
||||
|
||||
const answerField = direction === 'L2R' ? 'reference' : 'learning';
|
||||
|
||||
const allDistractors = [];
|
||||
allVocabs.forEach(vocab => {
|
||||
// Füge beide Richtungen hinzu (learning und reference)
|
||||
if (vocab.learning && vocab.learning.trim()) {
|
||||
const normalized = this.normalizeVocab(vocab.learning);
|
||||
if (!normalizedExcludeSet.has(normalized)) {
|
||||
allDistractors.push(vocab.learning);
|
||||
}
|
||||
}
|
||||
if (vocab.reference && vocab.reference.trim()) {
|
||||
const normalized = this.normalizeVocab(vocab.reference);
|
||||
if (!normalizedExcludeSet.has(normalized)) {
|
||||
allDistractors.push(vocab.reference);
|
||||
}
|
||||
allVocabs.forEach((vocab) => {
|
||||
const candidate = vocab[answerField];
|
||||
if (!candidate || !candidate.trim()) return;
|
||||
const normalized = this.normalizeVocab(candidate);
|
||||
if (!normalizedExcludeSet.has(normalized)) {
|
||||
allDistractors.push(candidate);
|
||||
}
|
||||
});
|
||||
|
||||
// Entferne Duplikate
|
||||
|
||||
const uniqueDistractors = [...new Set(allDistractors)];
|
||||
|
||||
// Füge Distraktoren hinzu, bis wir 4 Optionen haben
|
||||
|
||||
let attempts = 0;
|
||||
const maxAttempts = 200;
|
||||
|
||||
|
||||
while (options.size < 4 && uniqueDistractors.length > 0 && attempts < maxAttempts) {
|
||||
attempts++;
|
||||
const randomIndex = Math.floor(Math.random() * uniqueDistractors.length);
|
||||
const distractor = uniqueDistractors[randomIndex];
|
||||
|
||||
|
||||
if (distractor && distractor.trim()) {
|
||||
const normalizedDistractor = this.normalizeVocab(distractor);
|
||||
if (!normalizedExcludeSet.has(normalizedDistractor) && !options.has(distractor)) {
|
||||
@@ -1749,18 +1743,15 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Falls immer noch nicht genug Optionen: Verwende auch die andere Richtung der aktuellen Vokabeln
|
||||
|
||||
if (options.size < 4 && allVocabs.length > 0) {
|
||||
allVocabs.forEach(vocab => {
|
||||
allVocabs.forEach((vocab) => {
|
||||
if (options.size >= 4) return;
|
||||
|
||||
// Verwende die andere Richtung als Distraktor
|
||||
const otherDirection = this.vocabTrainerDirection === 'L2R' ? vocab.learning : vocab.reference;
|
||||
if (otherDirection && otherDirection.trim()) {
|
||||
const normalized = this.normalizeVocab(otherDirection);
|
||||
if (!normalizedExcludeSet.has(normalized) && !options.has(otherDirection)) {
|
||||
options.add(otherDirection);
|
||||
const candidate = vocab[answerField];
|
||||
if (candidate && candidate.trim()) {
|
||||
const normalized = this.normalizeVocab(candidate);
|
||||
if (!normalizedExcludeSet.has(normalized) && !options.has(candidate)) {
|
||||
options.add(candidate);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1845,9 +1836,10 @@ export default {
|
||||
debugLog('[VocabLessonView] Answer:', this.currentVocabQuestion.answer);
|
||||
// Wichtig: Der Prompt (die Frage) darf nicht in den Optionen erscheinen
|
||||
this.vocabTrainerChoiceOptions = this.buildChoiceOptions(
|
||||
this.currentVocabQuestion.answers,
|
||||
this.currentVocabQuestion.answers,
|
||||
allTrainerVocabs,
|
||||
this.currentVocabQuestion.prompt // Exkludiere den Prompt
|
||||
this.currentVocabQuestion.prompt,
|
||||
this.vocabTrainerDirection
|
||||
);
|
||||
debugLog('[VocabLessonView] Choice-Optionen erstellt:', this.vocabTrainerChoiceOptions);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user