Fix locale switch button

This commit is contained in:
afc163 2017-12-01 20:37:14 +08:00
parent bba0fd4220
commit 90736521bc
2 changed files with 16 additions and 16 deletions

View File

@ -1,7 +1,7 @@
import React from 'react';
import { FormattedMessage, injectIntl } from 'react-intl';
import { Modal, message, Row, Col } from 'antd';
import { isLocalStorageNameSupported, loadScript, getLocalizedPathname, isZhCN } from '../utils';
import { isLocalStorageNameSupported, loadScript } from '../utils';
import ColorPicker from '../Color/ColorPicker';
class Footer extends React.Component {
@ -82,21 +82,6 @@ class Footer extends React.Component {
});
}
handleLangChange = () => {
const { pathname } = this.props.location;
const currentProtocol = `${window.location.protocol}//`;
const currentHref = window.location.href.substr(currentProtocol.length);
if (isLocalStorageNameSupported()) {
localStorage.setItem('locale', isZhCN(pathname) ? 'en-US' : 'zh-CN');
}
window.location.href = currentProtocol + currentHref.replace(
window.location.pathname,
getLocalizedPathname(pathname, !isZhCN(pathname)),
);
}
render() {
return (
<footer id="footer" className="dark">

View File

@ -96,6 +96,21 @@ export default class Header extends React.Component {
.replace(currentPathname, utils.getLocalizedPathname(currentPathname));
}
handleLangChange = () => {
const { pathname } = this.props.location;
const currentProtocol = `${window.location.protocol}//`;
const currentHref = window.location.href.substr(currentProtocol.length);
if (utils.isLocalStorageNameSupported()) {
localStorage.setItem('locale', utils.isZhCN(pathname) ? 'en-US' : 'zh-CN');
}
window.location.href = currentProtocol + currentHref.replace(
window.location.pathname,
utils.getLocalizedPathname(pathname, !utils.isZhCN(pathname)),
);
}
render() {
const { inputValue, menuMode, menuVisible } = this.state;
const {