Skip to content

Commit 9ff6b4e

Browse files
committed
fix: i18n für Dashboard-Widget 'Dein Modell im Vergleich'
Card-Titel, Varianten-Subtitle, Reichweiten-Einheit, Hover-Referenz, Empty-State und Error-Fallback waren auf Deutsch hardcoded. Keys in allen 4 Locales (de/en/nb/sv) ergaenzt. categories auf computed umgestellt, damit Labels/Einheiten bei Sprachwechsel reaktiv bleiben.
1 parent 70de71c commit 9ff6b4e

5 files changed

Lines changed: 36 additions & 12 deletions

File tree

frontend/src/components/dashboard/PeerModelComparisonCard.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ const currentCategoryIndex = ref(0)
2929
const slideDirection = ref('slide-next')
3030
const hoveredSpecId = ref<string | null>(null)
3131
32-
const categories = [
32+
const categories = computed(() => [
3333
{ id: 'consumption', label: t('dashboard.peer_consumption'), unit: 'kWh/100km', shortUnit: 'kWh/100km', color: 'blue', sortAsc: true },
3434
{ id: 'costPerKwh', label: t('dashboard.peer_cost_label'), unit: '€/kWh', shortUnit: '€/kWh', color: 'purple', sortAsc: true },
3535
{ id: 'costPer100km', label: t('dashboard.peer_cost_per_distance'), unit: '€/100km', shortUnit: '€/100km', color: 'orange', sortAsc: true },
36-
{ id: 'range', label: t('dashboard.peer_range'), unit: 'km (Nettokapazität)', shortUnit: 'km', color: 'green', sortAsc: false },
37-
]
36+
{ id: 'range', label: t('dashboard.peer_range'), unit: t('dashboard.peer_range_unit'), shortUnit: 'km', color: 'green', sortAsc: false },
37+
])
3838
39-
const currentCategory = computed(() => categories[currentCategoryIndex.value])
39+
const currentCategory = computed(() => categories.value[currentCategoryIndex.value])
4040
4141
const visibleComparisons = computed(() =>
4242
comparisons.value
@@ -55,12 +55,12 @@ const visibleComparisons = computed(() =>
5555
5656
function nextCategory() {
5757
slideDirection.value = 'slide-next'
58-
currentCategoryIndex.value = (currentCategoryIndex.value + 1) % categories.length
58+
currentCategoryIndex.value = (currentCategoryIndex.value + 1) % categories.value.length
5959
}
6060
6161
function prevCategory() {
6262
slideDirection.value = 'slide-prev'
63-
currentCategoryIndex.value = (currentCategoryIndex.value - 1 + categories.length) % categories.length
63+
currentCategoryIndex.value = (currentCategoryIndex.value - 1 + categories.value.length) % categories.value.length
6464
}
6565
6666
onMounted(async () => {
@@ -70,7 +70,7 @@ onMounted(async () => {
7070
const response = await peerModelComparisonService.getPeerModelComparison(props.carId)
7171
comparisons.value = response.modelComparisons
7272
} catch (err) {
73-
error.value = err instanceof Error ? err.message : 'Failed to load peer data'
73+
error.value = err instanceof Error ? err.message : t('dashboard.peer_load_error')
7474
} finally {
7575
loading.value = false
7676
}
@@ -145,7 +145,7 @@ function getRelativePercent(item: PeerModelComparisonItem): string | null {
145145
const refVal = getItemValue(hoveredItem, currentCategory.value.id)
146146
const ownVal = getItemValue(item, currentCategory.value.id)
147147
if (refVal === null || ownVal === null || refVal === 0) return null
148-
if (item.vehicleSpecificationId === hoveredSpecId.value) return 'Referenz'
148+
if (item.vehicleSpecificationId === hoveredSpecId.value) return t('dashboard.peer_reference')
149149
const diff = Math.round((ownVal - refVal) / refVal * 100)
150150
return diff > 0 ? `+${diff}%` : `${diff}%`
151151
}
@@ -182,7 +182,7 @@ function getDisplayBarWidth(item: PeerModelComparisonItem): number {
182182
<ChevronLeftIcon class="w-4 h-4 text-gray-600 dark:text-gray-300" />
183183
</button>
184184
<button @click="toggleCollapsed" class="flex-1 flex flex-col items-center text-center min-w-0">
185-
<p class="text-xs font-semibold text-gray-800 dark:text-gray-200">Dein {{ carBrandModel }} im Vergleich</p>
185+
<p class="text-xs font-semibold text-gray-800 dark:text-gray-200">{{ t('dashboard.peer_card_title', { model: carBrandModel }) }}</p>
186186
<p class="text-xs text-gray-500 dark:text-gray-400 mt-0.5">{{ currentCategory.label }} · {{ currentCategory.unit }} · {{ currentCategoryIndex + 1 }}/{{ categories.length }}</p>
187187
</button>
188188
<button @click="nextCategory" class="p-1.5 hover:bg-gray-100 dark:hover:bg-gray-600 rounded shrink-0">
@@ -202,8 +202,8 @@ function getDisplayBarWidth(item: PeerModelComparisonItem): number {
202202
</button>
203203

204204
<div class="flex-1 text-center">
205-
<p class="text-sm font-semibold text-gray-800 dark:text-gray-200">Dein {{ carBrandModel }} im Vergleich</p>
206-
<p class="text-xs text-gray-400 dark:text-gray-500">{{ visibleComparisons.length }} Varianten · gesamter Zeitraum</p>
205+
<p class="text-sm font-semibold text-gray-800 dark:text-gray-200">{{ t('dashboard.peer_card_title', { model: carBrandModel }) }}</p>
206+
<p class="text-xs text-gray-400 dark:text-gray-500">{{ t('dashboard.peer_card_variants', { count: visibleComparisons.length }) }}</p>
207207
</div>
208208

209209
<div class="flex items-center gap-3">
@@ -235,7 +235,7 @@ function getDisplayBarWidth(item: PeerModelComparisonItem): number {
235235

236236
<!-- Empty state -->
237237
<div v-else-if="visibleComparisons.length === 0" class="p-4 text-center text-xs text-gray-500 dark:text-gray-400">
238-
<p>Keine Vergleichsdaten verfügbar</p>
238+
<p>{{ t('dashboard.peer_no_comparison_data') }}</p>
239239
</div>
240240

241241
<!-- Category Carousel -->

frontend/src/locales/de.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,12 @@ dashboard:
582582
peer_model_fallback: "Vergleich mit {n} Fahrern des gleichen Modells (alle Varianten)"
583583
peer_no_data_title: "Kein Vergleich verfügbar"
584584
peer_no_data_body: "Sobald mehr Fahrer mit gleichem Modell Daten erfassen, erscheint hier dein Community-Vergleich."
585+
peer_card_title: "Dein {model} im Vergleich"
586+
peer_card_variants: "{count} Varianten · gesamter Zeitraum"
587+
peer_range_unit: "km (Nettokapazität)"
588+
peer_reference: "Referenz"
589+
peer_no_comparison_data: "Keine Vergleichsdaten verfügbar"
590+
peer_load_error: "Vergleichsdaten konnten nicht geladen werden"
585591
charging_type_split_title: "Ladeverteilung"
586592
charging_type_ac: "AC"
587593
charging_type_dc: "DC"

frontend/src/locales/en.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,12 @@ dashboard:
582582
peer_model_fallback: "Comparing with {n} drivers of the same model (all variants)"
583583
peer_no_data_title: "No comparison available"
584584
peer_no_data_body: "Once more drivers with the same model track their data, your community comparison will appear here."
585+
peer_card_title: "Your {model} in comparison"
586+
peer_card_variants: "{count} variants · all time"
587+
peer_range_unit: "km (net capacity)"
588+
peer_reference: "Reference"
589+
peer_no_comparison_data: "No comparison data available"
590+
peer_load_error: "Could not load comparison data"
585591
charging_type_split_title: "Charging Distribution"
586592
charging_type_ac: "AC"
587593
charging_type_dc: "DC"

frontend/src/locales/nb.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ dashboard:
542542
peer_model_fallback: Sammenligner med {n} sjåfører av samme modell (alle varianter)
543543
peer_no_data_title: Ingen sammenligning tilgjengelig
544544
peer_no_data_body: Når flere sjåfører med samme modell registrerer data, vil sammenligningen din vises her.
545+
peer_card_title: "Din {model} i sammenligning"
546+
peer_card_variants: "{count} varianter · hele perioden"
547+
peer_range_unit: km (nettokapasitet)
548+
peer_reference: Referanse
549+
peer_no_comparison_data: Ingen sammenligningsdata tilgjengelig
550+
peer_load_error: Kunne ikke laste sammenligningsdata
545551
charging_type_split_title: Ladefordeling
546552
charging_type_ac: AC
547553
charging_type_dc: DC

frontend/src/locales/sv.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ dashboard:
542542
peer_model_fallback: Jämför med {n} förare av samma modell (alla varianter)
543543
peer_no_data_title: Ingen jämförelse tillgänglig
544544
peer_no_data_body: När fler förare med samma modell registrerar data visas din jämförelse här.
545+
peer_card_title: "Din {model} i jämförelse"
546+
peer_card_variants: "{count} varianter · hela perioden"
547+
peer_range_unit: km (nettokapacitet)
548+
peer_reference: Referens
549+
peer_no_comparison_data: Inga jämförelsedata tillgängliga
550+
peer_load_error: Kunde inte ladda jämförelsedata
545551
charging_type_split_title: Laddningsfordelning
546552
charging_type_ac: AC
547553
charging_type_dc: DC

0 commit comments

Comments
 (0)