diff --git a/src/web/components/structure/header.jsx b/src/web/components/structure/header.jsx index 692185ec11..8f8de43026 100644 --- a/src/web/components/structure/header.jsx +++ b/src/web/components/structure/header.jsx @@ -29,6 +29,7 @@ import useGmp from 'web/utils/useGmp'; import LogoutIcon from 'web/components/icon/logouticon'; import MySettingsIcon from 'web/components/icon/mysettingsicon'; +import LanguageSwitch from './languageswitch'; const Header = () => { const gmp = useGmp(); @@ -69,6 +70,7 @@ const Header = () => { ]; return ( } menuPoints={menuPoints} isLoggedIn={loggedIn} username={username} @@ -78,5 +80,3 @@ const Header = () => { }; export default Header; - -// vim: set ts=2 sw=2 tw=80: diff --git a/src/web/components/structure/languageswitch.jsx b/src/web/components/structure/languageswitch.jsx new file mode 100644 index 0000000000..165b5d5988 --- /dev/null +++ b/src/web/components/structure/languageswitch.jsx @@ -0,0 +1,39 @@ +/* SPDX-FileCopyrightText: 2024 Greenbone AG + * + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import {FlagDeIcon, FlagEnIcon} from '@greenbone/opensight-ui-components'; +import {ActionIcon} from '@mantine/core'; + +import useLocale from 'web/hooks/useLocale'; +import useTranslation from 'web/hooks/useTranslation'; + +const getNextLanguage = language => (language === 'en' ? 'de' : 'en'); + +const LanguageSwitch = () => { + const [language, changeLanguage] = useLocale(); + const [_] = useTranslation(); + + const nextLanguage = getNextLanguage(language); + const titles = { + en: _('Switch language to English'), + de: _('Switch language to German'), + }; + + const handleLanguageChange = () => { + changeLanguage(nextLanguage); + }; + return ( + + {language === 'en' ? : } + + ); +}; + +export default LanguageSwitch;