Enhance FalukantWidget gender label logic and add age-based labels: Updated gender label computation to include age-based distinctions for children and adults. Added new translation key for "years" in both German and English locale files.

This commit is contained in:
Torsten Schulz (local)
2026-02-09 15:12:23 +01:00
parent c8d8254fc1
commit b51d396afc
3 changed files with 18 additions and 3 deletions

View File

@@ -44,9 +44,18 @@ export default {
falukantGenderLabel() { falukantGenderLabel() {
const g = this.falukantData?.gender; const g = this.falukantData?.gender;
if (g == null || g === '') return '—'; if (g == null || g === '') return '—';
const key = `falukant.create.${g}`;
const t = this.$t(key); // Altersabhängige Bezeichnung (sprachlich natürlicher im Widget)
return t === key ? this.$t(`general.gender.${g}`) || g : t; // Default: unter 18 = Junge/Mädchen, sonst Mann/Frau
const age = Number(this.falukantData?.age);
const isChild = !Number.isNaN(age) && age < 18;
if (g === 'female') return isChild ? 'Mädchen' : 'Frau';
if (g === 'male') return isChild ? 'Junge' : 'Mann';
// Fallback auf vorhandene Übersetzungen
const key = `falukant.create.${g}`;
const t = this.$t(key);
return t === key ? this.$t(`general.gender.${g}`) || g : t;
}, },
falukantAgeLabel() { falukantAgeLabel() {
const ageValue = this.falukantData?.age; const ageValue = this.falukantData?.age;

View File

@@ -119,6 +119,7 @@
"name": "Name", "name": "Name",
"money": "Vermögen", "money": "Vermögen",
"age": "Alter", "age": "Alter",
"years": "Jahre",
"mainbranch": "Heimatstadt", "mainbranch": "Heimatstadt",
"nobleTitle": "Stand" "nobleTitle": "Stand"
}, },

View File

@@ -93,6 +93,11 @@
"children": "Children", "children": "Children",
"children_unbaptised": "Unbaptised children" "children_unbaptised": "Unbaptised children"
}, },
"overview": {
"metadata": {
"years": "years"
}
},
"health": { "health": {
"amazing": "Amazing", "amazing": "Amazing",
"good": "Good", "good": "Good",