You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.0 KiB
54 lines
1.0 KiB
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { changeConfirmLocale } from '../modal/locale';
|
|
|
|
export interface LocaleProviderProps {
|
|
locale: {
|
|
Pagination?: Object,
|
|
DatePicker?: Object,
|
|
TimePicker?: Object,
|
|
Calendar?: Object,
|
|
Table?: Object,
|
|
Modal?: Object,
|
|
Popconfirm?: Object,
|
|
Transfer?: Object,
|
|
Select?: Object,
|
|
};
|
|
children?: React.ReactElement<any>;
|
|
}
|
|
|
|
export default class LocaleProvider extends React.Component<LocaleProviderProps, any> {
|
|
static propTypes = {
|
|
locale: PropTypes.object,
|
|
};
|
|
|
|
static childContextTypes = {
|
|
antLocale: PropTypes.object,
|
|
};
|
|
|
|
getChildContext() {
|
|
return {
|
|
antLocale: {
|
|
...this.props.locale,
|
|
exist: true,
|
|
},
|
|
};
|
|
}
|
|
|
|
componentWillMount() {
|
|
this.componentDidUpdate();
|
|
}
|
|
|
|
componentDidUpdate() {
|
|
const { locale } = this.props;
|
|
changeConfirmLocale(locale && locale.Modal);
|
|
}
|
|
|
|
componentWillUnMount() {
|
|
changeConfirmLocale();
|
|
}
|
|
|
|
render() {
|
|
return React.Children.only(this.props.children);
|
|
}
|
|
}
|
|
|