mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-01 22:09:55 +00:00
fix: adding i18n keys for the fallback strings
This commit is contained in:
@@ -2044,6 +2044,10 @@
|
||||
"Set Group Nodes to Always": "Set Group Nodes to Always"
|
||||
},
|
||||
"widgets": {
|
||||
"boolean": {
|
||||
"true": "true",
|
||||
"false": "false"
|
||||
},
|
||||
"selectModel": "Select model",
|
||||
"uploadSelect": {
|
||||
"placeholder": "Select...",
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import PrimeVue from 'primevue/config'
|
||||
import ToggleSwitch from 'primevue/toggleswitch'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
|
||||
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
|
||||
|
||||
import WidgetToggleSwitch from './WidgetToggleSwitch.vue'
|
||||
|
||||
vi.mock('vue-i18n', () => ({
|
||||
useI18n: () => ({
|
||||
t: (key: string) => {
|
||||
const translations: Record<string, string> = {
|
||||
'widgets.boolean.true': 'true',
|
||||
'widgets.boolean.false': 'false'
|
||||
}
|
||||
return translations[key] || key
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
describe('WidgetToggleSwitch Value Binding', () => {
|
||||
const createMockWidget = (
|
||||
value: boolean = false,
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<script setup lang="ts">
|
||||
import ToggleSwitch from 'primevue/toggleswitch'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
|
||||
import type { SimplifiedWidget } from '@/types/simplifiedWidget'
|
||||
@@ -60,6 +61,8 @@ const { widget } = defineProps<{
|
||||
|
||||
const modelValue = defineModel<boolean>()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const filteredProps = computed(() =>
|
||||
filterWidgetProps(widget.options, STANDARD_EXCLUDED_PROPS)
|
||||
)
|
||||
@@ -68,8 +71,10 @@ const hasLabels = computed(() => {
|
||||
return !!(widget.options?.on || widget.options?.off)
|
||||
})
|
||||
|
||||
const labelOn = computed(() => widget.options?.on ?? 'true')
|
||||
const labelOff = computed(() => widget.options?.off ?? 'false')
|
||||
const labelOn = computed(() => widget.options?.on ?? t('widgets.boolean.true'))
|
||||
const labelOff = computed(
|
||||
() => widget.options?.off ?? t('widgets.boolean.false')
|
||||
)
|
||||
|
||||
const toggleGroupValue = computed(() => {
|
||||
return modelValue.value ? 'on' : 'off'
|
||||
|
||||
Reference in New Issue
Block a user