Commit 9bf497e5 authored by 2breakegg's avatar 2breakegg

i18n

parent e6c53dad
...@@ -47,13 +47,12 @@ app.router(require('./router')); ...@@ -47,13 +47,12 @@ app.router(require('./router'));
addLocaleData([...en, ...zh]); addLocaleData([...en, ...zh]);
/*eslint-disable */
let language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
/*eslint-enable */
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0]; const languageY = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
language = (localeData[languageWithoutRegionCode] || localeData[language]) ? language : 'zh-CN';
const messages = localeData[languageWithoutRegionCode] || localeData[language] || localeData.zh; const anguageWithoutRegionCode = languageY.toLowerCase().split(/[_-]+/)[0];
const language = anguageWithoutRegionCode === 'zh' ? 'zh-CN' : 'en-US';
const messages = localeData[language];
const App = app.start(); const App = app.start();
ReactDOM.render( ReactDOM.render(
......
...@@ -27,9 +27,10 @@ export default { ...@@ -27,9 +27,10 @@ export default {
subscriptions: { subscriptions: {
setup({ dispatch }) { setup({ dispatch }) {
let client; let client;
const language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage; const languageY = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
// const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0]; const anguageWithoutRegionCode = languageY.toLowerCase().split(/[_-]+/)[0];
const language = anguageWithoutRegionCode === 'zh' ? 'zh-CN' : 'en-US';
const messages = i18n[language]; const messages = i18n[language];
const { userAgent } = navigator; const { userAgent } = navigator;
......
...@@ -208,15 +208,10 @@ export default { ...@@ -208,15 +208,10 @@ export default {
dispatch(routerRedux.replace('/signin')); dispatch(routerRedux.replace('/signin'));
} }
history.listen(({ pathname, query }) => { history.listen(({ pathname }) => {
if (pathname === '/') { if (pathname === '/') {
dispatch({ type: 'preLogin', payload: { token } }); dispatch({ type: 'preLogin', payload: { token } });
} }
if (pathname === '/reset' || pathname === '/activate') {
if (!query.key) {
message.error('缺少参数');
}
}
}); });
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment