forked from crowetic/commerce
Merge pull request #18 from marbiano/fix-lang-switcher-nav
Language switcher fix
This commit is contained in:
commit
2c1f366f59
@ -32,7 +32,12 @@ const LOCALES_MAP: Record<string, LOCALE_DATA> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const I18nWidget: FC = () => {
|
const I18nWidget: FC = () => {
|
||||||
const { locale, locales, defaultLocale = 'en-US' } = useRouter()
|
const {
|
||||||
|
locale,
|
||||||
|
locales,
|
||||||
|
defaultLocale = 'en-US',
|
||||||
|
asPath: currentPath,
|
||||||
|
} = useRouter()
|
||||||
const options = locales?.filter((val) => val !== locale)
|
const options = locales?.filter((val) => val !== locale)
|
||||||
|
|
||||||
const currentLocale = locale || defaultLocale
|
const currentLocale = locale || defaultLocale
|
||||||
@ -59,7 +64,7 @@ const I18nWidget: FC = () => {
|
|||||||
{options.map((locale) => (
|
{options.map((locale) => (
|
||||||
<Menu.Item key={locale}>
|
<Menu.Item key={locale}>
|
||||||
{({ active }) => (
|
{({ active }) => (
|
||||||
<Link href="/" locale={locale}>
|
<Link href={currentPath} locale={locale}>
|
||||||
<a className={cn(s.item, { [s.active]: active })}>
|
<a className={cn(s.item, { [s.active]: active })}>
|
||||||
{LOCALES_MAP[locale].name}
|
{LOCALES_MAP[locale].name}
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user