fix: adding i18n keys for the fallback strings

This commit is contained in:
Csongor Czezar
2025-12-30 16:14:06 -08:00
parent dd435f86f5
commit 0e25a2f79b
3 changed files with 24 additions and 3 deletions

View File

@@ -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...",

View File

@@ -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,

View File

@@ -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'