-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added static language button and remove auth buttons
- Loading branch information
Showing
3 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useCallback } from 'react' | ||
import { useRouter } from 'next/router' | ||
import { Button } from '@material-ui/core' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
export default function LocaleMenu() { | ||
const router = useRouter() | ||
const { t } = useTranslation() | ||
const changeLang = useCallback( | ||
(locale: string) => (event: React.MouseEvent) => { | ||
event.preventDefault() | ||
// Same route different language | ||
router.push(router.route, undefined, { locale }) | ||
}, | ||
[], | ||
) | ||
if (!router.locale) { | ||
return null | ||
} | ||
|
||
if (router.locale === 'bg') { | ||
return ( | ||
<Button variant="text" size="small" onClick={changeLang('en')}> | ||
{t('EN')} | ||
</Button> | ||
) | ||
} | ||
|
||
return ( | ||
<Button variant="text" size="small" onClick={changeLang('bg')}> | ||
{t('BG')} | ||
</Button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters