Skip to content

Commit 9adb0ca

Browse files
committed
Make language switch
1 parent 3accbc2 commit 9adb0ca

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/components/StartingPage/index.js

Lines changed: 31 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: "start"
45+
}
4046
})
4147

4248
const ContentContainer = styled("div")(({ theme }) => ({
@@ -97,8 +103,15 @@ const Actionless = styled("div")({
97103
color: colors.grey[600],
98104
paddingTop: 16,
99105
})
106+
100107
const BottomSpacer = styled("div")({ height: 100 })
101108

109+
const languageOptions = [
110+
{label: "English", value: "en"},
111+
{label: "French", value: "fr"},
112+
{label: "Chinese", value: "cn"}
113+
]
114+
102115
export default ({
103116
onFileDrop,
104117
onOpenTemplate,
@@ -111,7 +124,7 @@ export default ({
111124
const posthog = usePosthog()
112125

113126
// internalization hook
114-
const { t } = useTranslation()
127+
const { t, i18n } = useTranslation()
115128

116129
//const isDesktop = useIsDesktop()
117130
const [newVersionAvailable, changeNewVersionAvailable] = useState(false)
@@ -137,6 +150,10 @@ export default ({
137150
onFileDrop(acceptedFiles[0])
138151
})
139152

153+
const changeLanguage = (language) =>{
154+
i18n.changeLanguage(language)
155+
}
156+
140157
let { getRootProps, getInputProps } = useDropzone({ onDrop })
141158

142159
return (
@@ -185,10 +202,21 @@ export default ({
185202
<ContentContainer>
186203
<Content>
187204
<Grid container>
188-
<Grid xs={12} item>
205+
<Grid xs={6} item>
189206
<Title>Universal Data Tool</Title>
190207
<Subtitle>{t("universaldatatool-description")}</Subtitle>
191208
</Grid>
209+
<Grid xs={3} />
210+
<Grid xs={3}>
211+
<Box padding={3} className={c.languageSelectionWrapper}>
212+
<ActionTitle>Select Language</ActionTitle>
213+
<Select
214+
defaultValue={languageOptions[0]}
215+
options={languageOptions}
216+
onChange={({ value }) => changeLanguage(value)}
217+
/>
218+
</Box>
219+
</Grid>
192220
<Grid xs={6} item>
193221
<ActionList>
194222
<ActionTitle>Start</ActionTitle>

0 commit comments

Comments
 (0)