import type { Locale } from "antd/es/locale";
import arEG from "antd/locale/ar_EG";
import enUS from "antd/locale/en_US";
import arabicLang from "assets/locals/ar.json";
import englishLang from "assets/locals/en.json";
import { DEFAULT_LANGUAGE } from "utils/constants";

export const LocalesMap = new Map<string, Locale>([
  ["en", enUS],
  ["ar", arEG],
]);

export const LOCALES = [
  { id: "ar", title: "العربية", iconPath: "/saudi-arabia.svg" },
  { id: "en", title: "English", iconPath: "/america.svg" },
];

export function getDirection(_locale: string) {
  if (_locale === "ar") return "rtl";

  return "ltr";
}

export const translationResources = {
  ar: { translation: arabicLang },
  en: { translation: englishLang },
};

export const getDefaultLanguage = () => {
  return (
    localStorage.getItem(DEFAULT_LANGUAGE) || import.meta.env.VITE_DEFAULT_LANGUAGE
  );
};
