1

I have the following next-i18next.config.js file

 module.exports = {
  i18n: {
    locales: ["en", "de-DE", "fr"],
    defaultLocale: "en",
    localeDetection: false,
    domains: [
      {
        domain: "my-domain.com",
        defaultLocale: "en",
      },
      {
        domain: "my-domain.fr",
        defaultLocale: "fr",
        http: true,
      },
      {
        domain: "my-domain.de",
        defaultLocale: "de-DE",
        http: true,
      },
    ],
  },
};

I have set localeDetection to false, but when I change the language from en to fr my app is being redirected to http://my-domain.fr

My next.config.js is the following

const { i18n } = require("./next-i18next.config");

module.exports = {
  i18n,
};

Am I missing something?

Mario Nikolaus
  • 2,346
  • 1
  • 21
  • 28
user3009752
  • 164
  • 2
  • 9
  • 24

1 Answers1

1

I think you don't have right understanding of what locale detection exactly do.

Locale detection will automatically redirect user to correct locale website/page depending on his language preferences. What seems to bother you is that your locale is set to specific domain so your next router will always redirect you to the domain you have associated with your locale. So that is expected behaviour.

With locale detection set to false, you simply don't redirect user initially to his preferred locale.

Mario Nikolaus
  • 2,346
  • 1
  • 21
  • 28
  • Makes sense Mario. So this is fo the initial page load. After that if i redirect the user and change the local it will change the domain too. Correct? – user3009752 Nov 01 '21 at 12:18
  • Is i18n.changeLanguage('fr') supposed to work on nextJS? Because nothing changes. I can change the language only through router.replace – user3009752 Nov 01 '21 at 12:18
  • If you change locale through router.push or through link it should change the domain. I don't know how the i18next lib should work, so cannot help you with that. – Mario Nikolaus Nov 01 '21 at 12:28