简体   繁体   English

为 DeleteWithConfirmButton react-admin 设置自定义消息

[英]Set custom message for DeleteWithConfirmButton react-admin

How can I send my message to DeleteWithConfirmButton not globally, but only to one?我怎样才能将我的消息发送到 DeleteWithConfirmButton 不是全局的,而是只发送给一个?

I can change the message globally:我可以全局更改消息:

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?', - default message delete_content: '您确定要删除此项目吗?', - 默认消息

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,
};

In the current version of React-admin, the DeleteButton / BulkDeleteButton components have the confirmTitle / confirmContent properties, to set a custom header and dialog content:在当前版本的 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,
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM