From: Daniel Karbach Date: Wed, 16 Mar 2022 16:38:43 +0000 (+0100) Subject: add language switcher X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=1326baff1f13e252d9c60cae03680f70a87a17e9;p=alttp.git add language switcher --- diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..58d725d --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,24 @@ +user(); + if (!$user) return; + + $validatedData = $request->validate([ + 'language' => 'required|in:de,en', + ]); + + $user->locale = $validatedData['language']; + $user->update(); + + return $user->toJson(); + } + +} diff --git a/resources/js/components/common/Header.js b/resources/js/components/common/Header.js index 6bab1a2..b1040f8 100644 --- a/resources/js/components/common/Header.js +++ b/resources/js/components/common/Header.js @@ -5,6 +5,7 @@ import { LinkContainer } from 'react-router-bootstrap'; import { withTranslation } from 'react-i18next'; import Icon from './Icon'; +import LanguageSwitcher from './LanguageSwitcher'; import { getAvatarUrl } from '../../helpers/User'; import { withUser } from '../../helpers/UserContext'; import i18n from '../../i18n'; @@ -17,7 +18,10 @@ const Header = ({ doLogout, user }) => ALttP -