QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.25k stars 59 forks source link

TypeError: locales[locale] is not a function #239

Closed stefanlogue closed 10 months ago

stefanlogue commented 10 months ago

Describe the bug When viewing a page using a locale that is not the default locale, I get this error:

node_modules/next-international/dist/app/server/index.js (180:61) @ eval
 ⨯ TypeError: locales[locale] is not a function
    at Generator.next (<anonymous>)
    at new Promise (<anonymous>)
    at OverviewLayout (house/[id]/overview/layout.tsx:23:85)
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async Promise.all (index 0)

This also happens when I try to use the getI18n function in the generateMetadata function in order to translate the page title

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior Shouldn't get an error, should just translate the page correctly as it does with the default locale.

Screenshots If applicable, add screenshots to help explain your problem.

Screenshot 2023-10-11 at 15 50 31 Screenshot 2023-10-11 at 15 51 32

About (please complete the following information):

Additional context Add any other context about the problem here.

QuiiBz commented 10 months ago

To Reproduce Steps to reproduce the behavior:

Go to '...' Click on '....' Scroll down to '....' See error

I cannot help without a reproduction, as this error doesn't happen in the example or the CodeSandbox. Please provide a repository or Stackblitz/CodeSandbox so we can look into that.

It might also be related to https://github.com/QuiiBz/next-international/issues/219 or https://github.com/QuiiBz/next-international/issues/193 (specifically https://github.com/QuiiBz/next-international/issues/193#issuecomment-1733918687)

iStorry commented 10 months ago

I am getting the same issue image

iStorry commented 10 months ago

Update, I fixed it.

For my case i was using fallbackLocale so i had to remove that and add locale to it.

image

That fixed everything.

Please look into this https://next-international.vercel.app/docs/app-setup#move-your-existing-files @stefanlogue

QuiiBz commented 10 months ago

See the migration guide in the release note for 1.1.0: https://github.com/QuiiBz/next-international/releases/tag/1.1.0 (Support Static Rendering in nested Client Components)