2016-09-21 11:54:53 +08:00
|
|
|
import React from 'react';
|
2016-05-12 13:25:00 +08:00
|
|
|
import { changeConfirmLocale } from '../modal/locale';
|
2016-03-03 16:28:02 +08:00
|
|
|
|
2016-08-02 16:10:26 +08:00
|
|
|
export interface LocaleProviderProps {
|
|
|
|
locale: {
|
|
|
|
Pagination?: Object,
|
|
|
|
DatePicker?: Object,
|
|
|
|
TimePicker?: Object,
|
|
|
|
Calendar?: Object,
|
|
|
|
Table?: Object,
|
|
|
|
Modal?: Object,
|
|
|
|
Popconfirm?: Object,
|
|
|
|
Transfer?: Object,
|
|
|
|
Select?: Object,
|
|
|
|
};
|
2016-12-16 16:42:50 +08:00
|
|
|
children?: React.ReactElement<any>;
|
2016-08-02 16:10:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class LocaleProvider extends React.Component<LocaleProviderProps, any> {
|
2016-03-29 14:01:10 +08:00
|
|
|
static propTypes = {
|
|
|
|
locale: React.PropTypes.object,
|
2016-07-13 11:14:24 +08:00
|
|
|
};
|
2016-03-29 14:01:10 +08:00
|
|
|
|
|
|
|
static childContextTypes = {
|
|
|
|
antLocale: React.PropTypes.object,
|
2016-07-13 11:14:24 +08:00
|
|
|
};
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2016-03-03 16:28:02 +08:00
|
|
|
getChildContext() {
|
|
|
|
return {
|
2017-01-09 16:25:58 +08:00
|
|
|
antLocale: {
|
|
|
|
...this.props.locale,
|
|
|
|
exist: true,
|
|
|
|
},
|
2016-03-03 16:28:02 +08:00
|
|
|
};
|
|
|
|
}
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2016-03-05 17:14:45 +08:00
|
|
|
componentDidMount() {
|
|
|
|
this.componentDidUpdate();
|
|
|
|
}
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2016-03-05 17:14:45 +08:00
|
|
|
componentDidUpdate() {
|
|
|
|
const { locale } = this.props;
|
|
|
|
changeConfirmLocale(locale && locale.Modal);
|
|
|
|
}
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2016-03-05 17:14:45 +08:00
|
|
|
componentWillUnMount() {
|
|
|
|
changeConfirmLocale();
|
|
|
|
}
|
2016-03-29 14:01:10 +08:00
|
|
|
|
2016-03-03 16:28:02 +08:00
|
|
|
render() {
|
2016-03-05 16:39:27 +08:00
|
|
|
return React.Children.only(this.props.children);
|
2016-03-03 16:28:02 +08:00
|
|
|
}
|
|
|
|
}
|