2016-03-03 16:28:02 +08:00
|
|
|
import React from 'react';
|
2016-03-05 17:14:45 +08:00
|
|
|
import { changeConfirmLocale } from '../modal/confirm';
|
2016-03-03 16:28:02 +08:00
|
|
|
|
|
|
|
export default class LocaleProvider extends React.Component {
|
|
|
|
getChildContext() {
|
|
|
|
return {
|
2016-03-05 16:39:27 +08:00
|
|
|
antLocale: this.props.locale,
|
2016-03-03 16:28:02 +08:00
|
|
|
};
|
|
|
|
}
|
2016-03-05 17:14:45 +08:00
|
|
|
componentDidMount() {
|
|
|
|
this.componentDidUpdate();
|
|
|
|
}
|
|
|
|
componentDidUpdate() {
|
|
|
|
const { locale } = this.props;
|
|
|
|
changeConfirmLocale(locale && locale.Modal);
|
|
|
|
}
|
|
|
|
componentWillUnMount() {
|
|
|
|
changeConfirmLocale();
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LocaleProvider.childContextTypes = {
|
2016-03-05 16:39:27 +08:00
|
|
|
antLocale: React.PropTypes.object,
|
2016-03-03 16:28:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
LocaleProvider.propTypes = {
|
|
|
|
locale: React.PropTypes.object,
|
|
|
|
};
|