1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 22:44:19 +00:00
pds-2021-g2-nest/nest_frontend/components/interactive/SelectLanguage.js
Stefano Pigozzi a21b982b97 Localization
2021-05-17 14:32:42 +00:00

31 lines
1 KiB
JavaScript

import React, { useState } from "react"
import Select from "../base/Select"
import Localization from "../../Localization"
/**
* A {@link Select} which allows the user to choose between the various available themes, switching between them as soon
* as the user selects a different one.
*
* @param props - Additional props to pass to the {@link Select}.
* @returns {JSX.Element}
* @constructor
*/
export default function SelectLanguage({ ...props }) {
const [_language, _setLanguage] = useState(Localization.getLanguage())
const setLanguage = event => {
const language = event.target.value
console.info("Changing language to: ", language)
Localization.setLanguage(language)
_setLanguage(language)
}
return (
<Select value={_language} onChange={setLanguage} {...props}>
<option value={"it"}>🇮🇹 Italiano</option>
<option value={"en"}>🇬🇧 English</option>
<option value={"fi"}>🇫🇮 Suomi</option>
</Select>
)
}