mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 12:38:58 +08:00
2b629ef391
* type: rm useless type of reducer * Update components/_util/ActionButton.tsx Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com>
41 lines
886 B
TypeScript
41 lines
886 B
TypeScript
import defaultLocale from '../locale/en_US';
|
|
|
|
export interface ModalLocale {
|
|
okText: string;
|
|
cancelText: string;
|
|
justOkText: string;
|
|
}
|
|
|
|
let runtimeLocale: ModalLocale = {
|
|
...(defaultLocale.Modal as ModalLocale),
|
|
};
|
|
|
|
let localeList: ModalLocale[] = [];
|
|
|
|
const generateLocale = () =>
|
|
localeList.reduce<ModalLocale>(
|
|
(merged, locale) => ({ ...merged, ...locale }),
|
|
defaultLocale.Modal!,
|
|
);
|
|
|
|
export function changeConfirmLocale(newLocale?: ModalLocale) {
|
|
if (newLocale) {
|
|
const cloneLocale = { ...newLocale };
|
|
localeList.push(cloneLocale);
|
|
runtimeLocale = generateLocale();
|
|
|
|
return () => {
|
|
localeList = localeList.filter((locale) => locale !== cloneLocale);
|
|
runtimeLocale = generateLocale();
|
|
};
|
|
}
|
|
|
|
runtimeLocale = {
|
|
...(defaultLocale.Modal as ModalLocale),
|
|
};
|
|
}
|
|
|
|
export function getConfirmLocale() {
|
|
return runtimeLocale;
|
|
}
|