mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
site: fix language detect function
This commit is contained in:
parent
c79826ea83
commit
9ac4e6ea44
@ -3,10 +3,10 @@ import Promise from 'bluebird';
|
||||
import MainContent from './MainContent';
|
||||
|
||||
// locale copy from layout
|
||||
const locale = (
|
||||
window.localStorage &&
|
||||
localStorage.getItem('locale') !== 'en-US'
|
||||
) ? 'zh-CN' : 'en-US';
|
||||
const language = (typeof localStorage === 'undefined' || !localStorage.getItem('locale')) ?
|
||||
navigator.language : localStorage.getItem('locale');
|
||||
const isZhCN = language === 'zh-CN';
|
||||
const locale = isZhCN ? 'zh-CN' : 'en-US';
|
||||
|
||||
export function collect(nextProps, callback) {
|
||||
const pageData = nextProps.location.pathname === 'changelog' ?
|
||||
|
@ -12,8 +12,9 @@ window.react = React;
|
||||
window['react-dom'] = ReactDOM;
|
||||
window.antd = require('antd');
|
||||
|
||||
const isZhCN = (typeof localStorage !== 'undefined' && localStorage.getItem('locale') === 'zh-CN') ||
|
||||
(navigator.language === 'zh-CN');
|
||||
const language = (typeof localStorage === 'undefined' || !localStorage.getItem('locale')) ?
|
||||
navigator.language : localStorage.getItem('locale');
|
||||
const isZhCN = language === 'zh-CN';
|
||||
|
||||
const appLocale = isZhCN ? cnLocale : enLocale;
|
||||
addLocaleData(appLocale.data);
|
||||
|
Loading…
Reference in New Issue
Block a user