This a repo showcasing the setup of i18n without internationalized routes in next.js
NOTE 💡: For i18n, Next uses internationalized routing as a standard. This ain't nice. So here's how to do it without the routing-part.
→ clone and install deps
npm run dev
# or
yarn dev
- get the
accept-language
header ingetServerSideProps
- parse it with resolve-accept-language to get the locale from the header, which looks like this for example:
en,de;q=0.9
- resolve-accept-language only works with full locales (like
de-DE
). However, it can still work, if the country-code is not set by the browser. This however still means that short-locales or locales with other country-codes with receive the appropriate language.
- use t() with useTranslation-hook
- use t() outside of component
- use serverside translations without routing