Skip to content

Instantly share code, notes, and snippets.

@fwojciec
Created September 3, 2019 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwojciec/b956f7ca559985eaf1464a4522639a69 to your computer and use it in GitHub Desktop.
Save fwojciec/b956f7ca559985eaf1464a4522639a69 to your computer and use it in GitHub Desktop.
How to build a multilingual website in Next.js
// components/Navigation.tsx
import React from 'react'
import Link from 'next/link'
import useTranslation from '../hooks/useTranslation'
import LocaleSwitcher from './LocaleSwitcher'
const Navigation = () => {
const { locale, t } = useTranslation()
return (
<ul className="root">
<li>
<LocaleSwitcher />
</li>
<li>
<Link href="/[lang]" as={`/${locale}`}>
<a>{t('painting')}</a>
</Link>
</li>
<li>
<Link href="/[lang]/artist" as={`/${locale}/artist`}>
<a>{t('artist')}</a>
</Link>
</li>
</ul>
)
}
export default Navigation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment