1

This is my next-i18next.config.js file

module.exports = {
  i18n: {
    locales: ["en", "de"],
    defaultLocale: "en",
    domains: [
      {
        domain: "abc-english.com",
        defaultLocale: "en",
      },
      {
        domain: "abc-german.com",
        defaultLocale: "de",
      },
    ],
  },
};

This is my next.config.js file

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

Usage:

import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";

//inside component
const { t } = useTranslation("common");
{t("test")}

export async function getStaticProps({ locale }) {
  return {
    props: {
      ...(await serverSideTranslations(locale, ["common"])),
    },
  };
}

The problem: If I go to url: abc-english.com its working fine but when i go to abc-german.com it is redirecting me to abc-english.com

Mohammed Ismail
  • 104
  • 1
  • 12
  • 1
    That's most likely because of Next.js [automatic locale detection](https://nextjs.org/docs/advanced-features/i18n-routing#automatic-locale-detection), which you can disable by setting `localeDetection: false` in the i18n options inside `next.config.js`. See [defaultLocale is not keeping default lang in Next.js i18n](https://stackoverflow.com/questions/66730980/defaultlocale-is-not-keeping-default-lang-in-next-js-i18n). – juliomalves Sep 11 '22 at 21:15

0 Answers0