<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import getConfig from './getConfig';
import localeStore from 'stores/localeStore';
import moment from 'moment';
import AdminContext from 'containers/AdminContext';
import 'moment/locale/zh-cn';

// TODO: should be able to custom
moment.locale('zh-cn');

export default class Admin extends Component {
	static propTypes = {
		config: PropTypes.shape({
			name: PropTypes.string,
			sidebar: PropTypes.array,
			tables: PropTypes.object,
			api: PropTypes.object,
			auth: PropTypes.object,
			upload: PropTypes.object,
			router: PropTypes.any,
			views: PropTypes.object,
			modals: PropTypes.object,
		}),
		children: PropTypes.node,
		locale: PropTypes.object,
	};

	componentWillMount() {
		const { children, config, locale } = this.props;
		if (locale) {
			localeStore.set(locale);
		}
		this._config = getConfig(children || config);
	}

	componentWillReceiveProps({ children, config }) {
		this._config = getConfig(children || config);
		this.forceUpdate();
	}

	render() {
		return <AdminContext appConfig={this._config} />;
	}
}<commit_msg>improve Admin `locale` prop<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import getConfig from './getConfig';
import localeStore from 'stores/localeStore';
import moment from 'moment';
import AdminContext from 'containers/AdminContext';
import { LocaleProvider } from 'antd';
import 'moment/locale/zh-cn';

// TODO: should be able to custom
moment.locale('zh-cn');

export default class Admin extends Component {
	static propTypes = {
		config: PropTypes.shape({
			name: PropTypes.string,
			sidebar: PropTypes.array,
			tables: PropTypes.object,
			api: PropTypes.object,
			auth: PropTypes.object,
			upload: PropTypes.object,
			router: PropTypes.any,
			views: PropTypes.object,
			modals: PropTypes.object,
		}),
		children: PropTypes.node,
		locale: PropTypes.object,
	};

	componentWillMount() {
		const { children, config, locale } = this.props;
		if (locale) {
			localeStore.set(locale);
		}
		this._config = getConfig(children || config);
	}

	componentWillReceiveProps({ children, config }) {
		this._config = getConfig(children || config);
		this.forceUpdate();
	}

	_renderContext() {
		return <AdminContext appConfig={this._config} />;
	}

	render() {
		const { locale } = this.props;
		if (locale) {
			return (
				<LocaleProvider locale={locale.antd}>
					{this._renderContext()}
				</LocaleProvider>
			);
		} else {
			return this._renderContext();
		}
	}
}
{'fraction_non_alphanumeric': 0.1312816517335411, 'fraction_numerical': 0.0, 'mean_word_length': 4.2089249492900604, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5370031', 'n_tokens_mistral': 854, 'n_tokens_neox': 786, 'n_words': 199}