Skip to content

Commit 6b5dca8

Browse files
committed
proper implementation for the optional translator
1 parent 3a4f2b9 commit 6b5dca8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/vue-vuetify/src/controls/components/ValidationBadge.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
</v-badge>
1818
</template>
1919

20-
<p>{{ t('Validation Errors', 'Validation Errors') }}</p>
20+
<p>
21+
{{
22+
t ? t('Validation Errors', 'Validation Errors') : 'Validation Errors'
23+
}}
24+
</p>
2125
<p
2226
v-for="(message, index) in tooltipMessages"
2327
:key="`${tooltipMessages.length}-${index}`"
@@ -31,13 +35,14 @@
3135
</template>
3236

3337
<script lang="ts">
34-
import { defineComponent, type PropType } from 'vue';
38+
import { defineComponent, inject, type PropType } from 'vue';
3539
import { VBadge, VTooltip } from 'vuetify/components';
3640
import type { ErrorObject } from 'ajv';
3741
import findIndex from 'lodash/findIndex';
3842
import {
3943
createControlElement,
4044
createLabelDescriptionFrom,
45+
type JsonFormsSubStates,
4146
type JsonSchema,
4247
} from '@jsonforms/core';
4348
import { useTranslator } from '@/util';
@@ -118,8 +123,13 @@ export default defineComponent({
118123
},
119124
},
120125
setup() {
121-
const t = useTranslator();
126+
// allow using the ValidationBadge outside the jsonforms like in the ExampleView in the demo app
127+
const jsonforms = inject<JsonFormsSubStates | undefined>(
128+
'jsonforms',
129+
undefined,
130+
);
122131
132+
const t = jsonforms !== undefined ? useTranslator() : null;
123133
return { t };
124134
},
125135
});

0 commit comments

Comments
 (0)