next-right-now icon indicating copy to clipboard operation
next-right-now copied to clipboard

Migrate NRN I18n routing implementation to native Next.js I18n

Open Vadorequest opened this issue 3 years ago • 7 comments

Goal

Update the current NRN implementation of I18n routing to the new official Next.js 10 I18n routing.

The update will provide more ways of configuring the i18n routing. Currently, NRN only handles the sub-path routing strategy. See https://nextjs.org/docs/advanced-features/i18n-routing#sub-path-routing

Status

Awaiting below issues to be fixed before starting working on this.

Issues

Currently, the Next.js i18n routing implementation doesn't generate a prefix url for the default locale.

  • e.g: if en is the default locale then the path will be / instead of /en See https://nextjs.org/docs/advanced-features/i18n-routing#sub-path-routing

This is a breaking changes for apps created through NRN. I'll await a fix for this before starting working on it.

To do

  • Remove or adapt our I18nLink component, because it's now handled by the Link component
  • Remove href - See https://nextjs.org/blog/next-10#automatic-resolving-of-href
  • Handle hreflang - See https://support.google.com/webmasters/answer/189077

Reference

  • https://nextjs.org/docs/advanced-features/i18n-routing

Vadorequest avatar Nov 01 '20 09:11 Vadorequest

Hi @Vadorequest After upgrade to next 10x I get wrong lang attribute on html tag without any advanced changes in codebase. This is because now next automatically resolve html lang attribute So your code https://github.com/UnlyEd/next-right-now/blob/e6f625820726d24967b4b14a5f32c93266fac3c9/src/pages/_document.tsx#L90 now not working at all. I open page in locale 'ru' but get <html lang="en"> Why next turn on this feature without the user including himself i18n config? I'm shocked.

7iomka avatar Nov 03 '20 19:11 7iomka

Hm.. Seems 10.0.1-canary.7 fixes this. will need to test

7iomka avatar Nov 03 '20 20:11 7iomka

Thanks for letting me know, I hadn't noticed this!

And yes, Next shouldn't enable this when you haven't opt-in for their i18n routing feature. I'm glad you found a workaround. There are other bugs in the 10.0.0 release and the canary branch is a fine workaround for now. It'll probably be patched in the 10.0.1 like many other things.

Vadorequest avatar Nov 03 '20 21:11 Vadorequest

FYI I won't change the current implementation until Next adds support for proper redirection to default locale prefix.

image

The default locale does not have a prefix.

The current behavior is a breaking change and cannot be configured at this time. Many people are asking for it but so far nothing.

Vadorequest avatar Dec 20 '20 22:12 Vadorequest

This issue hasn't been addressed by Next.js yet, despite having more than 70 upvotes.

https://github.com/vercel/next.js/discussions/18419

I suggest you upvote the official Next.js discussion if you wish to see this happen.

Vadorequest avatar Jan 05 '21 22:01 Vadorequest

Any new updates on this one?

samuelcastro avatar Mar 02 '21 19:03 samuelcastro

Still not fixed on nextjs

On Tue, Mar 2, 2021, 20:45 Samuel Castro [email protected] wrote:

Any new updates on this one?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/UnlyEd/next-right-now/issues/194#issuecomment-789166382, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5BRYR7VD5PRFZYESIZVI3TBU54VANCNFSM4TGM2UOQ .

Vadorequest avatar Mar 02 '21 20:03 Vadorequest