fix: add plurilization to node pack count in custom node manager dialog (#8191)

This commit is contained in:
Christian Byrne
2026-01-20 15:52:40 -08:00
committed by GitHub
parent e8b45204f2
commit f5a784e561
3 changed files with 29 additions and 6 deletions

View File

@@ -158,6 +158,7 @@
"choose_file_to_upload": "choose file to upload",
"capture": "capture",
"nodes": "Nodes",
"nodesCount": "{count} nodes | {count} node | {count} nodes",
"community": "Community",
"all": "All",
"versionMismatchWarning": "Version Compatibility Warning",

View File

@@ -10,15 +10,22 @@ import type {
RegistryPack
} from '@/workbench/extensions/manager/types/comfyManagerTypes'
const translateMock = vi.hoisted(() =>
vi.fn((key: string, choice?: number) =>
typeof choice === 'number' ? `${key}-${choice}` : key
)
)
const dateMock = vi.hoisted(() => vi.fn(() => '2024. 1. 1.'))
// Mock dependencies
vi.mock('vue-i18n', () => ({
useI18n: vi.fn(() => ({
d: vi.fn(() => '2024. 1. 1.'),
t: vi.fn((key: string) => key)
d: dateMock,
t: translateMock
})),
createI18n: vi.fn(() => ({
global: {
t: vi.fn((key: string) => key),
t: translateMock,
te: vi.fn(() => true)
}
}))
@@ -187,6 +194,18 @@ describe('PackCard', () => {
// Should still render without errors
expect(wrapper.exists()).toBe(true)
})
it('should use localized singular/plural nodes label', () => {
const packWithNodes = {
...mockNodePack,
comfy_nodes: ['node-a']
} as MergedNodePack
const wrapper = createWrapper({ nodePack: packWithNodes })
expect(wrapper.text()).toContain('g.nodesCount-1')
expect(translateMock).toHaveBeenCalledWith('g.nodesCount', 1)
})
})
describe('component structure', () => {

View File

@@ -36,8 +36,8 @@
</p>
<div class="flex flex-col gap-y-2">
<div class="flex flex-1 items-center gap-2">
<div v-if="nodesCount" class="p-2 pl-0 text-xs">
{{ nodesCount }} {{ $t('g.nodes') }}
<div v-if="nodesLabel" class="p-2 pl-0 text-xs">
{{ nodesLabel }}
</div>
<PackVersionBadge
:node-pack="nodePack"
@@ -94,7 +94,7 @@ const { nodePack, isSelected = false } = defineProps<{
isSelected?: boolean
}>()
const { d } = useI18n()
const { d, t } = useI18n()
const colorPaletteStore = useColorPaletteStore()
const isLightTheme = computed(
@@ -115,6 +115,9 @@ const isDisabled = computed(
const nodesCount = computed(() =>
isMergedNodePack(nodePack) ? nodePack.comfy_nodes?.length : undefined
)
const nodesLabel = computed(() =>
nodesCount.value ? t('g.nodesCount', nodesCount.value) : ''
)
const publisherName = computed(() => {
if (!nodePack) return null