Update age representation in DashboardWidget: Modify falukantAgeLabel computed property to display age in days if less than a year, otherwise show in years. Add localization for "days" in both German and English language files to support the new age format.

This commit is contained in:
Torsten Schulz (local)
2026-01-30 10:05:30 +01:00
parent ddefc2737b
commit 8fd15614af
3 changed files with 12 additions and 4 deletions

View File

@@ -122,10 +122,16 @@ export default {
return t === key ? this.$t(`general.gender.${g}`) || g : t; return t === key ? this.$t(`general.gender.${g}`) || g : t;
}, },
falukantAgeLabel() { falukantAgeLabel() {
const days = this.falukantData?.age; const ageValue = this.falukantData?.age;
if (days == null) return '—'; if (ageValue == null) return '—';
const years = Math.floor(Number(days) / 365); const numAge = Number(ageValue);
return `${years} ${this.$t('falukant.overview.metadata.years')}`; // Backend gibt Tage zurück (calcAge verwendet differenceInDays)
// Wenn < 365 Tage: Tage anzeigen, sonst Jahre
if (numAge < 365) {
return `${numAge} ${this.$t('falukant.overview.metadata.days')}`;
} else {
return `${numAge} ${this.$t('falukant.overview.metadata.years')}`;
}
}, },
dataList() { dataList() {
if (!Array.isArray(this.data) || this.data.length === 0) return []; if (!Array.isArray(this.data) || this.data.length === 0) return [];

View File

@@ -120,6 +120,7 @@
"money": "Vermögen", "money": "Vermögen",
"age": "Alter", "age": "Alter",
"years": "Jahre", "years": "Jahre",
"days": "Tage",
"mainbranch": "Heimatstadt", "mainbranch": "Heimatstadt",
"nobleTitle": "Stand" "nobleTitle": "Stand"
}, },

View File

@@ -101,6 +101,7 @@
"money": "Wealth", "money": "Wealth",
"age": "Age", "age": "Age",
"years": "Years", "years": "Years",
"days": "Days",
"mainbranch": "Home city", "mainbranch": "Home city",
"nobleTitle": "Title" "nobleTitle": "Title"
} }