Wednesday, 26 October 2022

Internationalized Routing in Nextjs

How can Nextjs detect the user's country and plug it into the URL if it helps we have the user's country in the cookies through Cloudflare, but we want our site to be personalized for a couple of countries. Nextjs docs suggested the following

i18n: {
    locales: ['en-US', 'fr', 'nl-NL'],
    defaultLocale: 'en-US', 
}

In my case, I don't want to manually plug all of the countries in both en and ar. Is there a way to detect it and change the URL accordingly or do you suggest plugging the countries we are interested in and having a default one for the rest of the world? I don't want to create common.json file for each one, for example, en-US and en-UK I want to have these as sub paths in my URL but I want them both to read from en/common.json



from Internationalized Routing in Nextjs

No comments:

Post a Comment