diff --git a/components/config-provider/index.tsx b/components/config-provider/index.tsx index 8705ecb9c..e0ce9eb82 100644 --- a/components/config-provider/index.tsx +++ b/components/config-provider/index.tsx @@ -1,5 +1,5 @@ import type { App, Plugin, WatchStopHandle } from 'vue'; -import { computed, reactive, defineComponent, watchEffect } from 'vue'; +import { watch, computed, reactive, defineComponent, watchEffect } from 'vue'; import defaultRenderEmpty from './renderEmpty'; import type { RenderEmptyHandler } from './renderEmpty'; import type { Locale } from '../locale-provider'; @@ -157,6 +157,13 @@ const ConfigProvider = defineComponent({ () => props.autoInsertSpaceInButton ?? parentContext.autoInsertSpaceInButton?.value, ); const locale = computed(() => props.locale || parentContext.locale?.value); + watch( + locale, + () => { + globalConfigBySet.locale = locale.value; + }, + { immediate: true }, + ); const direction = computed(() => props.direction || parentContext.direction?.value); const space = computed(() => props.space ?? parentContext.space?.value); const virtual = computed(() => props.virtual ?? parentContext.virtual?.value); diff --git a/components/locale/index.tsx b/components/locale/index.tsx index 1c45e6ab6..0f7a8c59f 100644 --- a/components/locale/index.tsx +++ b/components/locale/index.tsx @@ -1,6 +1,7 @@ import type { App, VNode, PropType } from 'vue'; import { provide, defineComponent, reactive, watch } from 'vue'; import type { ModalLocale } from '../modal/locale'; +import { changeConfirmLocale } from '../modal/locale'; import warning from '../_util/warning'; import { withInstall } from '../_util/type'; import type { ValidateMessages } from '../form/interface'; @@ -81,9 +82,10 @@ const LocaleProvider = defineComponent({ provide('localeData', state); watch( () => props.locale, - () => { + locale => { + changeConfirmLocale(locale && locale.Modal); state.antLocale = { - ...props.locale, + ...locale, exist: true, } as any; },