fix: Make bottom panel tab titles reactive to language changes (#5077)

* computed extraMenuItems

* add i18n key option

* underline fix

* Update locales [skip ci]

* restore title

* Update locales [skip ci]

* refactor: Extract tab title logic to helper method for better readability

- Moved complex nested ternary logic from template to getTabDisplayTitle helper
- Improves code readability and maintainability
- Addresses review feedback about using computed/method for performance

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Benjamin Lu
2025-08-18 19:27:21 -04:00
committed by GitHub
parent 75d7a3725b
commit 7a1a2dd654
11 changed files with 45 additions and 33 deletions

View File

@@ -1,6 +1,9 @@
<template>
<div class="flex flex-col h-full">
<Tabs v-model:value="bottomPanelStore.activeBottomPanelTabId">
<Tabs
:key="$i18n.locale"
v-model:value="bottomPanelStore.activeBottomPanelTabId"
>
<TabList pt:tab-list="border-none">
<div class="w-full flex justify-between">
<div class="tabs-container">
@@ -11,11 +14,7 @@
class="p-3 border-none"
>
<span class="font-bold">
{{
shouldCapitalizeTab(tab.id)
? tab.title.toUpperCase()
: tab.title
}}
{{ getTabDisplayTitle(tab) }}
</span>
</Tab>
</div>
@@ -60,13 +59,16 @@ import Tab from 'primevue/tab'
import TabList from 'primevue/tablist'
import Tabs from 'primevue/tabs'
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import ExtensionSlot from '@/components/common/ExtensionSlot.vue'
import { useDialogService } from '@/services/dialogService'
import { useBottomPanelStore } from '@/stores/workspace/bottomPanelStore'
import type { BottomPanelExtension } from '@/types/extensionTypes'
const bottomPanelStore = useBottomPanelStore()
const dialogService = useDialogService()
const { t } = useI18n()
const isShortcutsTabActive = computed(() => {
const activeTabId = bottomPanelStore.activeBottomPanelTabId
@@ -80,6 +82,11 @@ const shouldCapitalizeTab = (tabId: string): boolean => {
return tabId !== 'shortcuts-essentials' && tabId !== 'shortcuts-view-controls'
}
const getTabDisplayTitle = (tab: BottomPanelExtension): string => {
const title = tab.titleKey ? t(tab.titleKey) : tab.title || ''
return shouldCapitalizeTab(tab.id) ? title.toUpperCase() : title
}
const openKeybindingSettings = async () => {
dialogService.showSettingsDialog('keybinding')
}