"use client";

import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import HttpApi from "i18next-http-backend";

i18n
  .use(HttpApi)
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    fallbackLng: "en",
    supportedLngs: [
      "en", "fa", "ar", "zh", "hi", "es", "sw", "el", "sr",
      "fr", "ru", "bn", "pt", "id", "de", "ja", "te", "tr"
    ],
    defaultNS: "common",
    ns: ["common"],
    debug: process.env.NODE_ENV === "development",
    detection: {
      order: ["cookie", "localStorage", "navigator", "htmlTag"],
      caches: ["cookie"],
    },
    backend: {
      loadPath: "/locales/{{lng}}/{{ns}}.json",
    },
    react: {
      useSuspense: false,
    },
  });

export default i18n;
