diff --git a/components/drawer/drawer.tsx b/components/drawer/drawer.tsx index d23c9704..ea68aa97 100644 --- a/components/drawer/drawer.tsx +++ b/components/drawer/drawer.tsx @@ -19,6 +19,7 @@ import { useConfig } from '../config-provider'; import { useTheme } from '../_theme/useTheme'; import { pxfy } from '../_util/utils'; import useEsc from '../_util/use/useEsc'; +import { useLocale } from '../config-provider/useLocale'; import { useResizable } from './useResizable'; import { COMPONENT_NAME, prefixCls } from './const'; import { @@ -63,6 +64,8 @@ const Drawer = defineComponent({ () => props.getContainer || config.getContainer?.value, ); + const { t } = useLocale(); + function handleCancel(event: MouseEvent | KeyboardEvent) { ctx.emit(UPDATE_SHOW_EVENT, false); ctx.emit(CANCEL_EVENT, event); @@ -120,11 +123,11 @@ const Drawer = defineComponent({ onClick={handleOk} loading={props.okLoading} > - {props.okText} + {props.okText || t('drawer.okText')} {props.showCancel && ( - {props.cancelText} + {props.cancelText || t('drawer.cancelText')} )} diff --git a/components/drawer/props.ts b/components/drawer/props.ts index b7c12932..42ef0482 100644 --- a/components/drawer/props.ts +++ b/components/drawer/props.ts @@ -36,15 +36,9 @@ export const drawerProps = { default: false, }, title: String, - okText: { - type: String, - default: '确定', - }, + okText: String, okLoading: Boolean, - cancelText: { - type: String, - default: '取消', - }, + cancelText: String, showCancel: { type: Boolean, default: true, diff --git a/components/locales/lang/enUS.ts b/components/locales/lang/enUS.ts index 9afac52e..960b1931 100644 --- a/components/locales/lang/enUS.ts +++ b/components/locales/lang/enUS.ts @@ -99,4 +99,12 @@ export default { okText: 'Confirm', cancelText: 'Cancel', }, + drawer: { + okText: 'Confirm', + cancelText: 'Cancel', + }, + tooltip: { + okText: 'Confirm', + cancelText: 'Cancel', + }, }; diff --git a/components/locales/lang/zhCN.ts b/components/locales/lang/zhCN.ts index f7cc66c8..a33dc12c 100644 --- a/components/locales/lang/zhCN.ts +++ b/components/locales/lang/zhCN.ts @@ -98,4 +98,12 @@ export default { okText: '确定', cancelText: '取消', }, + drawer: { + okText: '确定', + cancelText: '取消', + }, + tooltip: { + okText: '确定', + cancelText: '取消', + }, }; diff --git a/components/locales/lang/zr.ts b/components/locales/lang/zr.ts index 2b33b7e0..9a2d0788 100644 --- a/components/locales/lang/zr.ts +++ b/components/locales/lang/zr.ts @@ -99,4 +99,12 @@ export default { okText: 'تأكيد', cancelText: 'إلغاء', }, + drawer: { + okText: 'تأكيد', + cancelText: 'إلغاء', + }, + tooltip: { + okText: 'تأكيد', + cancelText: 'إلغاء', + }, }; diff --git a/components/tooltip/tooltip.tsx b/components/tooltip/tooltip.tsx index 4d2d9464..be6cc1f5 100644 --- a/components/tooltip/tooltip.tsx +++ b/components/tooltip/tooltip.tsx @@ -15,12 +15,13 @@ import FButton from '../button/button'; import { popperProps } from '../popper/props'; import { CANCEL_EVENT, OK_EVENT, UPDATE_MODEL_EVENT } from '../_util/constants'; import type { ExtractPublicPropTypes } from '../_util/interface'; +import { useLocale } from '../config-provider/useLocale'; const prefixCls = getPrefixCls('tooltip'); const defaultConfirmOption = { - okText: '确定', - cancelText: '取消', + okText: '', + cancelText: '', showOk: true, showCancel: true, icon: , @@ -64,6 +65,8 @@ export default defineComponent({ currentValue.value = val; }; + const { t } = useLocale(); + const popperElRef = ref(null); function getPopperSlots() { @@ -134,7 +137,7 @@ export default defineComponent({ size="small" type="primary" > - {mergeOpt.okText} + {mergeOpt.okText || t('tooltip.okText')} )} { @@ -146,7 +149,7 @@ export default defineComponent({ } size="small" > - {mergeOpt.cancelText} + {mergeOpt.cancelText || t('tooltip.cancelText')} ) }