How can I setup multi domain configuration for i18next using nextjs?

Viewed 25

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

0 Answers
Related