Skip to content

Commit 9496760

Browse files
authored
fix: Merge pull request #223 from UniversalDataTool/feature/language-switch
Language Selection on Starting Page
2 parents 798cc45 + d57c346 commit 9496760

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

src/components/StartingPage/index.js

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import usePosthog from "../../utils/use-posthog"
1515
import packageInfo from "../../../package.json"
1616
import useEventCallback from "use-event-callback"
1717
import DownloadIcon from "@material-ui/icons/GetApp"
18-
18+
import Box from "@material-ui/core/Box"
19+
import Select from "react-select"
1920
import { useTranslation } from "react-i18next"
2021

2122
const useStyles = makeStyles({
@@ -37,6 +38,11 @@ const useStyles = makeStyles({
3738
marginLeft: -6,
3839
color: colors.grey[700],
3940
},
41+
languageSelectionWrapper: {
42+
display: "flex",
43+
flexDirection: "column",
44+
textAlign: "center",
45+
},
4046
})
4147

4248
const ContentContainer = styled("div")(({ theme }) => ({
@@ -65,6 +71,25 @@ const Title = styled("div")({
6571
color: colors.grey[300],
6672
})
6773

74+
const languageSelectionFormStyle = {
75+
control: (base, state) => ({
76+
...base,
77+
border: "1px solid #9e9e9e",
78+
background: "transparent",
79+
color: "#e0e0e0",
80+
}),
81+
menuList: (base) => ({
82+
...base,
83+
padding: 0,
84+
margin: 0,
85+
color: "black",
86+
}),
87+
singleValue: (base) => ({
88+
...base,
89+
color: "white",
90+
}),
91+
}
92+
6893
const Subtitle = styled("div")({
6994
fontSize: 18,
7095
// fontWeight: "bold",
@@ -97,8 +122,15 @@ const Actionless = styled("div")({
97122
color: colors.grey[600],
98123
paddingTop: 16,
99124
})
125+
100126
const BottomSpacer = styled("div")({ height: 100 })
101127

128+
const languageOptions = [
129+
{ label: "English", value: "en" },
130+
{ label: "French", value: "fr" },
131+
{ label: "Chinese", value: "cn" },
132+
]
133+
102134
export default ({
103135
onFileDrop,
104136
onOpenTemplate,
@@ -111,7 +143,7 @@ export default ({
111143
const posthog = usePosthog()
112144

113145
// internalization hook
114-
const { t } = useTranslation()
146+
const { t, i18n } = useTranslation()
115147

116148
//const isDesktop = useIsDesktop()
117149
const [newVersionAvailable, changeNewVersionAvailable] = useState(false)
@@ -137,6 +169,10 @@ export default ({
137169
onFileDrop(acceptedFiles[0])
138170
})
139171

172+
const changeLanguage = (language) => {
173+
i18n.changeLanguage(language)
174+
}
175+
140176
let { getRootProps, getInputProps } = useDropzone({ onDrop })
141177

142178
return (
@@ -185,10 +221,22 @@ export default ({
185221
<ContentContainer>
186222
<Content>
187223
<Grid container>
188-
<Grid xs={12} item>
224+
<Grid xs={6} item>
189225
<Title>Universal Data Tool</Title>
190226
<Subtitle>{t("universaldatatool-description")}</Subtitle>
191227
</Grid>
228+
<Grid xs={3} />
229+
<Grid xs={3}>
230+
<Box padding={3} className={c.languageSelectionWrapper}>
231+
<ActionTitle>Select Language</ActionTitle>
232+
<Select
233+
styles={languageSelectionFormStyle}
234+
defaultValue={languageOptions[0]}
235+
options={languageOptions}
236+
onChange={({ value }) => changeLanguage(value)}
237+
/>
238+
</Box>
239+
</Grid>
192240
<Grid xs={6} item>
193241
<ActionList>
194242
<ActionTitle>Start</ActionTitle>

src/i18n/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ i18n
1818
// init i18next
1919
// for all options read: https://www.i18next.com/overview/configuration-options
2020
.init({
21-
fallbackLng: "cn",
21+
fallbackLng: "en",
2222
debug: true,
2323

2424
interpolation: {

0 commit comments

Comments
 (0)