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

i18n

parent e6c53dad
......@@ -47,13 +47,12 @@ app.router(require('./router'));
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];
language = (localeData[languageWithoutRegionCode] || localeData[language]) ? language : 'zh-CN';
const messages = localeData[languageWithoutRegionCode] || localeData[language] || localeData.zh;
const languageY = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
const anguageWithoutRegionCode = languageY.toLowerCase().split(/[_-]+/)[0];
const language = anguageWithoutRegionCode === 'zh' ? 'zh-CN' : 'en-US';
const messages = localeData[language];
const App = app.start();
ReactDOM.render(
......
......@@ -27,9 +27,10 @@ export default {
subscriptions: {
setup({ dispatch }) {
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 { userAgent } = navigator;
......
......@@ -208,15 +208,10 @@ export default {
dispatch(routerRedux.replace('/signin'));
}
history.listen(({ pathname, query }) => {
history.listen(({ pathname }) => {
if (pathname === '/') {
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