The challenge ahead:
Developing a website that caters to multiple countries, each with its own unique set of products, services, etc. The website also needs to be able to translate into different languages based on the country/TLD. Some domains may share certain translation languages. The desired outcome should look like this:
US
sitename.com - US market, English language (US)
Germany
sitename.de - native language
sitename.de/en - English language (INT)
France
sitename.fr - native language
sitename.fr/en - English language (INT)
Netherlands
sitename.nl - native language
sitename.nl/en - English language (INT)
United Kingdom
sitename.co.uk - English language (GB)
Current status:
In my next.config.js
, I have configured domain routing as shown in the following example:
module.exports = {
...
i18n: {
localeDetection: false,
defaultLocale: 'en',
locales: [],
domains: [
{
domain: 'sitename.com',
defaultLocale: 'en-US',
locales: []
},
{
domain: 'sitename.de',
defaultLocale: 'de-DE',
locales: ['en']
},
{
domain: 'sitename.fr',
defaultLocale: 'fr-FR',
locales: ['en']
},
{
domain: 'sitename.nl',
defaultLocale: 'nl-NL',
locales: ['en']
},
{
domain: 'sitename.co.uk',
defaultLocale: 'en-GB',
locales: []
},
// more countries can be added here...
]
}
}
Unfortunately, Next.JS is not cooperating with my configuration and throws the following error message:
Both sitename.de and sitename.fr configured the locale (en) but only one can. Remove it from one i18n.domains config to continue
Both sitename.fr and sitename.de configured the locale (en) but only one can. Remove it from one i18n.domains config to continue
Both sitename.nl and sitename.de configured the locale (en) but only one can. Remove it from one i18n.domains config to continue
Error: Invalid i18n.domains values:
{"domain":"sitename.de","defaultLocale":"de-DE","locales":["en"]}
{"domain":"sitename.fr","defaultLocale":"fr-FR","locales":["en"]}
{"domain":"sitename.nl","defaultLocale":"nl-NL","locales":["en"]}
The domains value must follow the format { domain: 'example.fr', defaultLocale: 'fr', locales: ['fr'] }.
For more information, refer to: https://nextjs.org/docs/messages/invalid-i18n-config
Question:
Is there a way to successfully implement this type of localization in NEXT.JS, where certain domains may share a language without needing to include every other language in the list?