Enhance weather model and service logic; improve money history translation handling
- Added primary key to the Weather model for better data integrity. - Updated FalukantService to include specific weather attributes in queries, enhancing data retrieval. - Refactored money history view to utilize a dedicated translation method for improved localization handling.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(entry, index) in moneyHistory.data" :key="index">
|
||||
<td>{{ $t(`falukant.moneyHistory.activities.${entry.activity}`) }}</td>
|
||||
<td>{{ translateActivity(entry.activity) }}</td>
|
||||
<td>{{ entry.moneyBefore }}</td>
|
||||
<td>{{ entry.moneyAfter }}</td>
|
||||
<td>{{ entry.changeValue }}</td>
|
||||
@@ -79,6 +79,19 @@ export default {
|
||||
console.error('Error fetching money history:', error);
|
||||
}
|
||||
},
|
||||
translateActivity(activity) {
|
||||
// Handle nested keys like "health.pill" -> "health.pill"
|
||||
const key = `falukant.moneyHistory.activities.${activity}`;
|
||||
const translation = this.$t(key);
|
||||
// If translation is the same as key, try nested structure
|
||||
if (translation === key && activity.includes('.')) {
|
||||
const parts = activity.split('.');
|
||||
const nestedKey = `falukant.moneyHistory.activities.${parts[0]}.${parts[1]}`;
|
||||
const nestedTranslation = this.$t(nestedKey);
|
||||
return nestedTranslation !== nestedKey ? nestedTranslation : activity;
|
||||
}
|
||||
return translation !== key ? translation : activity;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user