aralroca / next-translate-plugin

Next-translate plugin for i18n in Next.js 🌍 - Load page translations and use them in an easy way!
MIT License
32 stars 20 forks source link

Support Next.js 13 app-dir with pagesInDir config option #12

Closed awinogrodzki closed 1 year ago

awinogrodzki commented 1 year ago

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update [X] Bug fix [X] New feature [ ] Other, please explain:

What changes did you make? (Give an overview)

Check if pagesInDir provided by the user is Next.js 13 app-dir and use templateAppDir loader instead of default one

Context

I use both Next.js 13 app-dir feature as well as Next.js Api Routes inside pages/api/*.ts.

Without pagesInDir option, next-translate-plugin@2.0.2 finds pages directory and assumes there is no Next.js 13 app dir, although I use pages dir only for api routes

I cannot use Next.js 13.2 app Route Handler due to https://github.com/aralroca/next-translate-plugin/issues/11 , which means I am forced to use pages/api dir for API handlers

The approach I decided on is: when user passes custom pagesInDir that points to Next.js 13 app directory, we set isAppDirNext13 to true that forces the use of templateAppDir loader

awinogrodzki commented 1 year ago

@aralroca I see that build is failing due to 500 error during Node.js setup action. I cannot retry the build myself. Did you encounter similar issues before?

aralroca commented 1 year ago

To be honest, this is the first time I have seen this error. I hit rerun to see if it goes. If not, don't worry it doesn't seem to be related to your changes

thomasverleye commented 1 year ago

@aralroca when will there be a release of this? 👼

aralroca commented 1 year ago

@thomasverleye I will try it to do it today