import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { Language } from "./constants/Language";
import translationEnglish from "./i18n/English.json";
import translationFrançais from "./i18n/Français.json";
import translationDeutsche from "./i18n/Deutsche.json";
import translationNederlands from "./i18n/Nederlands.json";
import translationItaliano from "./i18n/Italiano.json";
import translationEspañola from "./i18n/Española.json";

const defaultLanguage = Language.en;
// the translations
const resources = {
  English: {
    translation: translationEnglish,
  },
  Français: {
    translation: translationFrançais,
  },
  Deutsche: {
    translation: translationDeutsche,
  },
  Nederlands: {
    translation: translationNederlands,
  },
  Italiano: {
    translation: translationItaliano,
  },
  Española: {
    translation: translationEspañola,
  },
};

i18n
  .use(initReactI18next) // passes i18n down to react-i18next
  .init({
    resources,
    lng: defaultLanguage,

    keySeparator: ".", // to support nested translations

    interpolation: {
      escapeValue: false, // react already safes from xss
    },
  });

export default i18n;
