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;
|
||||
if (g == null || g === '') return '—';
|
||||
|
||||
// Altersabhängige Bezeichnung (sprachlich natürlicher im Widget)
|
||||
// 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';
|
||||
// Altersabhängige, (auf Wunsch) altertümlichere Bezeichnungen
|
||||
const age = Number(this.falukantData?.age);
|
||||
const group = this._getAgeGroupKey(age);
|
||||
if (group && (g === 'female' || g === 'male')) {
|
||||
const key = `falukant.genderAge.${g}.${group}`;
|
||||
const t = this.$t(key);
|
||||
if (t !== key) return t;
|
||||
}
|
||||
|
||||
// Fallback auf vorhandene Übersetzungen
|
||||
const key = `falukant.create.${g}`;
|
||||
const t = this.$t(key);
|
||||
return t === key ? this.$t(`general.gender.${g}`) || g : t;
|
||||
// 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() {
|
||||
const ageValue = this.falukantData?.age;
|
||||
@@ -65,6 +67,31 @@ export default {
|
||||
}
|
||||
},
|
||||
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) {
|
||||
const n = Number(value);
|
||||
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": {
|
||||
"male": {
|
||||
"noncivil": "Leibeigener",
|
||||
|
||||
@@ -98,6 +98,29 @@
|
||||
"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": {
|
||||
"amazing": "Amazing",
|
||||
"good": "Good",
|
||||
|
||||
Reference in New Issue
Block a user