mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-14 17:01:14 +08:00
feat: 动态删除已注册的语料数据的方法 (#5986)
Co-authored-by: 王玉振 <wangyuzhen01@wangyuzhen01.local>
This commit is contained in:
parent
6845f54628
commit
2b1b7175ec
@ -36,6 +36,7 @@ import {
|
||||
makeTranslator,
|
||||
register as registerLocale,
|
||||
extendLocale,
|
||||
removeLocaleData,
|
||||
localeable
|
||||
} from './locale';
|
||||
import type {LocaleProps, TranslateFn} from './locale';
|
||||
@ -140,6 +141,7 @@ export {
|
||||
registerLocale,
|
||||
makeTranslator,
|
||||
extendLocale,
|
||||
removeLocaleData,
|
||||
localeable,
|
||||
LocaleProps,
|
||||
TranslateFn,
|
||||
|
@ -27,6 +27,19 @@ export function extendLocale(name: string, config: LocaleConfig) {
|
||||
};
|
||||
}
|
||||
|
||||
/** 删除语料数据 */
|
||||
export function removeLocaleData(name: string, key: Array<string> | string) {
|
||||
if (Array.isArray(key)) {
|
||||
key.forEach(item => {
|
||||
removeLocaleData(name, item);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (locales?.[name]?.[key]) {
|
||||
delete locales[name][key];
|
||||
}
|
||||
}
|
||||
|
||||
const fns: {
|
||||
[propName: string]: TranslateFn;
|
||||
} = {};
|
||||
|
Loading…
Reference in New Issue
Block a user