Skip to content

Commit

Permalink
Merge pull request #240 from inevitable-changes/junhoyeo/change-local…
Browse files Browse the repository at this point in the history
…e-with-router

[web/i18n] Change locale with `router` not `i18n.changeLanguage`
  • Loading branch information
junhoyeo authored Oct 2, 2022
2 parents 151aed2 + 8b722cf commit 0a99553
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/bento-web/src/components/NavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ export const NavigationBar = () => {
const { t, i18n } = useTranslation('common');
const currentLanguage = i18n.resolvedLanguage || i18n.language || 'en';

const onChangeLocale = useCallback(() => {
console.log(currentLanguage);
i18n.changeLanguage(currentLanguage === 'en' ? 'ko' : 'en');
}, [i18n, currentLanguage]);
const onChangeLocale = useCallback(
() =>
router.push(router.asPath, router.asPath, {
locale: currentLanguage === 'en' ? 'ko' : 'en',
}),
[i18n, currentLanguage],
);

return (
<Wrapper>
Expand Down

0 comments on commit 0a99553

Please sign in to comment.