4e79481511
### Documentation / Examples Fixed one of the items from #25854 - Fixes warning from `next-intl` - Hides locale selector in case if no other location - Fixes path `next/router` import - Removes unused variable --- - [x] Add the StackBlitz button in README.md - [x] Make sure the linting passes [Live demo on StackBlitz](https://stackblitz.com/github/akellbl4/next.js/tree/fix/example-with-i18n-next-intl-missing-other/examples/with-i18n-next-intl)
27 lines
772 B
JavaScript
27 lines
772 B
JavaScript
import { useTranslations } from 'next-intl'
|
|
import { useRouter } from 'next/router'
|
|
import Link from 'next/link'
|
|
|
|
export default function Navigation() {
|
|
const t = useTranslations('Navigation')
|
|
const { locale, locales, route } = useRouter()
|
|
const otherLocale = locales?.find((cur) => cur !== locale)
|
|
|
|
return (
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
<div style={{ display: 'flex', gap: 10 }}>
|
|
<Link href="/">
|
|
<a>{t('index')}</a>
|
|
</Link>
|
|
<Link href="/about">
|
|
<a>{t('about')}</a>
|
|
</Link>
|
|
</div>
|
|
{otherLocale && (
|
|
<Link href={route} locale={otherLocale}>
|
|
<a>{t('switchLocale', { locale: otherLocale })}</a>
|
|
</Link>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|