Internalization with app router on latest nextjs?
Unanswered
Segugio Maremmano posted this in #help-forum
Segugio MaremmanoOP
Whats the correct approach? Last time I tried moving my app from pages to app router the internalization didnt work, does anyone have working example? On nextjs docs it says to fetch data from my dictionary file, but that seems too complicated compared to how it was with next i18n on pages router
12 Replies
@Segugio Maremmano Whats the correct approach? Last time I tried moving my app from pages to app router the internalization didnt work, does anyone have working example? On nextjs docs it says to fetch data from my dictionary file, but that seems too complicated compared to how it was with next i18n on pages router
hey, you can check how i implemented it here - https://github.com/dayoawobeku/onex-rswe-assessment-2024-starter
@Dayo hey, you can check how i implemented it here - https://github.com/dayoawobeku/onex-rswe-assessment-2024-starter
Segugio MaremmanoOP
What if I have multiple pages?
@Segugio Maremmano What if I have multiple pages?
shouldn't really change. all your new pages will be inside the
[lang] dirSegugio MaremmanoOP
Looks complicated since I already have finished project, is there no other way to do this? I also cant find lot of topics regarding this, do people just not implement internalization with new router anymore?
i struggled to find resources when i built that a few months back as well
Segugio MaremmanoOP
Hmm, surely there has to be other way right? In pages router it was so simple, just using useTranslations for different content..
@Dayo hey, you can check how i implemented it here - https://github.com/dayoawobeku/onex-rswe-assessment-2024-starter
Segugio MaremmanoOP
Doesnt this mean that on every page load there will be delay for few seconds since it will be fetching data locally?
Or does it happen in instant?
I do understand correctly that your approach is identical to suggested one on nextjs docs page so I guess it is the correct approach after all
@Segugio Maremmano Doesnt this mean that on every page load there will be delay for few seconds since it will be fetching data locally?
if the data is local in a json file, there shouldn’t be any delay at all. but if you’re using a CMS or some external source, then probably
@Dayo if the data is local in a json file, there shouldn’t be any delay at all. but if you’re using a CMS or some external source, then probably
Segugio MaremmanoOP
I guess, and how do you handle switches between languages? Just casual Link with prefix? Also is it possible to have the default language have no prefix in URL?
This used to be so easy in pages router but in app router it feels very complicated for no reason