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

export type Langs = "ru" | "en";

export interface Lang {
  nativeName: string;
}

export const languages: Record<Langs, Lang> = {
  ru: {
    nativeName: "Русский",
  },
  en: {
    nativeName: "English",
  },
};
export const popularLangKeys = ["ru", "en"];
const fallbackLng: Langs = "ru";

i18n
  .use(Backend)
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    debug: process.env.NODE_ENV === "development" ? true : false,
    fallbackLng,
    interpolation: {
      escapeValue: false,
    },
  });

export default i18n;
