Next.js Discord

Discord Forum

Select country and language - any ideas?

Answered
Horned oak gall posted this in #help-forum
Open in Discord
Horned oak gallOP
My app needs to be translated in different languages - but also available in different countries. So, for example, you could select language "German" while on the french version of the website.

Anyone got some ideas on how to do that? Language selection via next-intl or similar shouldn't be an issue, but combining these two seems somewhat of a bigger challenge.
Answered by B33fb0n3
ah that makes sense. I would add the language code to the url like https://shop.tld/[languageCode] and the country in the cookies. Like that you can easily get the country on calculation serverside and the pathname when rendering the page
View full answer

17 Replies

@B33fb0n3 country?
Horned oak gallOP
i want users to select language AND country
@Horned oak gall i want users to select language AND country
and how does your url look like? And how should it look after the change (correctly vs. right now)?
@B33fb0n3 and how does your url look like? And how should it look after the change (correctly vs. right now)?
Horned oak gallOP
that's actually up to me, and I'm currently exploring my options. I could do something like

de.shop.tld/en (germany, english language)

or shop.tld/de-en (same)

or just store everything in cookies
for what is the country important? I guess the language is important for the content language on the page itself, but the country?
Horned oak gallOP
prices may differ based on country. think of something like amazon
prices, shipping cost, etc
ah that makes sense. I would add the language code to the url like https://shop.tld/[languageCode] and the country in the cookies. Like that you can easily get the country on calculation serverside and the pathname when rendering the page
Answer
Horned oak gallOP
that was my first idea too - next to subdomains for countries, but that feels a bit off
@Horned oak gall prices may differ based on country. think of something like amazon
might want to compute price serverside by ip, relying on the client to give you accurate country info for prices might not be the best idea
@Lukas might want to compute price serverside by ip, relying on the client to give you accurate country info for prices might not be the best idea
Horned oak gallOP
i want the user to select it. I'll try to find it out, but - especially since it will be simply wrong many times - i want the user to be able to change it. additionally it would provide information about country-wide comparisons etc
@Horned oak gall solved?
@B33fb0n3 <@257212360479997953> solved?
Horned oak gallOP
should be, ya. I'll implement it slightly different; since selecting countries affects what you see, you'll be able to select multiple countries. by default you just see all countries, and by selecting countries the cookie will be set. language will stay in the url.
thanks for your help