为 DeleteWithConfirmButton 设置自定义消息 react-admin
Set custom message for DeleteWithConfirmButton react-admin
我如何才能将消息发送到 DeleteWithConfirmButton,而不是全局发送到一个?
我可以全局更改消息:
const messages = {
en: {
ra: {
message: {
delete_contents: 'HELLO?'
}
}
}
};
const i18nProvider = locale => messages[locale];
<Admin
i18nProvider={i18nProvider}
delete_content: 'Are you sure you want to delete this item?', - 默认消息
DeleteWithConfirmButton.propTypes = {
basePath: PropTypes.string,
classes: PropTypes.object,
className: PropTypes.string,
crudDelete: PropTypes.func.isRequired,
label: PropTypes.string,
record: PropTypes.object,
redirect: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
PropTypes.func,
]),
resource: PropTypes.string.isRequired,
translate: PropTypes.func,
icon: PropTypes.element,
};
在当前版本React-admin中,DeleteButton / BulkDeleteButton 组件具有 confirmTitle / confirmContent 属性,可以设置自定义 header 和对话框内容:
DeleteWithConfirmButton.propTypes = {
basePath: PropTypes.string,
classes: PropTypes.object,
className: PropTypes.string,
confirmTitle: PropTypes.string,
confirmContent: PropTypes.string,
label: PropTypes.string,
record: PropTypes.any,
redirect: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
PropTypes.func,
]),
resource: PropTypes.string,
icon: PropTypes.element,
};
我如何才能将消息发送到 DeleteWithConfirmButton,而不是全局发送到一个?
我可以全局更改消息:
const messages = {
en: {
ra: {
message: {
delete_contents: 'HELLO?'
}
}
}
};
const i18nProvider = locale => messages[locale];
<Admin
i18nProvider={i18nProvider}
delete_content: 'Are you sure you want to delete this item?', - 默认消息
DeleteWithConfirmButton.propTypes = {
basePath: PropTypes.string,
classes: PropTypes.object,
className: PropTypes.string,
crudDelete: PropTypes.func.isRequired,
label: PropTypes.string,
record: PropTypes.object,
redirect: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
PropTypes.func,
]),
resource: PropTypes.string.isRequired,
translate: PropTypes.func,
icon: PropTypes.element,
};
在当前版本React-admin中,DeleteButton / BulkDeleteButton 组件具有 confirmTitle / confirmContent 属性,可以设置自定义 header 和对话框内容:
DeleteWithConfirmButton.propTypes = {
basePath: PropTypes.string,
classes: PropTypes.object,
className: PropTypes.string,
confirmTitle: PropTypes.string,
confirmContent: PropTypes.string,
label: PropTypes.string,
record: PropTypes.any,
redirect: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool,
PropTypes.func,
]),
resource: PropTypes.string,
icon: PropTypes.element,
};