hozana / next-translate-routes

Flexible and translated routes for Next.js without custom server
MIT License
115 stars 30 forks source link

We support Dynamic Routes and getStaticProps Pages from next.js? #59

Closed KULTI1995 closed 1 year ago

KULTI1995 commented 1 year ago

Do you guys support, generating the correct link ?

E.g. we have articles in different languages

https://nextjs.org/docs/advanced-features/i18n-routing#dynamic-routes-and-getstaticprops-pages

ucarno commented 1 year ago

Really need this feature too

draxx318 commented 1 year ago

It seems like getStaticPaths does not get the translated routes from the _routes.json file. It looks like it's impossible to combine this library with SSG sadly. I hope this feature will be added soon.

Edit: I made it work, going to post the solution later.

stovein commented 1 year ago

Hi, @draxx318 is there any improvements on solution?

cvolant commented 1 year ago

Sorry, I don't get it, could you explain your issue? I also have some getStaticPaths and it works well... You should not have anything to do here: getStaticPaths creates the dynamic file paths, which is then redirected and rewritten using next-translate-routes.

wangwailok commented 1 year ago

Sorry, I don't get it, could you explain your issue? I also have some getStaticPaths and it works well... You should not have anything to do here: getStaticPaths creates the dynamic file paths, which is then redirected and rewritten using next-translate-routes.

I am facing the same problem : getStaticProps does not work with translated routes if you refresh the page, props will pass from getStaticProps to the page. but if you click the Link from translateRoute, the page wont grab props from getStaticProps

wangwailok commented 1 year ago

It seems like getStaticPaths does not get the translated routes from the _routes.json file. It looks like it's impossible to combine this library with SSG sadly. I hope this feature will be added soon.

Edit: I made it work, going to post the solution later.

Can't wait to see your solution!

cvolant commented 1 year ago

:thinking: Strange... I don't have this issue anywhere. Could you provide a minimal reproduction?

wangwailok commented 1 year ago

I just found out that if your file contains middleware.ts, getStaticProps will immediately fail.

cvolant commented 1 year ago

I just found out that if your file contains middleware.ts, getStaticProps will immediately fail.

Yes. See here

So this issue is a duplicate of this one, let's close it.