site: use correct locale for component

This commit is contained in:
afc163 2018-05-18 11:34:26 +08:00
parent 7404b7f36c
commit 9b17a943f5
2 changed files with 11 additions and 5 deletions

View File

@ -83,6 +83,7 @@ module.exports = {
webpackConfig(config) {
config.resolve.alias = {
'antd/lib': path.join(process.cwd(), 'components'),
'antd/es': path.join(process.cwd(), 'components'),
antd: path.join(process.cwd(), 'index'),
site: path.join(process.cwd(), 'site'),
'react-router': 'react-router/umd/ReactRouter',

View File

@ -3,6 +3,9 @@ import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import { enquireScreen } from 'enquire-js';
import { addLocaleData, IntlProvider } from 'react-intl';
import 'moment/locale/zh-cn';
import { LocaleProvider } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import Header from './Header';
import Footer from './Footer';
import enLocale from '../../en-US';
@ -82,11 +85,13 @@ export default class Layout extends React.Component {
return (
<IntlProvider locale={appLocale.locale} messages={appLocale.messages}>
<div className="page-wrapper">
<Header {...restProps} />
{children}
<Footer {...restProps} />
</div>
<LocaleProvider locale={appLocale.locale === 'zh-CN' ? zhCN : null}>
<div className="page-wrapper">
<Header {...restProps} />
{children}
<Footer {...restProps} />
</div>
</LocaleProvider>
</IntlProvider>
);
}