ant-design/components/modal/demo/locale.md

71 lines
1.3 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 6
2016-08-11 11:41:06 +08:00
title:
zh-CN: 国际化
en-US: Internationalization
2016-03-31 09:40:55 +08:00
---
2016-08-11 11:41:06 +08:00
## zh-CN
设置 `okText``cancelText` 以自定义按钮文字。
2016-08-11 11:41:06 +08:00
## en-US
To customize the text of the buttons, you need to set `okText` and `cancelText` props.
2017-01-19 15:19:03 +08:00
````__react
import { Modal, Button } from 'antd';
const LocalizedModal = React.createClass({
getInitialState() {
return { visible: false };
},
showModal() {
this.setState({
2016-05-11 09:32:33 +08:00
visible: true,
});
},
handleOk() {
this.setState({
2016-05-11 09:32:33 +08:00
visible: false,
});
},
handleCancel() {
this.setState({
2016-05-11 09:32:33 +08:00
visible: false,
});
},
render() {
return (
<div>
<Button type="primary" onClick={this.showModal}>Show Modal</Button>
<Modal title="Modal" visible={this.state.visible}
onOk={this.handleOk} onCancel={this.handleCancel}
okText="OK" cancelText="Cancel"
>
<p>Bla bla ...</p>
<p>Bla bla ...</p>
<p>Bla bla ...</p>
</Modal>
</div>
);
2016-05-11 09:32:33 +08:00
},
});
function confirm() {
Modal.confirm({
title: 'Confirm',
content: 'Bla bla ...',
okText: 'OK',
2016-05-11 09:32:33 +08:00
cancelText: 'Cancel',
});
}
ReactDOM.render(<div>
<LocalizedModal />
<br />
<Button onClick={confirm}>confirm</Button>
</div>, mountNode);
````