Implement age-based gender labels in FalukantWidget and update translations: Added logic to determine gender labels based on age groups and updated locale files for German and English.
This commit is contained in:
@@ -45,17 +45,19 @@ export default {
|
|||||||
const g = this.falukantData?.gender;
|
const g = this.falukantData?.gender;
|
||||||
if (g == null || g === '') return '—';
|
if (g == null || g === '') return '—';
|
||||||
|
|
||||||
// Altersabhängige Bezeichnung (sprachlich natürlicher im Widget)
|
// Altersabhängige, (auf Wunsch) altertümlichere Bezeichnungen
|
||||||
// Default: unter 18 = Junge/Mädchen, sonst Mann/Frau
|
const age = Number(this.falukantData?.age);
|
||||||
const age = Number(this.falukantData?.age);
|
const group = this._getAgeGroupKey(age);
|
||||||
const isChild = !Number.isNaN(age) && age < 18;
|
if (group && (g === 'female' || g === 'male')) {
|
||||||
if (g === 'female') return isChild ? 'Mädchen' : 'Frau';
|
const key = `falukant.genderAge.${g}.${group}`;
|
||||||
if (g === 'male') return isChild ? 'Junge' : 'Mann';
|
const t = this.$t(key);
|
||||||
|
if (t !== key) return t;
|
||||||
|
}
|
||||||
|
|
||||||
// Fallback auf vorhandene Übersetzungen
|
// Fallback auf vorhandene Übersetzungen
|
||||||
const key = `falukant.create.${g}`;
|
const key = `falukant.create.${g}`;
|
||||||
const t = this.$t(key);
|
const t = this.$t(key);
|
||||||
return t === key ? this.$t(`general.gender.${g}`) || g : t;
|
return t === key ? this.$t(`general.gender.${g}`) || g : t;
|
||||||
},
|
},
|
||||||
falukantAgeLabel() {
|
falukantAgeLabel() {
|
||||||
const ageValue = this.falukantData?.age;
|
const ageValue = this.falukantData?.age;
|
||||||
@@ -65,6 +67,31 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
_getAgeGroupKey(age) {
|
||||||
|
const a = Number(age);
|
||||||
|
if (Number.isNaN(a)) return null;
|
||||||
|
|
||||||
|
// Pro Sprache konfigurierbare Schwellenwerte aus i18n.
|
||||||
|
// Format: "key:maxAge|key2:maxAge2|..." (maxAge exklusiv, letzte Gruppe sollte hoch gesetzt sein)
|
||||||
|
const raw = this.$t('falukant.genderAge.ageGroups');
|
||||||
|
const parsed = typeof raw === 'string' ? raw : '';
|
||||||
|
const rules = parsed.split('|')
|
||||||
|
.map(part => part.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
.map(part => {
|
||||||
|
const [key, num] = part.split(':').map(s => (s ?? '').trim());
|
||||||
|
return { key, max: Number(num) };
|
||||||
|
})
|
||||||
|
.filter(r => r.key && !Number.isNaN(r.max))
|
||||||
|
.sort((x, y) => x.max - y.max);
|
||||||
|
|
||||||
|
for (const r of rules) {
|
||||||
|
if (a < r.max) return r.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback, falls Konfig kaputt ist
|
||||||
|
return 'adult';
|
||||||
|
},
|
||||||
formatMoney(value) {
|
formatMoney(value) {
|
||||||
const n = Number(value);
|
const n = Number(value);
|
||||||
if (Number.isNaN(n)) return '—';
|
if (Number.isNaN(n)) return '—';
|
||||||
|
|||||||
@@ -138,6 +138,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"genderAge": {
|
||||||
|
"ageGroups": "infant:2|toddler:4|child:12|teen:18|youngAdult:25|adult:50|mature:70|elder:999",
|
||||||
|
"male": {
|
||||||
|
"infant": "Säugling",
|
||||||
|
"toddler": "Knirps",
|
||||||
|
"child": "Knabe",
|
||||||
|
"teen": "Jüngling",
|
||||||
|
"youngAdult": "Junker",
|
||||||
|
"adult": "Mann",
|
||||||
|
"mature": "Herr",
|
||||||
|
"elder": "Greis"
|
||||||
|
},
|
||||||
|
"female": {
|
||||||
|
"infant": "Säugling",
|
||||||
|
"toddler": "Knirps",
|
||||||
|
"child": "Maid",
|
||||||
|
"teen": "Jungfer",
|
||||||
|
"youngAdult": "Jungfrau",
|
||||||
|
"adult": "Frau",
|
||||||
|
"mature": "Dame",
|
||||||
|
"elder": "Greisin"
|
||||||
|
}
|
||||||
|
},
|
||||||
"titles": {
|
"titles": {
|
||||||
"male": {
|
"male": {
|
||||||
"noncivil": "Leibeigener",
|
"noncivil": "Leibeigener",
|
||||||
|
|||||||
@@ -98,6 +98,29 @@
|
|||||||
"years": "years"
|
"years": "years"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"genderAge": {
|
||||||
|
"ageGroups": "infant:2|toddler:4|child:12|teen:18|youngAdult:25|adult:50|mature:70|elder:999",
|
||||||
|
"male": {
|
||||||
|
"infant": "infant",
|
||||||
|
"toddler": "toddler",
|
||||||
|
"child": "boy",
|
||||||
|
"teen": "youth",
|
||||||
|
"youngAdult": "young man",
|
||||||
|
"adult": "man",
|
||||||
|
"mature": "sir",
|
||||||
|
"elder": "old man"
|
||||||
|
},
|
||||||
|
"female": {
|
||||||
|
"infant": "infant",
|
||||||
|
"toddler": "toddler",
|
||||||
|
"child": "girl",
|
||||||
|
"teen": "maiden",
|
||||||
|
"youngAdult": "young woman",
|
||||||
|
"adult": "woman",
|
||||||
|
"mature": "lady",
|
||||||
|
"elder": "old woman"
|
||||||
|
}
|
||||||
|
},
|
||||||
"health": {
|
"health": {
|
||||||
"amazing": "Amazing",
|
"amazing": "Amazing",
|
||||||
"good": "Good",
|
"good": "Good",
|
||||||
|
|||||||
Reference in New Issue
Block a user