Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(examples/with-i18n-next-intl): fixes warning #25928

Merged
11 changes: 6 additions & 5 deletions examples/with-i18n-next-intl/components/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useTranslations } from 'next-intl'
import { useRouter } from 'next/dist/client/router'
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)

Expand All @@ -18,9 +17,11 @@ export default function Navigation() {
<a>{t('about')}</a>
</Link>
</div>
<Link href={route} locale={otherLocale}>
<a>{t('switchLocale', { locale: otherLocale })}</a>
</Link>
{otherLocale && (
<Link href={route} locale={otherLocale}>
<a>{t('switchLocale', { locale: otherLocale })}</a>
</Link>
)}
</div>
)
}
2 changes: 1 addition & 1 deletion examples/with-i18n-next-intl/messages/shared/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"Navigation": {
"index": "Start",
"about": "Über",
"switchLocale": "Zu {locale, select, de {Deutsch} en {Englisch}} wechseln"
"switchLocale": "Zu {locale, select, de {Deutsch} en {Englisch} other {}} wechseln"
}
}
2 changes: 1 addition & 1 deletion examples/with-i18n-next-intl/messages/shared/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"Navigation": {
"index": "Home",
"about": "About",
"switchLocale": "Switch to {locale, select, de {German} en {English}}"
"switchLocale": "Switch to {locale, select, de {German} en {English} other {}}"
}
}
2 changes: 1 addition & 1 deletion examples/with-i18n-next-intl/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextIntlProvider } from 'next-intl'

export default function App({ Component, messages, pageProps }) {
export default function App({ Component, pageProps }) {
return (
<NextIntlProvider
// To achieve consistent date, time and number formatting
Expand Down