[fix] use getter functions for sidebar tab command labels to resolve i18n collection issues (#4370)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Christian Byrne
2025-07-08 23:50:49 -07:00
committed by GitHub
parent f5b03f323d
commit 22c70d5d1b
16 changed files with 84 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ import { useModelLibrarySidebarTab } from '@/composables/sidebarTabs/useModelLib
import { useNodeLibrarySidebarTab } from '@/composables/sidebarTabs/useNodeLibrarySidebarTab'
import { useQueueSidebarTab } from '@/composables/sidebarTabs/useQueueSidebarTab'
import { useWorkflowsSidebarTab } from '@/composables/sidebarTabs/useWorkflowsSidebarTab'
import { t, te } from '@/i18n'
import { useCommandStore } from '@/stores/commandStore'
import { SidebarTabExtension } from '@/types/extensionTypes'
@@ -25,11 +26,23 @@ export const useSidebarTabStore = defineStore('sidebarTab', () => {
const registerSidebarTab = (tab: SidebarTabExtension) => {
sidebarTabs.value = [...sidebarTabs.value, tab]
// Generate label in format "Toggle X Sidebar"
const labelFunction = () => {
const tabTitle = te(tab.title) ? t(tab.title) : tab.title
return `Toggle ${tabTitle} Sidebar`
}
const tooltipFunction = tab.tooltip
? te(String(tab.tooltip))
? () => t(String(tab.tooltip))
: String(tab.tooltip)
: undefined
useCommandStore().registerCommand({
id: `Workspace.ToggleSidebarTab.${tab.id}`,
icon: tab.icon,
label: tab.title,
tooltip: tab.tooltip,
label: labelFunction,
tooltip: tooltipFunction,
versionAdded: '1.3.9',
function: () => {
toggleSidebarTab(tab.id)