|
|
@ -17,9 +17,9 @@ Components which need localization support are listed here, you can toggle the l |
|
|
|
import { LocaleProvider, Pagination, DatePicker, TimePicker, Calendar, |
|
|
|
Popconfirm, Table, Modal, Button, Select, Transfer, Radio } from 'antd'; |
|
|
|
import zhCN from 'antd/lib/locale-provider/zh_CN'; |
|
|
|
import enUS from 'antd/lib/locale-provider/en_US'; |
|
|
|
import moment from 'moment'; |
|
|
|
import 'moment/locale/zh-cn'; |
|
|
|
moment.locale('en'); |
|
|
|
|
|
|
|
const Option = Select.Option; |
|
|
|
const RangePicker = DatePicker.RangePicker; |
|
|
@ -108,25 +108,20 @@ class App extends React.Component { |
|
|
|
constructor() { |
|
|
|
super(); |
|
|
|
this.state = { |
|
|
|
locale: null, |
|
|
|
locale: enUS, |
|
|
|
}; |
|
|
|
} |
|
|
|
changeLocale = (e) => { |
|
|
|
const localeValue = e.target.value; |
|
|
|
this.setState({ locale: localeValue }); |
|
|
|
if (!localeValue) { |
|
|
|
moment.locale('en'); |
|
|
|
} else { |
|
|
|
moment.locale('zh-cn'); |
|
|
|
} |
|
|
|
} |
|
|
|
render() { |
|
|
|
return ( |
|
|
|
<div> |
|
|
|
<div className="change-locale"> |
|
|
|
<span style={{ marginRight: 16 }}>Change locale of components: </span> |
|
|
|
<Radio.Group defaultValue={null} onChange={this.changeLocale}> |
|
|
|
<Radio.Button key="en" value={null}>English</Radio.Button> |
|
|
|
<Radio.Group defaultValue={enUS} onChange={this.changeLocale}> |
|
|
|
<Radio.Button key="en" value={enUS}>English</Radio.Button> |
|
|
|
<Radio.Button key="cn" value={zhCN}>中文</Radio.Button> |
|
|
|
</Radio.Group> |
|
|
|
</div> |
|
|
|