Localisation app router
Unanswered
California pilchard posted this in #help-forum
California pilchardOP
Guys, if I want to have local on the router using the app director, do I have to do:
/app/[lang]/ ?
can it be something like /app/[something-else]/?
/app/[lang]/ ?
can it be something like /app/[something-else]/?
17 Replies
Barbary Lion
dont do localization at the router level do it at a subdomain level and have a redirect to the correct subdomain
ex: us.example.com jp.example.com uk.example.com
localization within middleware and in your app router will be extremely expensive. middlware invokes a function on every route change which will add up quick.
ex: us.example.com jp.example.com uk.example.com
localization within middleware and in your app router will be extremely expensive. middlware invokes a function on every route change which will add up quick.
California pilchardOP
@Barbary Lion I'm confused, I thought this is what I need to do https://nextjs.org/docs/app/building-your-application/routing/internationalization#routing-overview
I need something like
Locale in English:
/help/[...id]/page.tsx
Locale in Spanish:
/asistir/[...id]/page.tsx
I need something like
Locale in English:
/help/[...id]/page.tsx
Locale in Spanish:
/asistir/[...id]/page.tsx
Barbary Lion
yeah i just saw @Multiflora rose seed chalcid posting on reddit about this someone did something similar and had a crazy expensive bill. Not sure if its fixed but every route change your calling a lambda function which is kinda dangerous.. say someone wanted to take your business out they'd just have to navigate to a ton of pages to drive up your bill. I could be wrong though hopefully lee chimes in and adds some clarity.
I've worked with some large international companies on multiple subdomains like www.ecoatm.com and we usually have a redirect to the appropriate subdomain so you dont have to worry about any of the above.
I've worked with some large international companies on multiple subdomains like www.ecoatm.com and we usually have a redirect to the appropriate subdomain so you dont have to worry about any of the above.
California pilchardOP
Are all the routes not being built statically?
Barbary Lion
depends on if your fetching data or using useState. if no data is dynamic then it'll be static but im pretty sure middleware methods will still get invoked.
@Barbary Lion so the best method to implement localization would be simply to make a separate website for each language?
Barbary Lion
First request would redirect through middleware and then save a cookie so it doesnt have to translate every time and every route it's just showing data for that country. Yeah you would have separate data for each country which is pretty normal.
so, we would have redirect with i18n. But how do we then recognise which language to use on the page? Do we host each domain as a different website separately?
you said that using middleware can be expensive, but I didnt find any other solutions
Barbary Lion
It depends on the scale of the app for a large app yes it would be separate apps and stacks for each country. Yeah not pretty sure we had a redirect at a load balancer level instead of in the application level
Then it just redirects to the correct stack for the right country which has all of it's associated data
I think theirs certain laws around this too where you can't store EU data with US data plus EU has different cookie laws so it's kind of easier just having them separate
For really basic stuff you probably don't need it at all most browsers automatically do translations
you are right
thanks for the guidance
Barbary Lion
Yeah might be better to get thoughts from @Multiflora rose seed chalcid or someone on the team. There are too many changes to keep up with lately and I keep seeing mistakes that are causing crazy high bills.
California pilchardOP
@Multiflora rose seed chalcid Hello, has this been improved or do we still the same problem? I can't find the reddit post regarding to this 😦