Commit 3b329283 authored by 2breakegg's avatar 2breakegg

语言切换

parent 95056bbc
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<includedPredefinedLibrary name="ECMAScript 6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="JSX" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mycard-store.iml" filepath="$PROJECT_DIR$/.idea/mycard-store.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="27e0c04e-bce5-44bf-b6fb-c3274291706d" name="Default" comment="" />
<ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" />
<ignored path="$PROJECT_DIR$/tmp/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="App.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/App.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-3706">
<caret line="72" column="0" lean-forward="true" selection-start-line="72" selection-start-column="0" selection-end-line="72" selection-end-column="0" />
<folding>
<element signature="e#0#40#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER">
<package-json value="$PROJECT_DIR$/package.json" />
</component>
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="NodeModulesDirectoryManager">
<handled-path value="$PROJECT_DIR$/node_modules" />
</component>
<component name="ProjectFrameBounds">
<option name="x" value="550" />
<option name="y" value="225" />
<option name="width" value="1176" />
<option name="height" value="856" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="mycard-store" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="mycard-store" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="mycard-store" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="mycard-store" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="nodejs_interpreter_path" value="C:/Program Files/nodejs/node" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="HbShouldOpenHtmlAsHb" value="" />
<property name="js-jscs-nodeInterpreter" value="C:\Program Files\nodejs\node.exe" />
</component>
<component name="RunManager">
<configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
<method />
</configuration>
<configuration default="true" type="DartTestRunConfigurationType" factoryName="Dart Test">
<method />
</configuration>
<configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma">
<config-file value="" />
<node-interpreter value="project" />
<envs />
<method />
</configuration>
<configuration default="true" type="JavaScriptTestRunnerProtractor" factoryName="Protractor">
<config-file value="" />
<node-interpreter value="project" />
<envs />
<method />
</configuration>
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
<method />
</configuration>
<configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="project" working-dir="">
<method />
</configuration>
<configuration default="true" type="cucumber.js" factoryName="Cucumber.js">
<option name="cucumberJsArguments" value="" />
<option name="executablePath" />
<option name="filePath" />
<method />
</configuration>
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
<method />
</configuration>
<configuration default="true" type="js.build_tools.npm" factoryName="npm">
<command value="run" />
<scripts />
<node-interpreter value="project" />
<envs />
<method />
</configuration>
<configuration default="true" type="mocha-javascript-test-runner" factoryName="Mocha">
<node-interpreter>project</node-interpreter>
<node-options />
<working-directory />
<pass-parent-env>true</pass-parent-env>
<envs />
<ui />
<extra-mocha-options />
<test-kind>DIRECTORY</test-kind>
<test-directory />
<recursive>false</recursive>
<method />
</configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="27e0c04e-bce5-44bf-b6fb-c3274291706d" name="Default" comment="" />
<created>1488883523385</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1488883523385</updated>
<workItem from="1488883525063" duration="1448000" />
</task>
<task id="LOCAL-00001" summary="合并">
<created>1488884148406</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1488884148406</updated>
</task>
<task id="LOCAL-00002" summary="Merge branch 'master' of https://github.com/mycard/mycard-store&#10;&#10;# Conflicts:&#10;#&#9;i18n.json&#10;#&#9;src/App.css&#10;#&#9;src/App.js&#10;">
<created>1488884474344</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1488884474344</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="1448000" />
</component>
<component name="ToolWindowManager">
<frame x="550" y="225" width="1176" height="856" extended-state="0" />
<editor active="false" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24956064" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32963988" sideWeight="0.50351495" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32963988" sideWeight="0.49648505" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32963988" sideWeight="0.4929701" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="processedProjectFiles" value="true" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="合并" />
<MESSAGE value="Merge branch 'master' of https://github.com/mycard/mycard-store&#10;&#10;# Conflicts:&#10;#&#9;i18n.json&#10;#&#9;src/App.css&#10;#&#9;src/App.js&#10;" />
<option name="LAST_COMMIT_MESSAGE" value="Merge branch 'master' of https://github.com/mycard/mycard-store&#10;&#10;# Conflicts:&#10;#&#9;i18n.json&#10;#&#9;src/App.css&#10;#&#9;src/App.js&#10;" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/App.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-3706">
<caret line="72" column="0" lean-forward="true" selection-start-line="72" selection-start-column="0" selection-end-line="72" selection-end-column="0" />
<folding>
<element signature="e#0#40#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
...@@ -93,7 +93,8 @@ ...@@ -93,7 +93,8 @@
} }
.ant-layout-footer{ .ant-layout-footer{
text-align: right display: flex;
justify-content: space-between;
} }
.ant-card-head-title{ .ant-card-head-title{
...@@ -192,3 +193,15 @@ ...@@ -192,3 +193,15 @@
height: 40px; height: 40px;
width: 180px width: 180px
} }
.changelanguage{
display: flex;
line-height:30px;
}
.changelanguage>i{
line-height:30px;
}
li>.changelanguage{
display: flex;
line-height:30px;
}
\ No newline at end of file
...@@ -7,7 +7,7 @@ import config from './config' ...@@ -7,7 +7,7 @@ import config from './config'
import i18Data from '../i18data.json' import i18Data from '../i18data.json'
import { FormattedMessage } from 'react-intl' import { FormattedMessage } from 'react-intl'
import { Layout, Row, Col, Button, Card, Timeline } from 'antd' import { Layout, Row, Col, Button, Card, Timeline, Dropdown, Menu, Icon } from 'antd'
const { Content, Footer, Header } = Layout const { Content, Footer, Header } = Layout
...@@ -86,15 +86,34 @@ export default class App extends Component { ...@@ -86,15 +86,34 @@ export default class App extends Component {
return data return data
} }
changeLanguage(language){
localStorage.setItem('language',language);
history.go(0);
}
handleClick = (e) => { handleClick = (e) => {
console.log('click ', e); console.log('click ', e);
} }
render() { render() {
const { latest, isMobile, stats } = this.state const { latest, isMobile, stats } = this.state
const { language } = this.props const language = localStorage.getItem('language') || this.props.language
const realData = i18Data[language] ? i18Data[language] : i18Data['zh-CN'] const realData = i18Data[language] ? i18Data[language] : i18Data[this.props.language] ? i18Data[this.props.language] : i18Data['zh-CN']
const menu = (
<Menu style={{transform: 'translateX(-16px)'}}>
<Menu.Item key="0">
<a onClick={() => this.changeLanguage('en-US')} className='changelanguage'>
<img alt="img" src={require('../public/USFlag.png')}/>
&nbsp;English</a>
</Menu.Item>
<Menu.Item key="1">
<a onClick={() => this.changeLanguage('zh-CN')} className='changelanguage'>
<img alt="img" src={require('../public/CNFlag.png')}/>
&nbsp;中文</a>
</Menu.Item>
</Menu>
);
return ( return (
<Layout> <Layout>
...@@ -282,8 +301,19 @@ export default class App extends Component { ...@@ -282,8 +301,19 @@ export default class App extends Component {
<Footer> <Footer>
<div>
<Dropdown overlay={menu} trigger={['click']}>
{language=='en-US'?
(<a className="ant-dropdown-link changelanguage" href="#">
<img alt="img" src={require('../public/USFlag.png')}/>
&nbsp;English <Icon type="down" class="flag"/>
</a>):(<a className="ant-dropdown-link changelanguage" href="#">
<img alt="img" src={require('../public/CNFlag.png')}/>
&nbsp;中文 <Icon type="down" class="flag"/>
</a>)}
</Dropdown>
</div>
© MoeCube 2017 all right reserved. © MoeCube 2017 all right reserved.
</Footer> </Footer>
</Layout> </Layout>
......
...@@ -6,7 +6,7 @@ import localeData from '../i18n.json' ...@@ -6,7 +6,7 @@ import localeData from '../i18n.json'
addLocaleData([...en, ...zh]) addLocaleData([...en, ...zh])
const language = navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage; const language = localStorage.getItem('language') || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0]; const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
......
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