Issue
I want to select the default language of a website according the domain, for example :
www.test.fr --> default language is french
www.test.de --> default language is german
...
So how can I do that?
the application is developed using next.js and the backend is symfony 2.6
Solution
You need to add the i18n
config to your next.config.js
file:
// next.config.js
module.exports = {
i18n: {
// These are all the locales you want to support in
// your application
locales: ['en-US', 'fr', 'nl-NL'],
// This is the default locale you want to be used when visiting
// a non-locale prefixed path e.g. `/hello`
defaultLocale: 'en-US',
// This is a list of locale domains and the default locale they
// should handle (these are only required when setting up domain routing)
// Note: subdomains must be included in the domain value to be matched e.g. "fr.example.com".
domains: [
{
domain: 'example.com',
defaultLocale: 'en-US',
},
{
domain: 'example.nl',
defaultLocale: 'nl-NL',
},
{
domain: 'example.fr',
defaultLocale: 'fr',
},
],
},
}
More info and examples in the docs.
Answered By - Gh05d
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.