diff --git a/frontend/src/views/social/VocabLessonView.vue b/frontend/src/views/social/VocabLessonView.vue index 33745c9..3c0f115 100644 --- a/frontend/src/views/social/VocabLessonView.vue +++ b/frontend/src/views/social/VocabLessonView.vue @@ -126,11 +126,11 @@

- {{ $t('socialnetwork.vocab.courses.vocabPrepTargetLabel') }} + {{ prepTargetLabel }}
{{ currentPrepItem.target }}
- {{ $t('socialnetwork.vocab.courses.vocabPrepGlossLabel') }} + {{ prepGlossLabel }}
{{ currentPrepItem.gloss || '—' }}
@@ -1295,14 +1295,54 @@ export default { .map((p) => this.normalizeCorePatternEntry(p)) .filter(Boolean); }, + prepTargetLabel() { + return String( + this.lesson?.course?.languageName + || this.lesson?.languageName + || this.$t('socialnetwork.vocab.courses.vocabPrepTargetLabel') + ).toUpperCase(); + }, + prepGlossLabel() { + return String( + this.lesson?.course?.nativeLanguageName + || this.lesson?.nativeLanguageName + || this.$t('socialnetwork.vocab.courses.vocabPrepGlossLabel') + ).toUpperCase(); + }, prepItems() { // Vorbereitung nur mit echten Paaren (Zielsprache + Übersetzung), // damit weder leere Gloss-Zeilen noch übergroße Listen entstehen. const out = []; const seen = new Set(); - const pushUnique = (target, gloss) => { + const nativeHints = new Set( + (this.importantVocab || []) + .map((x) => this.normalizeLessonVocabTerm(x?.learning)) + .filter(Boolean) + ); + const targetHints = new Set( + (this.importantVocab || []) + .map((x) => this.normalizeLessonVocabTerm(x?.reference)) + .filter(Boolean) + ); + const orientPair = (target, gloss) => { const t = String(target || '').trim(); const g = String(gloss || '').trim(); + if (!t || !g) return { target: t, gloss: g }; + const nt = this.normalizeLessonVocabTerm(t); + const ng = this.normalizeLessonVocabTerm(g); + const tLooksNative = nativeHints.has(nt) && !targetHints.has(nt); + const gLooksTarget = targetHints.has(ng) && !nativeHints.has(ng); + const tLooksTarget = targetHints.has(nt) && !nativeHints.has(nt); + const gLooksNative = nativeHints.has(ng) && !targetHints.has(ng); + if (tLooksNative && gLooksTarget && !(tLooksTarget && gLooksNative)) { + return { target: g, gloss: t }; + } + return { target: t, gloss: g }; + }; + const pushUnique = (target, gloss) => { + const oriented = orientPair(target, gloss); + const t = String(oriented.target || '').trim(); + const g = String(oriented.gloss || '').trim(); if (!t || !g) return; const key = `${this.normalizeLessonVocabTerm(t)}|${this.normalizeLessonVocabTerm(g)}`; if (seen.has(key)) return;