diff --git a/site/theme/template/Content/index.jsx b/site/theme/template/Content/index.jsx index 868df86905..907d61f001 100644 --- a/site/theme/template/Content/index.jsx +++ b/site/theme/template/Content/index.jsx @@ -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' ? diff --git a/site/theme/template/Layout/index.jsx b/site/theme/template/Layout/index.jsx index ca0f650c73..6844bcd4c2 100644 --- a/site/theme/template/Layout/index.jsx +++ b/site/theme/template/Layout/index.jsx @@ -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);